Commit Graph

986 Commits

Author SHA1 Message Date
Jason Ekstrand 579578f10a vulkan/wsi/drm: Break create_prime_image in pieces
This is similar to the previous two commits that we did for DRM native
images.  It breaks it into configure/create/bind/finish and calls
wsi_create_image to walk through the process.  The primary difference is
that prime images need fifth step in the process to set up the blit
command buffer.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12031>
2022-01-31 19:46:54 +00:00
Jason Ekstrand 830d9967db vulkan/wsi: Add a helper for the configure/create/bind pattern
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12031>
2022-01-31 19:46:54 +00:00
Jason Ekstrand 5b13d74583 vulkan/wsi/drm: Break create_native_image in pieces
Instead of making create_native_image one monolithic function, break it
into a configure stage and a create stage.  The configure stage is
further broken up, first into a common piece that constructs a simple
VkImageCreateInfo and a couple chain-ins.  The second adds the extra
stuff for create_native_image.  This is to prepare for eventually
storing those structs in the swapchain itself.

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12031>
2022-01-31 19:46:54 +00:00
Jason Ekstrand 8299d5f37f vulkan/wsi: Set MUTABLE_FORMAT_BIT in the prime path
Fixes: 4bdf8547f4 "vulkan/wsi: Implement VK_KHR_swapchain_mutable_format"

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12031>
2022-01-31 19:46:54 +00:00
Caleb Callaway 7483c40ba0 vulkan/overlay: revise and reformat README
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14784>
2022-01-31 19:09:56 +00:00
Georg Lehmann cbe4943ae9 vulkan/wsi/wayland: Fix add_drm_format_modifier aplha/opaqueness.
This had the opposite problem of the shm path. R8G8B8A8 was always support if
either DRM_FORMAT_XBGR8888 or DRM_FORMAT_ABGR8888 was supported, but we need
both.

Fixes: d944136f36 ("vulkan/wsi/wayland: don't expose surface formats not fully supported")

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14588>
2022-01-31 17:50:01 +00:00
Georg Lehmann 9843fddfff vulkan/wsi/wayland: Add modifiers for RGB formats.
These formats get overwritten after the FALLTHROUGH, so no modifers got added
to them at all.

Fixes: 151b65b211 ("vulkan/wsi/wayland: generalize modifier handling")

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14588>
2022-01-31 17:50:01 +00:00
Georg Lehmann a881b6ac1f vulkan/wsi/wayland: Convert missing vulkan formats to shm formats.
Fixes: 6b36f35734 ("vulkan/wsi/wl: add wl_shm support for lavapipe.")

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14588>
2022-01-31 17:50:01 +00:00
Georg Lehmann 4ae4e04e18 vulkan/wsi/wayland: Fix add_wl_shm_format alpha/opaqueness.
We need both the SHM format with alpha and the opaque format to fully support
a vulkan format with alpha. Previously no surface format was reported because
the vulkan formats with aplha were never added as opaque.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5879
Fixes: d944136f36 ("vulkan/wsi/wayland: don't expose surface formats not fully supported")

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14588>
2022-01-31 17:50:01 +00:00
Ella Stanforth a53fd9b089 vulkan: Allow RegisterDisplayEventEXT before first page flip
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14685>
2022-01-31 12:49:26 +00:00
Emma Anholt bdb8e615d1 vulkan: Fix leak of error messages
Fixes: 0cad3beb2a ("vulkan/log: Add common vk_error and vk_errorf helpers")
Acked-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14235>
2022-01-27 23:47:46 +00:00
Chia-I Wu 4f1cf6fd3b vulkan/wsi/x11: fix x11_image_init return value on errors
fail_pixmap is reached when xshmfence alloc/map fails.  result is
VK_SUCCESS and we need to pick an error code explicitly.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14748>
2022-01-27 22:06:19 +00:00
Roman Gilg 6018d5c44a vulkan/wsi/x11: document implementation
To extend the shared understanding of our code base and ease contributing
document purpose and flow for many of our internal functions.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6536>
2022-01-27 09:14:29 +00:00
Jason Ekstrand cc8eb6f5df vulkan/runtime: Implement 1.3 features/properties
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14707>
2022-01-25 15:57:53 +00:00
Samuel Pitoiset 6a3928615b vulkan: Update the XML and headers to 1.3.204
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14707>
2022-01-25 15:57:53 +00:00
Michel Dänzer a429b3dd33 Revert "wsi/x11: Avoid a class of deadlocks in the WSI queue thread"
This reverts commit 272fba8e75.

Multiple regressions have been reported against this. Let's revert and
maybe try again.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5910
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5913
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14710>
2022-01-25 14:55:12 +00:00
Thomas H.P. Andersen 23135aece1 vulkan/vk_extensions_gen: fix -Wextern-initializer warning
vk_android_allowed_device_extensions is already declared as
extern in vk_extensions.h

Fixes a warning with clang

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14654>
2022-01-25 00:26:45 +00:00
Mike Blumenkrantz 3dcf275786 vulkan/wsi: add VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT for swapchain image caps
I need this, and drivers can do it, so add it

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14641>
2022-01-24 21:53:21 +00:00
Bas Nieuwenhuizen ce95871a50 vulkan/wsi/display: Add common implementation of VK_EXT_display_control.
Based on the new vk_sync functions.

Copied the version from anv as that seemed more thorough by using the
temporary sync payload. However that does mean we have do use the vk_sync
functions instead of being able to layer it on top of the dispatch table.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14365>
2022-01-24 12:57:35 +00:00
Adam Jackson 272fba8e75 wsi/x11: Avoid a class of deadlocks in the WSI queue thread
Here are two facts, each mildly unpleasant, quite nasty taken together:

- xcb_wait_for_special_event retries its poll() if the fd woke up but
  no matching event arrived, without verifying that the special event
  queue is still registered.
- Present gives no in-band notification of window destruction.

Now if the window is destroyed before the swapchain we're in trouble.
Our WSI thread might be stuck in xcb_wait_for_special_event as we're
awaiting a completion that won't come (the pixmap was being presented as
the window, and then the window was destroyed, so no more events can
happen on that window).

The solution is to use xcb_poll_for_special_event, which is
non-blocking, and handle the appropriate edge cases. If we've run the
event queue but we still don't have an image to acquire, we poke the X
server with a request that gently verifies that the window exists,
allowing the thread to exit gracefully in the above case.  We detect
when we're busy-looping, and poll on the X connection for up to 1ms in
response to avoid burning the CPU.

Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13564>
2022-01-21 19:46:14 +00:00
Samuel Pitoiset 6619f855d9 vulkan/runtime: fix accessing NULL pointers detected by UBSAN
Fixes: 7a84314c12 ("vulkan/runtime: Add sparse bind support.")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14619>
2022-01-19 16:16:08 +00:00
Chia-I Wu e6d7e1ec63 vulkan/wsi: add wsi_common_get_image
This can be useful with VkBindImageMemorySwapchainInfoKHR.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14544>
2022-01-14 17:41:42 +00:00
Danylo Piliaiev fa75b2a027 vulkan/wsi: create a common function to compare drm devices
Effectively moves most of v3dv_wsi_can_present_on_device to the
common code to be used in other drivers.

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11091>
2022-01-14 12:19:57 +00:00
Alejandro Piñeiro 821c66e50c vulkan: return default string for undefined enum
Instead of a unreachable.

This would avoid an assert on debug builds that uses vkfoo_to_str to
print structure types. This will become more common as some tests will
start to use VK_STRUCTURE_TYPE_MAX_ENUM to mark structures from
unsupported extensions more often.

v2 (Jason):
   * Include enum name on the default message
   * Handle MAX_ENUM as a special case

v3 (Jason):
   * vk_ObjectType_to_ObjectName don't need to use ${enum.name}

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14525>
2022-01-14 10:31:15 +00:00
Hyunjun Ko 58aa920706 vulkan: fix typo
Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14105>
2022-01-13 04:01:44 +00:00
Caleb Callaway 64a51293c8 vulkan/overlay: support Vulkan 1.2
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5602
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14465>
2022-01-13 02:02:14 +00:00
Pierre-Eric Pelloux-Prayer 7bd5aa111c vulkan/wsi: add a private transfer pool to exec the DRI_PRIME blit
The idea is to offer the driver a way to execute on a different queue
than the one the app is using for Present.

For instance, this could be used to make the DRI_PRIME blit asynchronous,
by using a transfer queue.

So instead of creating a command buffer to be executed on present using
the supplied queue, this commit uses an internal transfer queue to perform
the blit.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13959>
2022-01-11 12:18:35 +00:00
Pierre-Eric Pelloux-Prayer 0ad7ec56c9 vulkan/wsi: add use_prime_blit param to wsi_swapchain_init
Instead of initializing it to false and overriding it later if
needed.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13959>
2022-01-11 12:18:35 +00:00
Bas Nieuwenhuizen 85ca7fab29 radv: Add common entrypoint dependency.
To ensure we have the header. The revert likely reintroduced compilation flakiness due
to missing dependencies.

Fixes: a255f6f823 ("radv: do not use the common entrypoint for the Metro Exodus layer")
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14430>
2022-01-07 02:21:36 +00:00
Jason Ekstrand b2073f5e5d radv: Move QueueSignalReleaseImageANDROID to common code
This is mostly a copy+paste job but with a few syntax changes to make it
follow more closely with other common Vulkan code.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14372>
2022-01-05 16:36:10 +00:00
Jason Ekstrand dfb1e1777c anv,radv,v3dv: Move AcquireImageANDROID to common code
All three implementations are identical.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Tested-by: Tapani Pälli <tapani.palli@intel.com>
Tested-by: Roman Stratiienko <r.stratiienko@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14372>
2022-01-05 16:36:10 +00:00
Bas Nieuwenhuizen 7a84314c12 vulkan/runtime: Add sparse bind support.
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13974>
2021-12-31 15:14:18 +00:00
Bas Nieuwenhuizen 73cdc302ab vulkan/runtime: Refactor queue submit to take an argument struct.
For merging with the sparse binding structs.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13974>
2021-12-31 15:14:18 +00:00
Jason Ekstrand 88b9b68f30 vulkan/runtime: Validate instance version on 1.0 implementations
This isn't something that ANV or RADV have cared about in a long time
but, as people bring up new Vulkan drivers, shipping Vulkan 1.0 is still
a thing that happens in Mesa.  The common code should also implement the
1.0 rules.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14150>
2021-12-20 16:45:55 +00:00
Lionel Landwerlin b00086d393 anv,wsi: simplify WSI synchronization
Rather than using 2 vfuncs, use one since we've unified the
synchronization framework in the runtime with a single vk_sync object.

v2 (Jason Ekstrand):
 - create_sync_for_memory is now in vk_device

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14237>
2021-12-17 00:55:31 +00:00
Jason Ekstrand 2188829d29 vulkan/queue: Handle WSI memory signal information
We handle it by asking the driver to create a vk_sync that wraps a
VkDeviceMemory object and gets passed as one of the signal ops.

Fixes: 9bffd81f1c ("vulkan: Add common implementations of vkQueueSubmit and vkQueueWaitIdle")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14237>
2021-12-17 00:55:31 +00:00
Lionel Landwerlin cdf101455d vulkan: fix missing handling of WSI memory signal
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: b996fa8efa ("anv: implement VK_KHR_synchronization2")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5744
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14237>
2021-12-17 00:55:31 +00:00
Tomeu Vizoso f71713d43c lvp: Free the driver_data pointer for all commands
We were only freeing it for commands that had a struct as their
parameter, but all commands can have driver_data.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5715
Reported-by: Jose Fonseca <jfonsec@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14081>
2021-12-14 09:46:39 +01:00
Jakob Bornecrantz 555f93cdcd vulkan-device-select: Don't leak drmDevicePtr
ASAN found a leak:

```
Direct leak of 1440 byte(s) in 10 object(s) allocated from:
    #0 0x4a9a92 in calloc (build-Monado-CMake/src/xrt/targets/service/monado-service+0x4a9a92)
    #1 0x7fdf82afed06 in drmDeviceAlloc build-drm/../drm/xf86drm.c:3933:14
    #2 0x7fdf82b00203 in drmProcessPciDevice build-drm/../drm/xf86drm.c:3965:11
    #3 0x7fdf82b00203 in process_device build-drm/../drm/xf86drm.c:4359:16
    #4 0x7fdf82b0485e in drmGetDevice2 build-drm/../drm/xf86drm.c:4528:15
    #5 0x7fdf70751113 in device_select_find_xcb_pci_default ../src/vulkan/device-select-layer/device_select_x11.c:95:13
    #6 0x7fdf70751113 in get_default_device ../src/vulkan/device-select-layer/device_select_layer.c:395:21
    #7 0x7fdf70751113 in device_select_EnumeratePhysicalDevices ../src/vulkan/device-select-layer/device_select_layer.c:456:33
```

Cc: mesa-stable
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14068>
2021-12-06 11:21:03 +00:00
Yonggang Luo 6e7ffa760f vulkan: Open registry XML files as UTF-8
"C:\CI-Tools\msys64\mingw64\bin/python3.EXE" "../../src/vulkan/util/gen_enum_to_str.py" "--xml" "../../src/vulkan/registry/vk.xml" "--outdir" "C:/work/xemu/xemu-opengl/mesa/build/windows-mingw64/src/vulkan/util"
Traceback (most recent call last):
  File "C:\work\xemu\xemu-opengl\mesa\src\vulkan\util\gen_enum_to_str.py", line 473, in <module>
    main()
  File "C:\work\xemu\xemu-opengl\mesa\src\vulkan\util\gen_enum_to_str.py", line 462, in main
    f.write(template.render(
UnicodeEncodeError: 'gbk' codec can't encode character '\xa9' in position 107: illegal multibyte sequence

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14015>
2021-12-05 03:28:38 +08:00
Sergii Melikhov 7fb6eafbc4 vulkan: Unlock before return.
Fix defect reported by Coverity Scan CID-1494382.

Missing unlock (LOCK): Returning without unlocking queue->submit.mutex.

Fixes: 9bffd81f1c ("vulkan: Add common implementations of vkQueueSubmit and vkQueueWaitIdle")

Signed-off-by: Sergii Melikhov <sergii.v.melikhov@globallogic.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13933>
2021-11-24 15:15:46 +00:00
Michel Zou d7957df318 vulkan: fix uninitialized variables
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13892>
2021-11-23 19:11:05 +00:00
Alejandro Piñeiro ff89dc3523 vulkan: move common format helpers to vk_format
v3dv, radv, and turnip are using several C&P format helpers (most of
them wrappers over util_format_description based helpers).  methods.

This commit moves the common helpers to the already existing common
vk_format.h. For the case of v3dv we were able to remove the vk_format
header. For turnip and radv, a local vk_format.h header remains, with
methods that are only used for those drivers.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13858>
2021-11-19 12:23:19 +01:00
Joshua Ashton d0f217ad80 vulkan: Update the XML and headers to 1.2.199
Signed-off-by: Joshua Ashton <joshua@froggi.es>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13820>
2021-11-18 01:05:06 +00:00
Jason Ekstrand 63baeffc2d vulkan/sync: Rework asserts a bit
ANV currently smashes off the TIMELINE bit depending on whether or not
the i915 interface supports them, triggering assert(!type->get_value).
Instead of requiring ANV to smash off function pointers, let the extra
function pointers through and then assert on the feature bits before the
function pointers get used.  This should give us roughly the same amount
of assert protection while side-stepping the feature disabling problem.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13839>
2021-11-17 16:52:29 +00:00
Jason Ekstrand 8a11d2a31b vulkan: Add a dummy sync type
This is useful in WSI scenarios where you want to trivially signal a
fence or semaphore.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:54:27 -06:00
Jason Ekstrand 2a910071bc vulkan,anv: Auto-detect syncobj features
Instead of having a bunch of const vk_sync_type for each permutation of
vk_drm_syncobj capabilities, have a vk_drm_syncobj_get_type helper which
auto-detects features.  If a driver can't support a feature for some
reason (i915 got timeline support very late, for instance), they can
always mask off feature bits they don't want.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:54:27 -06:00
Jason Ekstrand c5ac1d1669 vulkan: Add an emulated binary vk_sync type
This wraps a timeline vk_sync type and turns it into a binary one.  This
is useful for, for instance, driver layered on D3D12.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:54:27 -06:00
Jason Ekstrand e3fda7ae78 vulkan/wsi/display: Wrap wsi_display_fence in a vk_sync
This gets rid of the bespoke vfunc interface in the WSI code.
Eventually, I'd love to get rid of wsi_display_fence entirely but
this at least makes it a lot more palatable.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:54:27 -06:00
Jason Ekstrand b1addc425a wsi/display: Rework wsi_fence a bit
Get rid of most of the guts of the base class and just leave it as a
vtable.  We can also drop some of wsi_display_fence.  One functional
change here is that we're now using VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE
which is more correct anyway because, thanks to the funky reference
counting we do with destroyed and event_received, its lifetime is tied
to the physical device, at best.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:54:27 -06:00
Jason Ekstrand 2bd3434fa2 vulkan/wsi: Drop wsi_common_get_current_time()
Use os_time_get_nano() instead.  At this point, it's just a wrapper
around os_time_get_nano() anyway.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:54:27 -06:00
Jason Ekstrand 7b19c9d19b vulkan/device: Log the timeline mode when lost
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:54:27 -06:00
Jason Ekstrand 9bffd81f1c vulkan: Add common implementations of vkQueueSubmit and vkQueueWaitIdle
This adds a new vk_queue_submit object which contains a list of command
buffers as well as wait and signal operations along with a driver hook
which takes a vk_queue and a vk_queue_submit and does the actual submit.
The common code then handles spawning a submit thread if needed, waiting
for timeline points to materialize, dealing with timeline semaphore
emulation via vk_timeline, etc.  All the driver sees are vk_queue.submit
calls with fully materialized vk_sync objects which it can wait on
unconditionally.

This implementation takes a page from RADV's book and only ever spawns
the submit thread if it sees a timeline wait on a time point that has
not yet materialized.  If this never happens, it calls vk_queue.submit
directly from vkQueueSubmit() and the thread is never spawned.

One other nicety of the new framework is that there is no longer a
distinction, from the driver's PoV, between fences and semaphores.  The
fence, if any, is included as just one more signal operation on the
final vk_queue_submit in the batch.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:54:27 -06:00
Jason Ekstrand 673b5e97ec vulkan: Add a common implementation of VkSemaphore
This is built on the new vk_sync primitives.  In the vk_physical_device,
the driver provides a null-terminated array of vk_sync_type pointers in
priority order.  The semaphore implementation then selects the first
type that meets the necessary criterion.  In particular, semaphores may
or may not be timelines depending on the VkSemaphoreType.  It also
auto-selects the semaphore type based on the external handle types
provided and can down-grade as needed to support a particular external
handle.

The implementation itself is mostly copy+pasted from ANV.  The primary
difference is the fact that anv_semaphore_impl has been replaced with
vk_sync.  The permanent vk_sync is still embedded (like ANV) but the
temporary one is a pointer.  This makes stealing the temporary state as
part of VkQueueSubmit a bit easier.

All of the interesting stuff around waits, signals, etc. is implemented
by the vk_sync interface.  All this code does is wrap it all in the
annoyingly detailed VkFence rules so we can provide the correct Vulkan
entrypoint behavior.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:54:27 -06:00
Jason Ekstrand 60e7359db0 vulkan: Add a common implementation of VkFence
This is built on the new vk_sync primitives.  In the vk_physical_device,
the driver provides a null-terminated array of vk_sync_type pointers in
priority order.  The fence implementation then selects the first type
that meets the necessary criterion.  In particular, fences can't be
timelines and need to support reset and CPU wait.  It also auto-selects
the fence type based on the external handle types provided and can
down-grade as needed to support a particular external handle.

The implementation itself is mostly copy+pasted from ANV.  The primary
difference is the fact that anv_fence_impl has been replaced with
vk_sync.  The permanent vk_sync is still embedded (like ANV) but the
temporary one is a pointer.  This makes stealing the temporary state as
part of VkQueueSubmit a bit easier.

All of the interesting stuff around waits, resets, etc. is implemented
by the vk_sync interface.  All this code does is wrap it all in the
annoyingly detailed VkFence rules so we can provide the correct Vulkan
entrypoint behavior.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:02:08 -06:00
Jason Ekstrand 301e20f7a3 vulkan: Add an emulated timeline sync type
This is mostly copy+paste (and a bit of re-typing) from ANV.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:02:08 -06:00
Jason Ekstrand 13ab3757bb vulkan: Add a common vk_drm_syncobj struct
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:02:08 -06:00
Jason Ekstrand fdb636e3a6 vulkan/vk_device: Add a drm_fd field
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:02:08 -06:00
Jason Ekstrand 95dee5150a vulkan/util: Include stdlib.h
It's needed for malloc() which is used by STACK_ARRAY

Fixes: f695171e38 ("vulkan: add common entrypoints for sparse image requirements/properties")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:02:08 -06:00
Jason Ekstrand 8134feb9a2 vulkan/meson: Re-arrange libvulkan_util deps a bit
Rename files_vulkan_runtime to vulkan_runtime_files and add a new
vulkan_runtime_deps array for dependencies.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:02:08 -06:00
Jason Ekstrand 3cf5fced4c vulkan: Add a vk_sync base class
This doesn't map directly to any particular Vulkan object but is,
instead, a base class for the internal implementations of both VkFence
and VkSemaphore.  Its utility will become evident in later patches.

The design of vk_sync will look familiar to anyone with significant
experience in DRM.  The base object itself is just a pointer to a vfunc
table with function pointers providing the implementation of the various
operations.  Depending on how the vk_sync will be used some of of those
vfuncs are optional.  If it's only going to be used for VkSemaphore, for
instance, there's no need for reset().

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:02:08 -06:00
Jason Ekstrand e9662e0154 vulkan/device: Add a check_status hook
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:02:08 -06:00
Jason Ekstrand dd89ef96d7 vulkan: Pull the device lost framework from ANV
It's a bit on the over-complicated side but the objective is to make the
debug log messages show up in the same thread as the first
VK_ERROR_DEVICE_LOST so we don't massively confuse the app.  It's
unknown if this is actually ever a problem but, with submit happening
off on its own thread, logging errors from threads the client doesn't
know about doesn't seem like a massively great plan.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
2021-11-16 10:02:08 -06:00
Danylo Piliaiev deb23612f7 vulkan/util: Handle depth-only formats in vk_att_ref_stencil_layout
From VUID-VkAttachmentReference2-attachment-04755:
 "If attachment is not VK_ATTACHMENT_UNUSED, and the format of the
  referenced attachment is a depth/stencil format which includes both
  depth and stencil aspects, and layout is
  VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL or
  VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL, the pNext chain must include
  a VkAttachmentReferenceStencilLayout structure."

We did not check that there even could be a stencil layout
before fetching it.

Fixes a few tests from:
 dEQP-VK.image.depth_stencil_descriptor.depth_read_only_optimal.*

Fixes: 979ea394e5 "vulkan/util: Move
helper functions for depth/stencil images to vk_iamge"

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13740>
2021-11-11 17:17:16 +00:00
Niklas Haas a697dde553 wsi/x11: support depth 30 visuals
There's only really one format that makes sense here, since there's no
sRGB equivalent for 10-bit packed formats.

It's possible that this results in flipped colors, if 10-bit visuals
exist that have the channels in the opposite order. (They don't seem to,
on my end)

Perhaps a more principled solution would also compare the exact r/g/b
bitmasks. But for now, this works.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3537
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9450>
2021-11-10 15:53:11 +00:00
Vinson Lee 794a9cf3d6 vulkan/wsi: Unlock before return on error path.
Fix defect reported by Coverity Scan.

Missing unlock (LOCK)
missing_unlock: Returning without unlocking wsi->wait_mutex.

Fixes: 4885e63a6d ("vulkan/wsi: implement missing wsi_register_device_event")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13698>
2021-11-10 13:22:24 +00:00
James Park 183e705a15 vulkan, radv: Support backslash in ICD paths
Vulkan loader wants backslash for paths on Windows. Need to jump through
hoops because Meson does not support backslashes in commands.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13461>
2021-11-10 09:48:41 +00:00
Hyunjun Ko 979ea394e5 vulkan/util: Move helper functions for depth/stencil images to vk_iamge
Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12785>
2021-11-09 16:12:04 +00:00
Dave Airlie 40157bc2b0 vulkan: add new image types undef beta define to switch statements.
This fixes some warnings when building with beta extensions enabled.

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13685>
2021-11-09 04:33:06 +00:00
Tapani Pälli 4885e63a6d vulkan/wsi: implement missing wsi_register_device_event
These changes implement vkRegisterDeviceEventEXT and detection of
monitor hotplug. Wsi launches a thread that listens to udev events and
signals the appropriate device fences when hotplug hapens.

v2: use wsi fences instead of syncobj api (Jason Ekstrand)
v3: refactor + cleanups, create thread on demand (Samuel Pitoiset)
v4: bring back syncobj support from initial version for radv
v5: make libudev dependency optional, check for poll errors (Simon Ser)
v6: change matching mechanism to use udev device node instead of path
v7: remove the matching mechanism
v8: fix a race with thread creation + use single mutex + other cleanups
    (Jason Ekstrand)

Fixes:
   dEQP-VK.wsi.display_control.register_device_event

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12305>
2021-11-04 16:57:29 +00:00
Tapani Pälli 73f21ea2e1 vulkan/wsi: provide api for drivers to setup syncobj fd
Drivers that import sync_fd to the wsi fences can use this to set file
descriptor for syncobj related calls. This fixes permission errors when
registering display/device events and importing sync_fd from driver
side.

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12305>
2021-11-04 16:57:29 +00:00
Mike Blumenkrantz dd71cc8947 lavapipe: fix cmd queuing for dynamic render
this sucks, but it should be sorted quickly in #5440

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13627>
2021-11-04 03:22:09 +00:00
Mike Blumenkrantz fbd5ded5e0 vk: update headers for 1.2.197
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13627>
2021-11-04 03:22:08 +00:00
Dave Airlie a8725ec3dc vulkan/wsi: set correct bits for host allocations/exports for images.
Lavapipe was hitting asserts in this area due to incorrect bits being
specified.

Set the handle type depending on the sw flag, and set a correct handle
type for the memory host ptrs.

v2: add image export struct to image creation (Jason)

Fixes: 895d3399f7 ("lavapipe: add support for KHR_external_memory_fd")
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13615>
2021-11-02 10:27:04 +10:00
Jason Ekstrand 4108fda426 vulkan: Move all the common object code to runtime/
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13156>
2021-10-29 23:12:32 +00:00
Jason Ekstrand 4af0c038cf vulkan: Move trampoline code-gen to its own file
This way we sepaprate the raw tables from the code that actively depends
on vk_device and friends.

Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13156>
2021-10-29 23:12:32 +00:00
Jason Ekstrand d53f20ff4d vulkan: Break entrypoint parsing into its own file
Instead of having a bunch of stuff depend on vk_dispatch_table_gen to
get the list of entrypoints, pull that into its own vk_entrypoints file.

Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13156>
2021-10-29 23:12:32 +00:00
Jason Ekstrand 8f9e0c2816 vulkan/dispatch_table: EntrypointBase doesn't need to derive from object
We use python3 now and everything derives from object automatically

Suggested-by: Dylan Baker <dylan@pnwbakers.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13156>
2021-10-29 23:12:32 +00:00
Jason Ekstrand 3fd7cc9d42 vulkan: Drop unnecessary [en]coding comments from python generators
Suggested-by: Dylan Baker <dylan@pnwbakers.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13156>
2021-10-29 23:12:32 +00:00
Jason Ekstrand a208b849f3 vulkan: Rework mako error handling in python generators
Suggested-by: Dylan Baker <dylan@pnwbakers.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13156>
2021-10-29 23:12:32 +00:00
Jason Ekstrand 837a142f2d vulkan/vk_extensions_gen: Stop including vk_object.h
All we need from it is vulkan_common.h for VkExtensionProperties.

Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13156>
2021-10-29 23:12:32 +00:00
Jason Ekstrand 741262ee01 vulkan/vk_extensions_gen: Drop support for extra includes
No one is using this anymore.

Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13156>
2021-10-29 23:12:32 +00:00
Lionel Landwerlin d944136f36 vulkan/wsi/wayland: don't expose surface formats not fully supported
Depending on whether an application creates a swapchain with
VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR or not, we might use 2
different formats with the compositor.

This change makes sure that we support all the underlying formats
before exposing the corresponding VkFormat to the application.

v2: Don't forget get_formats2() (Ivan)

v3: Replace formats with availability boolean (Simon)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 151b65b211 ("vulkan/wsi/wayland: generalize modifier handling")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5522
Reviewed-by: Ivan Briano <ivan.briano@intel.com> (v2)
Reviewed-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13453>
2021-10-26 16:12:06 +03:00
Boris Brezillon 1813bb5917 vulkan: Fix entrypoint generation when compiling for x86 with MSVC
When compiling for x86 with MSVC, Vulkan API entry points follow the
__stdcall convention (VKAPI_CALL maps to __stdcall), which uses the
following name mangling:

   _<function_name>@<arguments_size>

Fix the vk_entrypoint_stub()/alternatename definitions accordingly.

Fixes: 6d44b21d4f ("vulkan: Fix weak symbol emulation when compiling with MSVC")
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13516>
2021-10-25 18:31:22 +00:00
Connor Abbott 7a90aa8d2e vk/format, v3dv: Add a vulkan -> pipe swizzle helper
And use it to replace the one in v3dv.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13359>
2021-10-18 16:00:38 +00:00
Jason Ekstrand b79e978ae4 vulkan/wsi/win32: Delete the wrapper entrypoints
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13352>
2021-10-14 15:44:51 +00:00
Jason Ekstrand 116e23e385 vulkan/log: Don't assert on non-client-visible objects
We already have code to deal with non-client-visible objects but we were
asserting if it didn't fall into one of the clearly mappable error
cases.  However, we didn't have a mapping for VK_ERROR_NOT_PERMITTED
which can happen during object creation.  Let's just be sloppy and drop
the assert.  Worst case, the client gets an error with no object.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13341>
2021-10-14 14:23:45 +00:00
Jason Ekstrand 071437d29d vulkan/log: Tweak our handling of a couple error enums
VK_ERROR_INITIALIZATION_FAILED can happen as part of device creation and
isn't really an instance error in that case.
VK_ERROR_EXTENSION_NOT_PRESENT, on the other hand, is always an instance
thing and we should handle it as such.

Fixes: 0cad3beb2a ("vulkan/log: Add common vk_error and vk_errorf helpers")
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13341>
2021-10-14 14:23:45 +00:00
Boris Brezillon fd46749234 vulkan: Set unused entrypoints to vk_entrypoint_stub when compiling with MSVC
If we don't do that we hit the assert(entry[i] != NULL) added by commit
6d44b21d4f ("vulkan: Fix weak symbol emulation when compiling with MSVC").

Fixes: 6d44b21d4f ("vulkan: Fix weak symbol emulation when compiling with MSVC")
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13355>
2021-10-14 13:56:38 +00:00
Boris Brezillon 6d44b21d4f vulkan: Fix weak symbol emulation when compiling with MSVC
Mapping unimplemented entrypoints to a global function pointer variable
initialized to NULL is a bit cumbersome, and actually led to a bug
in the vk_xxx_dispatch_table_from_entrypoints() template: the !override
case didn't have the right check on the source table entries. Instead of
fixing that case, let's simplify the logic by creating a stub function
and making the alternatename pragma point to this stub. This way we get
rid of all those uneeded xxx_Null symbols/variables and simplify the
tests in vk_xxxx_dispatch_table_from_entrypoints().

Cc: mesa-stable
Fixes: 98c622a96e ("vulkan: Update dispatch table gen for Windows")
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13348>
2021-10-14 09:09:23 +02:00
Adam Jackson b01fe97a39 wsi/x11: Fetch and discard the SYNC extension info
Since we're not checking for this, xcb has to do it for us the first
time we call xcb_sync_destroy_fence, which puts a blocking round-trip in
the swapchain destroy path for no reason. Check for the extension so we
have the extension's opcode cached when we need it.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13339>
2021-10-13 16:11:11 +00:00
Jason Ekstrand a00f4c6f7d vulkan/wsi/display: Delete the wrapper entrypoints
Acked-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13234>
2021-10-13 00:06:15 +00:00
Jason Ekstrand 8abeecf505 vulkan/wsi/wayland: Delete the wrapper entrypoints
Acked-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13234>
2021-10-13 00:06:15 +00:00
Jason Ekstrand 8ade418144 vulkan/wsi/x11: Delete the wrapper entrypoints
Acked-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13234>
2021-10-13 00:06:15 +00:00
Jason Ekstrand 1680cd907d vulkan/wsi/common: Delete the wrapper entrypoints
Acked-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13234>
2021-10-13 00:06:15 +00:00
Jason Ekstrand 75955c6685 vulkan/wsi: Add common wrappers for most entrypoints
For a long time, our Vulkan WSI code has acted as something of a layer.
The WSI code calls into various Vulkan entrypoints inside the driver to
create images, allocate memory, etc.  It then implements the API-facing
interface almost entirely.  The only thing the driver has to provide is
little wrappers that wrap around the WSI calls to expose them through
the API.

However, now that we have a common dispatch framework, we can implement
entrypoints directly in the WSI code.  As long as the driver uses
vk_instance, vk_physical_device, and vk_device, we can provide common
wrappers for the vast majority of entrypoints.  The only exceptions are
vkAcquireNextImage, vkQueuePresent, vkRegisterDeviceEventEXT, and
vkRegisterDisplayEventEXT because those may have to manually poke at
synchronization primitives.  We provide wrappers for vkAcquireNextImage
and vkQueuePresent because some drivers can use the default versions.

For now, we're intentionally avoiding any link-time dependencies between
WSI and the common code.  We only use VK_FROM_HANDLE and associated
inline helpers and vk_physical_device has a pointer to a wsi_device.
Eventually, we may tie the two together closer, but this lets us get 95%
of the way there without reworking the universe.

Acked-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13234>
2021-10-13 00:06:15 +00:00
Jason Ekstrand 020fbb9ea1 vulkan/wsi: Add a dispatch table for WSI entrypoints
Acked-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13234>
2021-10-13 00:06:15 +00:00
Jason Ekstrand 916c9335b4 meson: Add and use an idep for Vulkan WSI
Acked-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13234>
2021-10-13 00:06:15 +00:00
Iván Briano 0b75b88651 vulkan: Generate defines for aliases of promoted enums
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13264>
2021-10-11 18:14:06 +00:00
Iván Briano 1c2cd8bc16 vulkan: fix handling of aliases in enum members
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13264>
2021-10-11 18:14:06 +00:00
Jason Ekstrand 1d4d71057b vulkan: Generate #defines with every bit in a given bitfield
This is useful when trying to restrict from VkFoo2 to VkFoo.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13198>
2021-10-11 10:29:05 -05:00
Jason Ekstrand 2741762ca9 vulkan: Generate flag #defines based on bitwidth
Instead of basing it on a fixed list, just generate #defines for every
bitfield that's 64-bit.  As part of this refactor, we rework things a
bit to record all bitfields and just not do anything with them if
they're not 64-bit.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13198>
2021-10-11 10:28:58 -05:00
Yogesh Mohanmarimuthu 5317874f91 vulkan/device-select: select correct default device for xcb apiVersion 1.0
In function fill_drm_device_info(), struct ext_pci_properties is filled only
if has_vulkan11 is true. But the data received from ext_pci_properties is used
without checking for has_vulkan11. Fixing this by setting
drm_device->has_bus_info also if has_vulkan11 is true.

This fix will help in case of nonidentical gpu being used and xcb_surface
extension enabled.

Signed-off-by: Yogesh Mohanmarimuthu <yogesh.mohanmarimuthu@amd.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12816>
2021-10-08 13:51:33 +00:00
Chia-I Wu 8cce6281e6 util/vector: make util_vector_init harder to misuse
Make u_vector_init a wrapper to u_vector_init_pot.  Let both take
(element_count, element_size) as parameters.

Motivated by eed0fc4caf ("vulkan/wsi/wayland: fix an invalid
u_vector_init call")

v2: rename u_vector_init_pot to u_vector_init_pow2

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13201>
2021-10-08 00:15:11 +00:00
Jason Ekstrand 305b170229 vulkan/device: Use vk_errorf to report missing features
With a tiny bit more code-gen, we can now not only throw the error but
also log back to the client exactly which feature was missing.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13045>
2021-10-07 20:51:36 +00:00
Jason Ekstrand 5b42f1a374 vulkan/device: Use vk_error
Tested-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13045>
2021-10-07 20:51:36 +00:00
Jason Ekstrand 330f4c9bc9 vulkan/instance: Use vk_error in vk_instance_init
We have to be a bit careful here.  Calling log functions during instance
initialization can be a bit sketchy.  However, we know that __vk_log_impl
only ever touches the callbacks lists if instance->base.client_visible
so it's safe to call vk_error as soon as we've set up instance_callbacks.

Tested-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13045>
2021-10-07 20:51:36 +00:00
Jason Ekstrand ad27db2ae9 vulkan/log: Drop _impl from the log helper names
Now that we no longer have every driver in the tree defining their own
__vk_errorf and __vk_errorv, we don't need to worry about the symbol
collision anymore and can use the "real" names for the common ones.

Tested-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13045>
2021-10-07 20:51:36 +00:00
Jason Ekstrand 0cad3beb2a vulkan/log: Add common vk_error and vk_errorf helpers
These helpers have quite a bit of smarts in them to log errors to chase
the object chain as needed and log errors to roughly the appropriate
object.  For instance, VK_ERROR_OUT_OF_DEVICE_MEMORY always goes to a
device while VK_ERROR_OUT_OF_HOST_MEMORY always goes to the instance.

Tested-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13045>
2021-10-07 20:51:36 +00:00
Jason Ekstrand ec34ec388b vulkan/log: Handle logging to a physical device
Instance-level objects won't have a device pointer so we can't rely on
that.  Instead, we should look at the object type and try to chase it
back to an instance.  Sadly, we can't do that for certain display and
WSI objects.  However, we never use the vk_log* helpers for those.

Tested-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13045>
2021-10-07 20:51:36 +00:00
Jason Ekstrand 9067c12d2a vulkan/log: Log to instance messages during instance construction
If the instance isn't client-visible yet (i.e. foo_instance_to_handle
hasn't been called), then the instance is still under construction and
we should log using vk_debug_message_instance.  This makes the vk_log*
macros work regardless of whether the instance is fully constructed or
not.

Tested-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13045>
2021-10-07 20:51:35 +00:00
Jason Ekstrand e884e35077 vulkan/log: Assert if the driver logs a client-invisible object
Tested-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13045>
2021-10-07 20:51:35 +00:00
Jason Ekstrand 571b5f5000 vulkan: Track which objects are client-visible
When dealing with debug logging, it's useful to track when an object's
construction is finished and it's now visible to the client.  We can
detect this pretty easily by setting a flag the first time foo_to_handle
is called.  As long as drivers only ever call that function at the end
of object construction (they all do to my knowledge), this should be a
reliable mechanism for detecting when a client knows about a handle.

Tested-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13045>
2021-10-07 20:51:35 +00:00
Jason Ekstrand a815b2b3c1 vulkan: Drop vk_object_base_reset
It's no longer used and just makes the init/finish path more
complicated.

Tested-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13045>
2021-10-07 20:51:35 +00:00
Lionel Landwerlin 97f0a4494b vulkan: implement legacy entrypoints on top of VK_KHR_synchronization2
v2: fix common vkQueueSubmit() pNext generation
    fix potential leak of perf_query_submit_info
    fix comment about casting VkQueue to vk_object_base
    add helper for barrier struct upgrades (Jason)
    reuse __vk_append_struct() (Jason)
    optimize vk_common_GetQueueCheckpointDataNV
    use multialloc for vk_common_QueueSubmit (Dave)

v3: Reuse new vk_queue/vk_command_buffer objects
    Fixup CmdWaitEvents() (Jason)

v4: Add comment about dep_flags for CmdWaitEvents() (Jason)

v5: Drop multialloc in VkQueueSubmit entrypoint (Jason)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> (v5)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9045>
2021-10-06 20:22:38 +00:00
Lionel Landwerlin 9af7506370 vulkan/util: generate define for a selected few enums
One of the unfortunate effect of Vulkan starting to use 64bit bitmasks
is that they can no longer be defined using enums because C doesn't
guarantees that enum values will be 64bits.

Vulkan therefore started using those patterns :

  static const VkAccessFlags2KHR VK_ACCESS_2_INDIRECT_COMMAND_READ_BIT_KHR = 0x00000001;

This has the effect that we can not longer use those values in
switch/case statements.

This change introduces defines so that we can keep doing this. For now
only VkAccessFlags2KHR/VkPipelineStageFlags2KHR are allowed to be
redefined this way, this list could be changed later (or all bitmask
could be processed this way).

v2: Generate hexadecimal numbers (Jason)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9045>
2021-10-06 20:22:37 +00:00
Lionel Landwerlin dbf4cfeff5 vulkan: remove unused VkCommand
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9045>
2021-10-06 20:22:37 +00:00
Lionel Landwerlin 59e98694be vulkan: handle new VK_KHR_synchronization2 image layouts
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9045>
2021-10-06 20:22:37 +00:00
Lionel Landwerlin 2ff3fd4773 vulkan: put generated defines into their own header
v2: Put vk_enum_defines.h in the list of generated files

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9045>
2021-10-06 20:22:37 +00:00
Dave Airlie 7d388c8d09 wsi/x11: cleanup properly after mit shm paths are used.
This path was being skipped on sw + has_mit_shm, when it
shouldn't be.

Fixes: a069b4e9b9 ("vulkan/wsi/sw: add mit-shm support for pixmap allocation")
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13217>
2021-10-07 05:43:27 +10:00
Mike Blumenkrantz 7cc85dba71 build: unify vulkan cpp platform args
these were duplicated all over the place, and it's annoying to have to keep
duplicating them any time a new component includes the vulkan header

Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13141>
2021-10-06 14:19:35 +00:00
Dave Airlie ab1c888c8d device_select: close dri3 fd after using it.
This can leak and causes crashes in some CTS test groups
dEQP-VK.wsi.xcb.incremental_present*

Fixes: 9bc5b2d169 ("vulkan: add initial device selection layer. (v6.1)")
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13215>
2021-10-06 18:24:54 +10:00
Jason Ekstrand 7677f1d09e vulkan: Update the XML and headers to 1.2.195
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13199>
2021-10-06 02:18:39 +00:00
Chia-I Wu eed0fc4caf vulkan/wsi/wayland: fix an invalid u_vector_init call
u_vector_init requires size to be power-of-two.

Fixes: 151b65b211 ("vulkan/wsi/wayland: generalize modifier handling")
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13186>
2021-10-05 17:42:41 +00:00
Jason Ekstrand 2f55aace9c vulkan/physical_device_features: Stop generating a header
It only has one entrypoint and nothing in it is based on code-gen.  We
can put that one entrypoint in vk_physical_device.h instead.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13150>
2021-10-04 22:42:32 +00:00
Jason Ekstrand ec9619a83e vulkan/physical_device_features: Drop some unnecessary dependencies
None of these are actually used.  We parse the XML bare and don't need
any extension or entrypoint information.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13150>
2021-10-04 22:42:32 +00:00
Adam Jackson aa30e58600 wsi/x11: Fix a misunderstanding about how xcb_get_geometry works
The code here is well-intentioned, but the only way a GetGeometry
request can fail is if you name an invalid drawable. And if we did that,
either our internal state got corrupted, or - more likely - the user
destroyed the window. In either case there's nothing more we can do with
the surface, so report that it's been lost.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13104>
2021-10-04 15:30:06 +00:00
Tapani Pälli 2e5718c957 vulkan: provide common functions to check device features
v2: move checks to vk_device_init, ignore struct types from
    provisional extensions + lots of cleanups/fixes (Jason Ekstrand)
v3: squash in following patch from Jason:
    "vulkan: Restructure vk_physical_device_check_device_features()"
v4 (Jason): Fix a Windows build error

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12867>
2021-10-01 17:37:02 +00:00
Mike Blumenkrantz 85c38d192f wsi/x11: fix uninit value by using zalloc for swapchain
==767499== Conditional jump or move depends on uninitialised value(s)
==767499==    at 0xEB8E3ED: x11_image_finish (wsi_common_x11.c:1539)
==767499==    by 0xEB8E768: x11_swapchain_destroy (wsi_common_x11.c:1640)
==767499==    by 0xEB8A8FA: wsi_common_destroy_swapchain (wsi_common.c:505)
==767499==    by 0xDE30BA1: anv_DestroySwapchainKHR (anv_wsi.c:242)
==767499==    by 0x6817A21: copper_displaytarget_destroy (zink_copper.c:192)
==767499==    by 0x6882BE6: zink_destroy_resource_object (zink_resource.c:95)
==767499==    by 0x6882447: zink_resource_object_reference (zink_resource.h:198)
==767499==    by 0x6882D33: zink_resource_destroy (zink_resource.c:123)
==767499==    by 0x688AC97: pipe_resource_destroy (u_inlines.h:145)
==767499==    by 0x688AD2E: pipe_resource_reference (u_inlines.h:162)
==767499==    by 0x688BE1E: zink_destroy_surface (zink_surface.c:319)
==767499==    by 0x688AE0A: zink_surface_reference (zink_surface.h:102)
==767499==    by 0x688BE6D: zink_surface_destroy (zink_surface.c:328)
==767499==    by 0x67F9CA2: pipe_surface_release (u_inlines.h:134)
==767499==    by 0x67FB8AD: zink_context_destroy (zink_context.c:92)
==767499==    by 0x5D47B65: st_destroy_context_priv (st_context.c:475)
==767499==    by 0x5D49AF2: st_destroy_context (st_context.c:1193)
==767499==    by 0x5D5C90F: st_context_destroy (st_manager.c:816)
==767499==    by 0x5CC1FC9: dri_destroy_context (dri_context.c:248)
==767499==    by 0x658DD63: driDestroyContext (dri_util.c:535)
==767499==    by 0x5A30166: drisw_destroy_context (drisw_glx.c:417)
==767499==    by 0x5A32484: glXDestroyContext (glxcmds.c:515)
==767499==    by 0x5315AEB: glXDestroyContext (libglx.c:332)
==767499==    by 0x4AA8E7D: glXDestroyContext (g_libglglxwrapper.c:384)
==767499==    by 0x4D5A3F0: ??? (in /usr/lib64/libwaffle-1.so.0.6.1)
==767499==    by 0x499DDD5: piglit_wfl_framework_teardown (piglit_wfl_framework.c:638)
==767499==    by 0x499E4C5: piglit_winsys_framework_teardown (piglit_winsys_framework.c:238)
==767499==    by 0x499F50C: destroy (piglit_x11_framework.c:212)
==767499==    by 0x498C535: destroy (piglit-framework-gl.c:210)
==767499==    by 0x4F48AF6: __run_exit_handlers (in /usr/lib64/libc-2.33.so)
==767499==    by 0x4F48C9F: exit (in /usr/lib64/libc-2.33.so)
==767499==    by 0x4AEFD71: piglit_report_result (piglit-util.c:245)
==767499==    by 0x499F2CA: process_next_event (piglit_x11_framework.c:139)
==767499==    by 0x499F365: enter_event_loop (piglit_x11_framework.c:153)
==767499==    by 0x499DF88: run_test (piglit_winsys_framework.c:88)
==767499==    by 0x498C5EF: piglit_gl_test_run (piglit-framework-gl.c:229)
==767499==    by 0x4022B4: main (primitive-restart.c:45)
==767499==  Uninitialised value was created by a heap allocation
==767499==    at 0x484086F: malloc (vg_replace_malloc.c:380)
==767499==    by 0xE964E85: vk_default_alloc (vk_alloc.c:26)
==767499==    by 0xEB8B24B: vk_alloc (vk_alloc.h:43)
==767499==    by 0xEB8EAF9: x11_surface_create_swapchain (wsi_common_x11.c:1723)
==767499==    by 0xEB8A82A: wsi_common_create_swapchain (wsi_common.c:476)
==767499==    by 0xDE30B47: anv_CreateSwapchainKHR (anv_wsi.c:225)
==767499==    by 0xE96134F: vk_tramp_CreateSwapchainKHR (vk_dispatch_table.c:6592)
==767499==    by 0xD7B88F0: ??? (in /usr/lib64/libvulkan.so.1.2.162)
==767499==    by 0x6817796: copper_CreateSwapchain (zink_copper.c:123)
==767499==    by 0x6817960: copper_displaytarget_create (zink_copper.c:170)
==767499==    by 0x6884C65: resource_create (zink_resource.c:780)
==767499==    by 0x6884EC5: zink_resource_create_drawable (zink_resource.c:829)
==767499==    by 0x5CC0FE3: copper_allocate_textures (copper.c:199)
==767499==    by 0x5CC28C2: dri_st_framebuffer_validate (dri_drawable.c:82)
==767499==    by 0x5D5B69A: st_framebuffer_validate (st_manager.c:222)
==767499==    by 0x5D5D32D: st_api_make_current (st_manager.c:1102)
==767499==    by 0x5CC220B: dri_make_current (dri_context.c:306)
==767499==    by 0x658DE23: driBindContext (dri_util.c:588)
==767499==    by 0x5A3022A: drisw_bind_context (drisw_glx.c:435)
==767499==    by 0x5A36CC2: MakeContextCurrent (glxcurrent.c:220)
==767499==    by 0x5A36DF9: glXMakeCurrent (glxcurrent.c:253)
==767499==    by 0x531849C: InternalMakeCurrentVendor (libglx.c:875)
==767499==    by 0x53185C3: InternalMakeCurrentDispatch (libglx.c:930)
==767499==    by 0x5318DE5: CommonMakeCurrent (libglx.c:1074)
==767499==    by 0x5318ED5: glXMakeCurrent (libglx.c:1119)
==767499==    by 0x4AA9CFA: glXMakeCurrent (g_libglglxwrapper.c:930)
==767499==    by 0x4D5AA36: ??? (in /usr/lib64/libwaffle-1.so.0.6.1)
==767499==    by 0x4D5E16E: waffle_make_current (in /usr/lib64/libwaffle-1.so.0.6.1)
==767499==    by 0x499C8CD: wfl_checked_make_current (piglit-util-waffle.h:115)
==767499==    by 0x499DA04: make_context_current_singlepass (piglit_wfl_framework.c:488)
==767499==    by 0x499DC43: make_context_current (piglit_wfl_framework.c:565)
==767499==    by 0x499DD88: piglit_wfl_framework_init (piglit_wfl_framework.c:628)
==767499==    by 0x499E3FC: piglit_winsys_framework_init (piglit_winsys_framework.c:209)
==767499==    by 0x499F581: piglit_x11_framework_create (piglit_x11_framework.c:229)
==767499==    by 0x499E361: piglit_winsys_framework_factory (piglit_winsys_framework.c:175)
==767499==    by 0x498CA60: piglit_gl_framework_factory (piglit_gl_framework.c:53)
==767499==    by 0x498C587: piglit_gl_test_run (piglit-framework-gl.c:221)
==767499==    by 0x4022B4: main (primitive-restart.c:45)

Fixes: b5c390c113 ("vulkan/wsi: add support for detecting mit-shm pixmaps.")

Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13124>
2021-09-30 19:56:51 +00:00
Jason Ekstrand 24637a6579 vulkan/shader_module: Fix the lifetime of temporary shader modules
The vk_shader_module_handle_from_nir() macro was constructing a
temporary vk_shader_module and passing it through
vk_shader_module_to_handle().  Since this is a function and not a macro,
it means that the lifetime of the temporary vk_shader_module will end
once the to_handle() function is called.  Technically, this is a
use-after-free.  I really don't know why no one has been bitten by this
yet....

Fixes: a41e98ddca "vk/util: add a util macro for initializing stack..."
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13101>
2021-09-29 23:27:52 +00:00
Joshua Ashton adbe4022c6 vulkan/util: Cast vk_alloc pointers
Fixes errors when trying to use vk_alloc.h from C++ code.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13103>
2021-09-29 17:42:17 +00:00
Jason Ekstrand 0e4266260a vulkan/device: Add a common DeviceWaitIdle implementation
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13003>
2021-09-28 21:08:25 +00:00
Jason Ekstrand 3b535d28d2 vulkan/device: Add a common GetDeviceQueue2 implementation
If we store the queues in a linked list in the device as vk_queue_init
is called then we can handle enumeration in common code.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13003>
2021-09-28 21:08:25 +00:00
Jason Ekstrand b2313b6884 vulkan: Add the pCreateInfo to vk_queue_init()
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13003>
2021-09-28 21:08:25 +00:00
Emma Anholt cc6954ec0b vulkan: Update the XML and headers to 1.2.193
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13007>
2021-09-24 17:55:10 +00:00
Yevhenii Kolesnikov d55d1fcda2 vulkan: Add convenience debug message helpers
Forwards the message to both VK_EXT_debug_utils and
VK_EXT_debug_report provided callbacks.

Signed-off-by: Yevhenii Kolesnikov <yevhenii.kolesnikov@globallogic.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10318>
2021-09-23 21:14:32 +00:00
Yevhenii Kolesnikov 2db5536a46 vulkan: Add vk_asprintf and vk_vasprintf helpers
Signed-off-by: Yevhenii Kolesnikov <yevhenii.kolesnikov@globallogic.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10318>
2021-09-23 21:14:32 +00:00
Yevhenii Kolesnikov 98d22acca2 vulkan/enum_to_str: Add generator for VkObjectType to Vulkan Handle
Signed-off-by: Yevhenii Kolesnikov <yevhenii.kolesnikov@globallogic.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10318>
2021-09-23 21:14:32 +00:00
Yevhenii Kolesnikov 3b361b234a vulkan: Implement VK_EXT_debug_utils
This implements all the necessary features of VK_EXT_debug_utils in
common code.

Signed-off-by: Yevhenii Kolesnikov <yevhenii.kolesnikov@globallogic.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10318>
2021-09-23 21:14:32 +00:00
Emma Anholt 8a54903a48 vulkan: Support PHYSICAL_DEVICE_1_n_ features/properties in the helpers.
Since we have a filled out struct available, just memcpy it over so the
driver doesn't have to fill it out again.

Suggested by Jason, this is code that isn't copy-and-paste from anv.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12967>
2021-09-23 16:19:47 +00:00
Emma Anholt 19ff5019b7 vulkan: Add helpers for filling exts for core features and properties.
This is boilerplate that drivers have to replicate, so make a nice helper.
The feature/property macro lists are are copy and pasted from anv, though
the helper functions has been split between 1.1 and 1.2 (and thus the macros
refactored).

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12967>
2021-09-23 16:19:47 +00:00
Yevhenii Kolesnikov cff01303b5 vulkan: Add a common vk_queue structure
This can be used e.g. for storing debug labels for the common
implementation of VK_EXT_debug_utils.

Signed-off-by: Yevhenii Kolesnikov <yevhenii.kolesnikov@globallogic.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13000>
2021-09-23 15:57:46 +00:00
Yevhenii Kolesnikov ef9c371f60 vulkan: Add a common vk_command_buffer structure
This can be used e.g. for storing debug labels for the common
implementation of VK_EXT_debug_utils.

Signed-off-by: Yevhenii Kolesnikov <yevhenii.kolesnikov@globallogic.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13000>
2021-09-23 15:57:45 +00:00
Zachary Michaels fc5ea6a054 X11: Ensure that VK_SUBOPTIMAL_KHR propagates to user code
Commit 0245b825 switched from returning the error code VK_ERROR_OUT_OF_DATE_KHR
to returning the success code VK_SUBOPTIMAL_KHR. Prior to that commit, the error
code caused all code paths to fail immediately, but the success code does not.

Currently the success code is not recorded in some scenarios, resulting in a
result of VK_SUCCESS instead. This breaks applications that rely on the
result (per the spec) to trigger resizes.

This commit ensures that the proper VK_SUBOPTIMAL_KHR success code is set as a
sticky status (as comments indicate was intended), ensuring that it is
propagated to user code.

Fixes #5331

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12782>
2021-09-20 16:43:10 +00:00
Simon Ser 3c18e69078 vulkan/wsi/x11: add driconf option to not wait under Xwayland
By default, Mesa's X11 Vulkan WSI will wait for buffers to be ready
before submitting them to Xwayland when the swapchain is created
with the IMMEDIATE mode.

This is undesirable when the Wayland compositor already monitors
fences. A Wayland compositor may want to know the delay between
the buffer submition and the end of the GPU work, this is impossible
to measure if the WSI waits for the buffer to be ready before
submission.

Since most compositors don't monitor fences, let's introduce a driconf
option for this for now. We can reconsider once more compositors
have better support for fences.

Signed-off-by: Simon Ser <contact@emersion.fr>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11290>
2021-09-13 19:38:13 +00:00
Danylo Piliaiev 3dd1bb6355 turnip: implement basic perfetto support
Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Hyunjun Ko <zzoon@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10969>
2021-09-10 14:58:28 +03:00
Marcin Ślusarz 8408cce303 vulkan/wsi/x11: fix shm allocation control flow issue
shmget returns -1 on error. alloc_shm assigns it to an unsigned variable
and then checks whether it's < 0, which will never be true.

Found by Coverity.
CID: 1490891

Fixes: 1f55f9a97a ("vulkan/wsi/sw: add support for using host_ptr for shm pixmaps.")

Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12696>
2021-09-03 08:33:36 +00:00
Tomeu Vizoso 0005b90ba9 vulkan: Copy pNext structures when enqueuing commands
There is enough information in vk.xml to figure how to copy the chain of
extensions, so use it.

Otherwise, the caller might have released the structs after recording
the command but before it executes.

Closes #5314.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reported-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12701>
2021-09-03 07:33:21 +02:00
Tomeu Vizoso 03d586899e Revert "lavapipe: unbreak imageless framebuffer"
This reverts commit c679dbe09c.

No need to override the generated cmd enqueing function, we can use the
information in vk.xml to do the right thing with pNext arguments.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12701>
2021-09-03 07:33:21 +02:00
Samuel Pitoiset f695171e38 vulkan: add common entrypoints for sparse image requirements/properties
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12416>
2021-09-02 10:56:39 +00:00
Iago Toral Quiroga 77f2e2a75f vulkan: allow creating color views from depth/stencil images
Some drivers may want to implement certain depth/stencil operations by
reinterpreting a depth/stencil format as a color format. This is not
strictly allowed by the Vulkan spec, so handle it separately.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12668>
2021-09-02 05:53:39 +00:00
Mike Blumenkrantz c679dbe09c lavapipe: unbreak imageless framebuffer
vk cmd queue doesn't copy pNext pointers

Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12688>
2021-09-01 21:40:00 -04:00
Tomeu Vizoso ec44c48945 vulkan: Remove dependency on Python 3.9+
Closes #5311.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Fixes: 997a6ca226 ("vulkan: Generate entrypoints that enqueue commands")
Fixes: a7b0946ef0 ("vulkan: Generate code to place commands in a queue")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12672>
2021-09-01 19:46:14 +00:00
Tomeu Vizoso 997a6ca226 vulkan: Generate entrypoints that enqueue commands
For drivers such as Lavapipe that record the commands at the execution
stage.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Antonio Caggiano <antonio.caggiano@collabora.com>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12369>
2021-09-01 01:05:22 +00:00
Tomeu Vizoso a7b0946ef0 vulkan: Generate code to place commands in a queue
It can be used by lavapipe and also by drivers for GPUs with command
streams that require values related to the framebuffer, thus the command
stream emission for secondary buffers needs to be deferred until the
framebuffer is known (execution time).

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Antonio Caggiano <antonio.caggiano@collabora.com>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12369>
2021-09-01 01:05:22 +00:00
Tomeu Vizoso 925a8fac17 vulkan: Read len attribute of parameters to functions
It will be needed for generating code that needs to know the size of
arrays.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Antonio Caggiano <antonio.caggiano@collabora.com>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12369>
2021-09-01 01:05:22 +00:00
Samuel Pitoiset d465095fc0 vulkan: Update the XML and headers to 1.2.190
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12611>
2021-08-30 18:39:20 +00:00
Dave Airlie a069b4e9b9 vulkan/wsi/sw: add mit-shm support for pixmap allocation
This allocate the mit-shm pixmap instead of dri3 pixmaps and
uses the present paths when mit-shm is enabled

Acked-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12482>
2021-08-29 20:26:13 +00:00
Dave Airlie 1f55f9a97a vulkan/wsi/sw: add support for using host_ptr for shm pixmaps.
This pipes the allocation of the MIT-SHM pixmap into the wsi common
code to callback to the x11 path to allocate things in the right place.

Acked-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12482>
2021-08-29 20:26:13 +00:00
Dave Airlie b5c390c113 vulkan/wsi: add support for detecting mit-shm pixmaps.
This just adds the xcb bits to detect is the host supports shared
shm pixmaps or whether the old paths should be used.

shm pixmaps will only be used if dri3 is available

Acked-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12482>
2021-08-29 20:26:13 +00:00
Dave Airlie 0cddfba328 vulkan/wsi/sw: wait for image fence before submitting to queue
With hw devices, when you submit a present, implicit sync will
make sure the work submitted to the gpu on the client will end
up happening before the present work submitted on the server.

However with sw paths there is no real GPU, the lavapipe fake
GPU thread is client side only and presenting is done directly
from the pixmap (or later shared pixmap). In order for this to
make sense the wsi common code should wait for the fence on the
image before queueing the submit to the server so that all
client works has been flushed to the pixmap before the copy or
present operation is submitted.

Fixes: 8004fa9c95 ("vulkan/wsi: add sw support. (v2)")
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12502>
2021-08-24 03:30:17 +10:00
Leandro Ribeiro 8107f67171 vulkan/wsi/wayland: memset members of image to zero
struct wsi_wl_image is only used as member of the swapchain, and during
the swapchain creation the image is already initialized to zero. So we
have no problems with members of the image being used uninitialized.

But for consistency, memset the members of this struct to zero in
wsi_wl_image_init(). This can help to avoid problems in the future.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12451>
2021-08-20 18:51:36 +00:00
Leandro Ribeiro 4cd187e71e vulkan/wsi/wayland: create swapchain using vk_zalloc()
In wsi_wl_surface_create_swapchain() we have a piece of code to init
some members of the chain to 0, in order to allow us to call
wsi_wl_swapchain_destroy() for cleanup.

Instead, we can use vk_zalloc() to allocate the chain, as it initializes
all members of the struct to zero. This help us to avoid problems when
people add new members to the struct and forget to initialize them.
Also, it makes the code look better.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12451>
2021-08-20 18:51:36 +00:00
Jason Ekstrand 3ed4ddf076 anv,vulkan: Add a vk_image::wsi_legacy_scanout bit
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12023>
2021-08-17 21:29:35 +00:00
Jason Ekstrand def2cb9808 anv,vulkan: Move drm_format_mod to vk_image
Even though we can't really do the parsing on behalf of the driver (it's
too complicated), storing it in the vk_image lets us provide a common
implementation of vkGetImageDrmFormatModifierPropertiesEXT().  It'll
also be useful in the next few commits for swapchain images.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12023>
2021-08-17 21:29:35 +00:00
Jason Ekstrand 0f2afa0abc anv,vulkan: Move ANV image layout helpers to common code
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12023>
2021-08-17 21:29:35 +00:00
Jason Ekstrand 9cc004b3d0 vulkan: Add a vk_image_view struct
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12023>
2021-08-17 21:29:35 +00:00
Jason Ekstrand 48e8efd00e vulkan,radv: Move vk_format_depth/stencil_only to common code
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12023>
2021-08-17 21:29:35 +00:00
Jason Ekstrand c36ff60a52 vulkan: Refactor and better document vk_image_expand_aspect_mask
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12023>
2021-08-17 21:29:35 +00:00
Jason Ekstrand 83b4d4f17d anv,vulkan: Move VkImageSubresource* helpers from ANV
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12023>
2021-08-17 21:29:35 +00:00
Jason Ekstrand e45e4e3ba1 anv,vulkan: Move anv_image_expand_aspects to common code
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12023>
2021-08-17 21:29:35 +00:00
Jason Ekstrand 0e6c320a7d vulkan: Add a vk_image struct
Currently, this is optional for drivers to carry around but it scrapes
up most of VkImageCreateInfo for you and parses a couple of extension
structs.  We also add a few useful little helpers copied over from ANV.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12023>
2021-08-17 21:29:34 +00:00
Leandro Ribeiro d18f102275 vulkan/wsi/wayland: add helper function find_format()
There are some places in the code in which we search for a certain
format in the u_vector. This new function help us to avoid repetition.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12117>
2021-08-16 10:23:06 +02:00
Leandro Ribeiro cb3b4609c1 vulkan/wsi/wayland: always initialize format vector
In wsi_wl_display_init(), the format vector is initialized only when the
caller sets the function to query the formats/modifiers. But
wsi_wl_display_finish() always release the vector, no matter if it has
been initialized or not.

For now it just works because the u_vector_foreach() macro works when
the format vector is uninitialized, but it is a weird design to try to
release something that has not been initialized.

So in this patch we start to always initialize the format vector, even
when not querying formats/modifiers.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12117>
2021-08-16 10:22:50 +02:00
Simon Ser 151b65b211 vulkan/wsi/wayland: generalize modifier handling
Instead of having hard-coded lists of modifiers for argb8888 and
xrgb8888, store a list of modifiers alongside each VkFormat. To
achieve this goal, introduce a new struct wsi_wl_format that holds
both a VkFormat and a modifier list, and use it for the items in
the formats list.

This commit unlocks non-{A,X}RGB8888 formats, which were previously
always disabled for linux-dmabuf.

Signed-off-by: Simon Ser <contact@emersion.fr>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12117>
2021-08-16 10:22:48 +02:00
Leandro Ribeiro 7383827acc vulkan/wsi/wayland: fold wsi_wl_display_swrast and wsi_wl_display_dmabuf into parent
The two structs wsi_wl_display_swrast and wsi_wl_display_dmabuf have in
common the list of formats and the only difference between both is the
interface object.

As we know that only one of the arrays is populated (we never bind to
wl_shm and the dmabuf interface simultaneously), we can move the members
of these structs to wsi_wl_display and simplify the code.

This is based on previous work of Simon Ser <contact@emersion.fr>.

Signed-off-by: Simon Ser <contact@emersion.fr>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12117>
2021-08-16 10:22:39 +02:00
Leandro Ribeiro 1c9299eade vulkan/wsi/wayland: fix crash when force_bgra8_unorm_first is true
When force_bgra8_unorm_first is true, we access display->formats and
change the order of certain formats. The final result is BGRA8_UNORM
being the first in the format list, as some clients require this.

But we are trying to do this before before setting up display->formats,
so it should result in a crash. Fix this by changing the order of
things. Now we first set up display->formats before trying to access it.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12117>
2021-08-16 10:22:35 +02:00
Leandro Ribeiro db2635020f vulkan/wsi/wayland: do not perform roundtrip when not querying formats
When we call wsi_wl_display_init() with get_format_list set to false
there's no need to dispatch the events from the interfaces. This allow
us to remove a check in the event handlers to verify if we're querying
the formats or not, what makes the code easier to read.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12117>
2021-08-16 10:22:28 +02:00
Leandro Ribeiro 4bf011a768 vulkan/wsi/wayland: check directly if we got globals successfully
Until now we had a weird way to bail out if we could not get any
globals. Instead, add a direct check, what makes the code easier to
read.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12117>
2021-08-16 10:22:20 +02:00
Simon Ser e090316570 vulkan/wsi/wayland: drop support for wl_drm
Nowadays, all Wayland compositors implement linux-dmabuf. We
shouldn't need to support the legacy wl_drm interface anymore.

Signed-off-by: Simon Ser <contact@emersion.fr>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12117>
2021-08-16 10:22:17 +02:00
Simon Ser 9990a351e8 vulkan/wsi/wayland: use drm_fourcc.h for formats
drm_fourcc.h is the canonical source for DRM formats. Instead of
using the values from wl_drm, use the canonical header.

Signed-off-by: Simon Ser <contact@emersion.fr>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12117>
2021-08-16 10:21:38 +02:00
Eric Engestrom 4d9acfa533 python: drop explicit output_encoding='utf-8' in mako templates
Python 3 handles unicode strings by default, so we can drop all that.

Suggested-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3674>
2021-08-14 21:44:32 +00:00
Eric Engestrom f1eae2f8bb python: drop python2 support
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Acked-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3674>
2021-08-14 21:44:32 +00:00
Pavel Asyutchenko 4374e7fb45 vulkan/overlay: Fix violation of VUID-VkMappedMemoryRange-size-01389
Mapping lentgh must be a multiple of 'nonCoherentAtomSize' bytes
when using VK_WHOLE_SIZE in vkFlushMappedMemoryRanges.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12131>
2021-07-30 11:38:40 +00:00
Alejandro Piñeiro 476dc3c050 vulkan: add vk_spec_info_to_nir_spirv util method
All vulkan drivers have been copying anv's code to convert
VkSpecializationInfo into nir_spirv_specialization.

Recently there was a Vulkan spec change on allowed values for
VkSpecializationInfo, and all drivers got affected.

This commits creates a new helper, and uses it on all Vulkan Mesa
drivers.

v2: use (uint8_t*) castings, instead of void*, to avoid C2036 with
    MSVC (detected by the CI, inspired on what radv was doing)

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12047>
2021-07-29 03:28:52 +00:00
Chia-I Wu 206fe780d5 vulkan/wsi/x11: do not inherit last_present_mode
Under XWayland, the first present after a window resize is sometimes
completed with COPY (seems to happen when the previous present with the
old size is pending; not really sure).  The following presents are
completed with FLIP.

When a swapchain is created with an old swapchain, and
old_chain->last_present_mode is FLIP, chain->last_present_mode is set to
FLIP as well.  This causes the new swapchain to be marked
VK_SUBOPTIMAL_KHR, which is sticky, if the first present is completed
with COPY.

Instead of inheriting, treat each swapchain as independent.  We will
miss the case where an old swapchain is flipping but a new swapchain is
copying.  But swapchain reallocation normally happens in response to
present engine state change.  If the newly allocated swapchain is
copying, another reallocation is unlikely to fix that.

Fixes: 61309c2a72 ("vulkan/wsi/x11: Return VK_SUBOPTIMAL_KHR for X11")
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12030>
2021-07-28 01:05:50 +00:00
Shmerl 8aa6002943 vulkan/overlay: don't display histogram and range for device and format
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4320
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12056>
2021-07-25 21:29:31 +00:00
Chia-I Wu bd9550b026 vulkan/wsi: replace prime_blit_buffer by a bool
venus only needs to know if a WSI image is a prime blit source.  In an
upcoming swapchain image rework, the prime blit destination is unknown
when the WSI image is created.  Replace prime_blit_buffer by a bool.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12046>
2021-07-23 15:31:20 -07:00
Caio Marcelo de Oliveira Filho a3e53495a9 vulkan: Update XML and headers to 1.2.185
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11981>
2021-07-21 20:15:21 +00:00
Dave Airlie 75aa8524ec wl/shm: don't fetch formats if not requested.
This aligns the code with the drm format code

Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11945>
2021-07-20 05:03:04 +10:00
Caio Marcelo de Oliveira Filho 34aae6a1f2 vulkan/util: Add and use vk_multialloc_zalloc variants
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11890>
2021-07-15 21:34:53 +00:00
Daniel Stone 49a7c92793 vulkan/wsi/wayland: Initialise wl_shm pointer in VkImage
We don't explicitly calloc the wsi_wl_image to zero; anything that's
expected to be valid needs to be explicitly initialised.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5063
Fixes: 6b36f35734 ("vulkan/wsi/wl: add wl_shm support for lavapipe.")
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Tested-by: Jan Beich <jbeich@freebsd.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11909>
2021-07-15 21:57:30 +01:00
Daniel Stone 1061ebb6da vulkan/wsi/wayland: Cosmetic alignment fix
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11909>
2021-07-15 21:57:29 +01:00
Erik Faye-Lund e3542b35a8 vulkan: allocate host-visible memory for swapchain images
The Vulkan 1.2 specification, section 11.2.12 ("Host Access to Device
Memory Objects") say the following:

> memory must have been created with a memory type that reports
> VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT

Since there's no guarantee that there's any memory that is *both*
device-local *and* host-visible, let's just use the latter requirement.

Fixes: 8af568e4ae ("vulkan: implement wsi_win32 backend")
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11848>
2021-07-14 07:09:38 +00:00
Erik Faye-Lund d0c7a2106b vulkan: do not map zero-sized region of memory
The Vulkan 1.2 specification, section 11.2.12 ("Host Access to Device
Memory Objects") say the following:

> If size is not equal to VK_WHOLE_SIZE, size must be greater than 0

So, mapping a zero-sized range is illegal. Let's instead map the
reported size of the image, which we already know.

Fixes: 8af568e4ae ("vulkan: implement wsi_win32 backend")
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11848>
2021-07-14 07:09:38 +00:00
Dave Airlie 6b36f35734 vulkan/wsi/wl: add wl_shm support for lavapipe.
This adds swrast support for rendering from lavapipe.

Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11819>
2021-07-12 20:27:48 +00:00
Georg Lehmann d8c1bf4a7d vulkan/wsi/wayland: Add support for more SRGB formats.
This is required by the Vulkan specification:

If pSurfaceFormats includes an entry whose value for colorSpace is
VK_COLOR_SPACE_SRGB_NONLINEAR_KHR and whose value for format is a UNORM
(or SRGB) format and the corresponding SRGB (or UNORM) format is a color
renderable format for VK_IMAGE_TILING_OPTIMAL, then pSurfaceFormats must also
contain an entry with the same value for colorSpace and format equal to the
corresponding SRGB (or UNORM) format.

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11778>
2021-07-09 11:54:43 +00:00
Jason Ekstrand d4b482d378 android: Drop the Android.mk build system
Android.mk files haven't really been supported by Mesa devs for a long
time.  Most of us have been willing to update Makefile.sources if we
remember and sometimes we try to blind code some Android.mk for a new
generator.  However, the reality is that it breaks regularly and ends up
being maintained by the Android community.  To address this problem
another approach was implemented in !10183 utilizing the maintained
meson build system.  The old Android.mk files are no longer required.

This commit was created with the following commands:

    git rm **/Android.mk
    git rm **/Android.*.mk
    git rm **/Makefile.sources
    git rm CleanSpec.mk

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4487
Acked-by: Roman Stratiienko <r.stratiienko@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9728>
2021-07-08 14:44:02 -05:00
Chia-I Wu a8173a78a3 vulkan/wsi: fix select_memory_type when all MTs are local
The intention is to pick the system memory for the prime blit dst, but
that is not possible when all memory types are advertised to be local.

This fixes venus over vtest (i.e., unix socket) because the driver
provides no PCI bus info and wsi_device_matches_drm_fd returns false.  A
driver might also use can_present_on_device to force prime blit.

Fixes: 469875596a ("vulkan/wsi: Fix prime blits to use system memory for the destination")

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11774>
2021-07-08 17:08:46 +00:00
Simon Ser 3ee30d98ff vulkan/wsi/wayland: handle dmabuf params allocation failure
Return VK_ERROR_OUT_OF_HOST_MEMORY if
zwp_linux_dmabuf_v1_create_params fails.

Signed-off-by: Simon Ser <contact@emersion.fr>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11589>
2021-07-08 12:05:28 +02:00
Simon Ser 7d711a10aa vulkan/wsi/wayland: fix wsi_wl_image_init error code
If image->buffer cannot be allocated, the value returned by
wsi_create_native_image is returned. However, if we got that far,
that value is VK_SUCCESS.

Fix it and return VK_ERROR_OUT_OF_HOST_MEMORY.

Signed-off-by: Simon Ser <contact@emersion.fr>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11589>
2021-07-08 12:05:25 +02:00
Simon Ser c45a1de5c6 vulkan/wsi/wayland: remove unnecessary wl_proxy_set_queue call
A wl_proxy inherits its queue from its parent.
display->dmabuf.wl_dmabuf already has its queue correctly set up,
so it's unnecessary to set it again on the child
zwp_linux_buffer_params_v1 proxy.

Signed-off-by: Simon Ser <contact@emersion.fr>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11589>
2021-07-08 12:05:20 +02:00
Simon Ser 589ea55732 vulkan/wsi/wayland: remove swapchain wl_drm wrapper
The sole purpose of this wl_proxy is to set the queue to
chain->display->queue. However, wl_proxy inherit their queue from
their parent, so the original wl_drm proxy already has its queue
set up properly (inherited from wl_registry).

Signed-off-by: Simon Ser <contact@emersion.fr>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11589>
2021-07-08 12:05:09 +02:00
Kenneth Graunke 469875596a vulkan/wsi: Fix prime blits to use system memory for the destination
The intention here was to pass VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT to
select_memory_types() when requesting device local memory, or simply
pass 0 for the prime blit destination which should be in system memory.

Unfortunately, that meant we did (type.propertyFlags & 0) == 0 which
was vacuously true, causing us to not filter out device local types.

Fixes hybrid display of Vulkan apps on Intel TGL+DG1 systems.

Tested-by: Luis Felipe Strano Moraes <luis.strano@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11680>
2021-07-02 23:35:57 +00:00
Luis Felipe Strano Moraes daf3d9e1eb overlay_layer: add missing undef
reviewed-by: Dylan Baker <dylan@pnwbakers.com>

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11673>
2021-07-01 16:42:07 +00:00
Simon Ser fc667fdf3b vulkan/wsi: prefer the Wayland linux-dmabuf protocol
When the linux-dmabuf protocol is available, prefer it over the old
wl_drm protocol. Previously wl_drm was used when modifiers aren't
supported, however linux-dmabuf supports formats without modifiers too.
In this case, linux-dmabuf will send a DRM_FORMAT_MOD_INVALID modifier
for each supported format [1].

All of this allows compositors to better handle these buffers, getting a
DMA-BUF and implementing features like direct scan-out.

A similar logic has been implemented for EGL [2].

In this patch, we bind to linux-dmabuf even if the driver doesn't support
modifiers. In this case the formats advertised by the compositor will
still be added to the display->dmabuf.formats list.

In wsi_wl_image_init, drop the assertions that display->drm_wrapper and
display->dmabuf.wl_dmabuf can't be both present. If the driver doesn't
support modifiers, the modifier is already set to DRM_FORMAT_MOD_INVALID.
If the parent compositor doesn't support modifiers, the modifiers list
passed to wsi_create_native_image will be empty, and the common code
will ensure that the image's modifier is set to DRM_FORMAT_MOD_INVALID.

In wsi_wl_surface_create_swapchain, create the wl_proxy proxy if we've
bound to it earlier. Don't decide to create the proxy depending on the
number of supported modifiers.

[1]: fb9b2a8731
[2]: c376865f5e

Signed-off-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4942>
2021-06-30 04:48:19 +00:00
Simon Ser 14f0c0d9db vulkan/wsi: unify format logic in dmabuf_handle_modifier
This function has a switch which currently duplicates the format
handling logic.

Move this logic out of the switch.

This avoids repeating the same code for each supported format and
prepares the work for proper DRM_FORMAT_MOD_INVALID handling.

Signed-off-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4942>
2021-06-30 04:48:19 +00:00
Matt Turner ed77bf3c4e ci: Unify on MESA_VK_IGNORE_CONFORMANCE_WARNING
Move and rename warn_non_conformant_implementation() to common location
of src/vulkan/util/vk_util.c as vk_warn_non_conformant_implementation().

In freedreno/ci,  move MESA_VK_IGNORE_CONFORMANCE_WARNING to common
location of .baremetal-deqp-test-freedreno-vk.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11563>
2021-06-25 19:45:38 +00:00
Niklas Haas 83f8b19f9b vulkan/wsi/wayland: implement the full format table
This code was written but (rightfully) commented out, because it
referenced non-existing vulkan formats.

The correct vulkan analogs come in the form _PACK16 and _PACK32,
respectively, which have their component ordering in high->low bit
order. This is compatible with the DRM format ordering on little endian
systems, so we can just implement them all in the obvious way. On big
endian systems, the _PACKN formats have no analogs, because the
corresponding DRM formats are specified as always being little endian.

I implemented all of the formats I could, while excluding those that
don't map to vulkan at all (e.g. BGRA1010102), and commenting out the
ones that require an extra extension (e.g. ARGB4444) because they
probably need to be checked for extension presence first.

List slightly re-ordered to make it more neatly organized. Tested
working with the 2101010 and 565 variants. Was not able to test the 4444
or 1555 formats, but I verified the channel order was correct so they
should be working in theory.

Signed-off-by: Niklas Haas <git@haasn.xyz>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9737>
2021-06-24 19:37:51 +00:00
Simon Zeni f9944899a7 vulkan/wsi: Implement VK_EXT_acquire_drm_display
Implements the two functions defined in the extension
VK_EXT_acquire_drm_display, vkAcquireDrmDisplayEXT and vkGetDrmDisplayEXT.

Signed-off-by: Simon Zeni <simon@bl4ckb0ne.ca>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11014>
2021-06-24 15:48:38 +00:00
Simon Zeni fdf22aad73 vulkan/wsi: add drm_fd param to wsi_display_get_connector
Modifies the signature on `wsi_display_get_connector` to retrieve the
connector of an arbitrary DRM FD instead of the one taken from the
wsi_display.

Signed-off-by: Simon Zeni <simon@bl4ckb0ne.ca>
Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11014>
2021-06-24 15:48:38 +00:00
Mike Blumenkrantz 6d0aceae4d vk/util: add macros for multidraw
this simplifies implementations since a lot of the code is going to be
copy/pasted around, enabling related tweaks to be made in a centralized place

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11496>
2021-06-22 15:53:03 +00:00
Simon Ser 7369b1a21e vulkan/wsi/wayland: simplify wl_surface version check
No need to cast to a wl_proxy, there is a wl_surface variant
available.

No need to cache the result of get_version(), this is just a
one-line getter and doesn't perform any roundtrip.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11420>
2021-06-21 20:01:28 +00:00
Jason Ekstrand 69d4fa3a1c vulkan: Update the XML and headers to 1.2.182
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11497>
2021-06-21 14:29:16 +00:00
Michel Zou f9a69cbcd4 zink: Fix win32 build
Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11338>
2021-06-14 19:48:36 +00:00
Georg Lehmann 00084669ae vulkan: Update the XML and headers to 1.2.180
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11215>
2021-06-09 08:25:25 +00:00
Chia-I Wu d3acc73455 vulkan/util: add vk_default_allocator
We cannot use os_{malloc,free,realloc}_aligned because
os_realloc_aligned needs the old size (for memcpy).

v2: no max_align_t on MSVC

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11117>
2021-06-03 08:13:26 +00:00
Chia-I Wu 447e80ac9b vulkan/wsi: provide more info in wsi_image_create_info
Always chain wsi_image_create_info to VkImageCreateInfo, which indicates
that the image is a wsi image and can be transitioned to/from
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.

Add prime_blit_buffer to the struct as well.  When set, it indicates the
prime blit destination and implies that the image is a prime blit
source.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10789>
2021-06-03 04:24:55 +00:00
Hoe Hao Cheng 17d7b0bb8f vulkan/util: generate vk_dispatch_table that combines all dispatch tables
Zink uses this, as it doesn't need to differentiate all the entrypoints.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11045>
2021-05-30 01:57:49 +00:00
Emma Anholt 307139c7f9 vulkan: Avoid stomping array padding in the MemoryProperties wrapper.
The deqp test for it expects that the unused array elements are untouched,
so make sure they don't get replaced with random stack data.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10737>
2021-05-20 21:41:06 +00:00
James Park fb7be7870c vulkan: Support 32-bit "weak" symbols on MSVC
MSVC uses different decorated names for 32-bit versus 64-bit. Declare
all argument sizes for 32-bit because computing the actual size would be
difficult.

Fixes: 9be7aa3fc8 ("vulkan: Add a common entrypoint table generator")
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10573>
2021-05-16 23:05:24 +00:00
Erik Kurzinger f4eb13dc55 vulkan/device_select: avoid segfault on Wayland if wl_drm is unavailable
On Wayland, if the wl_drm interface is not available, for example if the
compositor is using the proprietary NVIDIA driver along with their egl-wayland
library, the device_select layer will fail to initialize. However, the failure
path will unconditionally call wl_drm_destroy even though info.wl_drm would be
NULL in that case. This can cause a segfault in libwayland-client.so.

To fix this, check if info.wl_drm is NULL before calling wl_drm_destroy. This
way, initialization will fail gracefully even if that interface is not present.

Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10598>
2021-05-04 21:26:21 +00:00
Michel Zou ff58ea7d91 vulkan/wsi: avoid wsi_x11_check_for_dri3 for sw device
Disabling the check allows swapchains to be created on a remote
X Server using the xlib backend, which in turn allows Vulkan apps,
such as swapchain_images in Vulkan Samples, to run.

Closes #4323

Reviewed-by: Adam Jackson <ajax@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10349>
2021-05-03 13:33:08 +00:00
Dylan Baker f03da01fe3 meson/vulkan: fix linkage on windows
The current approach likley breaks icl and clang-cl, but it seems that
the problem isn't even really related to MSVC, but to Meson's Visual
Studio backend, as such, let's use link-whole unless we're using a
Visual Studio backend.

Fixes: 48d31a6280
       ("meson: link vulkan_util with link_whole on mingw")

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Acked-by: James Park <jpark37@lagfreegames.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10506>
2021-04-30 18:49:20 +00:00
Rhys Perry 32ebbd8c23 vulkan: fix use-after-free in vk_common_DestroyDebugReportCallbackEXT
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Fixes: bd1705a480 ("vulkan: Make vk_debug_report_callback derive from vk_object_base")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10433>
2021-04-29 14:06:49 +00:00
Lionel Landwerlin 6b61fbca8b vulkan/wsi/display: don't report support if there is no drm fd
This partially deals with
https://gitlab.freedesktop.org/mesa/mesa/-/issues/4688

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10430>
2021-04-27 21:04:25 +00:00
Niklas Haas 0245b82570 vulkan/wsi/x11: lower resize events to VK_SUBOPTIMAL_KHR
Currently, a resized window results in an VK_ERROR_OUT_OF_DATE_KHR. But,
this seems to go against the spec, which suggests returning
VK_SUBOPTIMAL_KHR if the surface extent no longer matches the window
extent. (It does not *require* the WSI actually scale the contents, only
encourages doing so "if possible")

More to the point, VK_SUBOPTIMAL_KHR is the correct status to return if
the client *can* continue presenting to this swapchain, even if the
result will look wrong / "suboptimal". It's the client's decision on
when exactly to recreate the swapchain in this case, and the client may
very well end up wanting to continue presenting for a frame or two, to
prevent flooding the driver with swapchain recreations (which can result
in the window appearing visually "frozen" while resizing).

This change makes live resizing *significantly* smoother in e.g. mpv.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3196>
2021-04-27 19:42:00 +00:00
Niklas Haas 4a1f230e35 vulkan/wsi/x11: return VK_SUBOPTIMAL_KHR on mismatched swapchain
If the swapchain already does not match the current geometry at the time
of creation, set the initial status to VK_SUBOPTIMAL_KHR as a way to
inform clients to please resize the swapchain.

This solves a race condition where users have no way of knowing if the
surface extent changed in between the user querying the current extent
and creating the swapchain, and might end up missing a resize event
because of it, since XCB_PRESENT_CONFIGURE_NOTIFY is not yet being
handled.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3196>
2021-04-27 19:42:00 +00:00
Iago Toral Quiroga 0c0c1418ae vulkan/wsi: give drivers the option to decide if they need to blit
Until now, the WSI code would rely on VK_EXT_pci_bus_info to check if the
WSI device matched the DRM device used for display. If they matched, then
it would allow direct presentation of the swapchain images, otherwise
it would fallback to a blit path through a linear buffer.

Unfortunately, this only works for PCI devices, so embedded GPUs would
always fail the test and fallback to the prime blit path, incurring in a
performance penalty due to the extra blit.

With this change driver backends have the possibility to attach a
callback to the WSI device to take control over that decision and have
freedom to make that choice according to their own platform particularities.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5917>
2021-04-27 06:37:43 +00:00
Keith Packard a60767ec26 vulkan/x11: Mark present complete using serial instead of MSC
Present operations do not necessarily complete after the requested
time; if the CRTC has been blanked, they will complete
immediately. This means we cannot use the MSC value to tell when a
present has finished.

Instead of using MSC, track whether each present is complete by serial
number, which is the low 32-bits of the SBC value. This value is
provided in the present_pixmap request and returned in the present
complete notify event.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2021-04-26 11:55:46 -07:00
Jason Ekstrand d5ee5f6104 vulkan: Update the XML and headers to 1.2.177
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10460>
2021-04-26 15:13:19 +00:00
Lionel Landwerlin 2b49d5d193 vulkan: bump headers/registry to version 1.2.175
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10206>
2021-04-22 15:34:52 +00:00
Michel Zou 48d31a6280 meson: link vulkan_util with link_whole on mingw
It was missing for mingw.

Closes #4633

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: James Park <jpark37@lagfreegames.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10276>
2021-04-19 22:46:30 +00:00
Michel Zou dc036b1769 vulkan: fix duplicate win32 def
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10276>
2021-04-19 22:46:30 +00:00
Lionel Landwerlin f90d625841 vulkan/util: cast enums to int64_t in switch
With the new Vulkan Video extensions a bunch of enum values have been
added. The problem is that those are behind #ifdef so our generated
code complains that we using enum values not defined.

Since we're not using enum names but integer values, we can silence
all those by casting the enum type to int64_t.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10304>
2021-04-19 06:14:11 +00:00
Michel Dänzer 2928c21eb7 Convert most remaining free-form fall-through comments to FALLTHROUGH
One exception is src/amd/addrlib/, for which -Wimplicit-fallthrough is
explicitly disabled.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10220>
2021-04-15 16:01:22 +00:00
James Park d32512effc vulkan/util: Use util_bitcount
__builtin_popcount is not available on all compilers.

Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10159>
2021-04-12 03:25:59 +00:00
Jason Ekstrand 22478bb0e4 vulkan: Add a vk_object_multialloc helper
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10123>
2021-04-10 02:18:02 +00:00
Chad Versace 5e6db19168 anv: Remove vkCreateDmaBufINTEL (v4)
Superceded by VK_EXT_image_drm_format_modifier.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> (v1)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> (v4)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/1466>
2021-04-08 14:15:55 +00:00
Chad Versace 0845cabc72 vulkan: Track dependencies of Python imports
The meson.build was unaware of transitive dependencies introduced by
Python imports.

Android still needs fixing. But I did not update the Android files lest
I break the build.

Ideally, we would fix this by using a Python runner that generates
a depfile, similar to how meson creates depfiles for C files by passing
flags -MD -MQ -MF to gcc. But this patch gets the job done, without
stalling on the ideal general solution, by manually tracking the Python
imports in new 'foo_depend_files' variables.

CC: mesa-stable@lists.freedesktop.org
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/1466>
2021-04-08 14:15:54 +00:00
Michel Dänzer 8ec530d982 wsi/x11: Wait for fences with IMMEDIATE on Xwayland
The commit below was already meant to do this, but accidentally missed
this part.

Fixes stutter when the frame-rate drops below the refresh rate.

Fixes: e8f50bd600 "wsi/x11: Treat IMMEDIATE present mode the same as
                     MAILBOX for Xwayland"

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10026>
2021-04-07 13:20:20 +00:00
Mauro Rossi 1b3a0f8829 vulkan/util: Fix implicit declaration of ffs for Android build
Similar to 641320ce02 and 68bb26af63 to avoid Android build errors

Fixes the following building error:

In file included from external/mesa/src/vulkan/util/vk_util.c:28:
external/mesa/src/vulkan/util/vk_util.h:248:30: error: implicit declaration of function 'ffs' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
   return (gl_shader_stage) (ffs((uint32_t) vk_stage) - 1);
                             ^
1 error generated.

Fixes: 06ebbde630 ("vulkan: Deduplicate mesa stage conversion")
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10023>
2021-04-04 17:04:04 +02:00
Alyssa Rosenzweig 06ebbde630 vulkan: Deduplicate mesa stage conversion
Across every driver...

v2: Add casts to appease -fpermissive used on CI.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9477>
2021-04-03 17:34:39 +00:00
Keith Packard 8c7940cc0f wsi/x11: Fix type of target_msc argument to x11_present_to_x11_dri3
Broken out of VK_GOOGLE_display_timing patch

Cc: stable
Co-author: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9939>
2021-04-01 17:39:47 +00:00
Bas Nieuwenhuizen 83c92a48b7 vulkan: Fix descriptor set creation with zero bindings.
MAX2(count * struct size, 1) results in 1 for count=0, not the size of a struct.

Since this MAX only seems to exist so we can keep using NULL for error reporting,
just refactor to return a VkResult.

Fixes: ad241b15a9 ("vk: consolidate dynamic descriptor binding sorting")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4522
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9880>
2021-03-29 23:32:50 +00:00
Lionel Landwerlin 54fe5b0482 meson: switch vulkan layer to list of choices
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2832>
2021-03-25 19:10:03 +00:00
Samuel Pitoiset 0ce6b625a2 vulkan: add common entrypoints for VK_KHR_create_renderpass2
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9601>
2021-03-24 11:21:53 +00:00
Mauro Rossi cd1d8b4371 android: vulkan/util: add vk_descriptors.{c,h} to Makefile.sources
Fixes the following building errors:

FAILED: out/target/product/x86_64/obj/SHARED_LIBRARIES/vulkan.radv_intermediates/LINKED/vulkan.radv.so
...
ld.lld: error: undefined symbol: vk_create_sorted_bindings
>>> referenced by radv_descriptor_set.c:158 (external/mesa/src/amd/vulkan/radv_descriptor_set.c:158)
...
ld.lld: error: undefined symbol: vk_create_sorted_bindings
>>> referenced by radv_descriptor_set.c:340 (external/mesa/src/amd/vulkan/radv_descriptor_set.c:340)

Fixes: ad241b15a9 ("vk: consolidate dynamic descriptor binding sorting")
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9766>
2021-03-23 20:29:55 +01:00
Mike Blumenkrantz ad241b15a9 vk: consolidate dynamic descriptor binding sorting
this code was duplicated across several drivers

Reviewed-by: Adam Jackson <ajax@redhat.com>
turnip changes Reviewed-by: Hyunjun Ko <zzoon@igalia.com>

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9480>
2021-03-22 16:51:55 +00:00
Iago Toral Quiroga 1e4abf1fe3 vulkan/util: call glsl_type_singleton_init_or_ref from vk_instance_init
v2: link libvulkan_util with libglsl so it can find the glsl singleton symbols.
v3: link with libcompiler instead of libglsl (Jason)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Dylan Baker <dylan.c.baker@intel.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> for the v3dv bits.
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com> for the turnip bits.
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> for the radv bits.
Acked-by: Dave Airlie <airlied@redhat.com> for the lvp bits.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9457>
2021-03-17 08:15:36 +01:00
Samuel Pitoiset 7c68a2518f vulkan: add missing vk_shader_module.c/h includes to Makefile
Fixes: 76078ed9fe ("vk/util: add unified shader module struct/functions")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9620>
2021-03-16 16:01:10 +01:00
Mike Blumenkrantz a41e98ddca vk/util: add a util macro for initializing stack vk_shader_module structs
radv does a lot of this, so having a central dispatch point will be useful in
case changes are made to this struct in the future

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9508>
2021-03-15 21:47:44 +00:00
Mike Blumenkrantz 76078ed9fe vk/util: add unified shader module struct/functions
there's some extra logging stuff dumped into here to match functionality,
eventually that should also be consolidated into vk_util.c

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9508>
2021-03-15 21:47:44 +00:00
Michel Zou 862671369d vulkan: fix CreateRenderPass prototype
Fixes compilation on win32

Fixes: 2523c477 " turnip: Move the CreateRenderPass wrapper..."
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9530>
2021-03-12 17:37:38 +00:00
Jason Ekstrand e7e297732e vulkan/alloc: Use char * for pointer arithmetic
MSVC doesn't like arithmetic on void *.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9511>
2021-03-10 20:59:59 -06:00
Jason Ekstrand 492b5577f0 vulkan/util: Add a type parameter to vk_multialloc_add
We also switch from using __alignof__ to alignof() in util/macros.h
which works on MSVC with the one unfortunate downside of requiring an
actual type and not a value.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9511>
2021-03-10 20:59:56 -06:00
Jason Ekstrand c120edd8e8 vulkan/alloc: Add VK_MULTIALLOC_DECL macros
These both declare the variable and add it to the allocator in one go.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9511>
2021-03-10 20:59:55 -06:00
Jason Ekstrand 5afdbfe0c8 vk/alloc: Handle zero sizes better in vk_multialloc_add
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9511>
2021-03-10 20:59:53 -06:00
Jason Ekstrand c22267262e vulkan: Use ALWAYS_INLINE for multialloc
This way it properly compiles on Visual Studio.

Fixes: 145444d265 "anv: Move multialloc to common code"
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9506>
2021-03-10 23:15:17 +00:00
Jason Ekstrand b302159b1c vulkan: Preserve preserve attachments in CreateRenderPass
This is trivial so I really don't know why it wasn't handled in the
initial turnip code.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8857>
2021-03-10 18:17:31 +00:00
Jason Ekstrand 147187f754 vulkan: Add some asserts and checks for multiview in CreateRenderPass
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8857>
2021-03-10 18:17:31 +00:00
Jason Ekstrand 5de355b0f9 vulkan: Use correct aspectMask in CreateRenderPass
If a VkRenderPassInputAttachmentAspectCreateInfo is provided, we use the
aspects specified there.  Otherwise, we default to every aspect in the
format.  For attachments which are not input attachments, aspectMask is
left zero.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8857>
2021-03-10 18:17:31 +00:00
Jason Ekstrand 4fb6c051c9 anv: Move vk_format helpers to common code
The Android ones we put in anv_android.c.  Maybe one day we'll want a
vk_android.h to put some common Android stuff but, for now, let's keep
it contained to ANV's android code.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8857>
2021-03-10 18:17:31 +00:00
Jason Ekstrand c7345bd1fb vulkan: Use VK_MULTIALLOC in CreateRenderPass
The variable-length stack allocations are causing issues with ubsan when
the array size is zero.  Also, a heap allocation is probably safer.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8857>
2021-03-10 18:17:31 +00:00
Jason Ekstrand 145444d265 anv: Move multialloc to common code
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8857>
2021-03-10 18:17:31 +00:00
Jason Ekstrand 2523c47720 turnip: Move the CreateRenderPass wrapper to common code
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8857>
2021-03-10 18:17:31 +00:00
Georg Lehmann fb1100d718 vulkan/device_select: Only call vkGetPhysicalDeviceProperties2 if the device supports it.
vkGetPhysicalDeviceProperties2 is not allowed to be used with a 1.0 device
because it's  a vulkan 1.1 function.

Closes: #4396
Fixes: 38ce8d4d ("vulkan/device_select: Stop using device properties 2.")
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9462>
2021-03-09 15:00:57 +00:00
James Park 98c622a96e vulkan: Update dispatch table gen for Windows
Update entry null test to deal with MSVC not supporting weak functions.

Also fix warnings for returning from void functions.

Acked-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9121>
2021-02-26 04:29:52 +10:00
James Park 10244fe76e vulkan: Fix source list for vulkan_wsi on Windows
I don't think link_whole works right for VS project generation, but MSVC
doesn't support GCC weak functions anyway, so work around it.

Acked-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9121>
2021-02-26 04:29:52 +10:00
Michel Zou 8af568e4ae vulkan: implement wsi_win32 backend
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7208>
2021-02-25 03:41:36 +00:00
James Park 9f30370654 vulkan: Use typed outarray API
MSVC cannot perform GCC __typeof__ for C code. (C++ has decltype.)

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9208>
2021-02-23 17:18:11 +10:00
Bas Nieuwenhuizen 38ce8d4d00 vulkan/device_select: Stop using device properties 2.
We have to choose between:
1) Stop handling two identical GPUs
2) Stop having crashes with other layers active.
3) Fix the Vulkan Loader.

Since nobody seems to want to spend enough effort to do 3 the
effective choice is between 1 and 2. This is choosing 2, as
two identical GPUs is pretty uncommon since crossfire doesn't
work on Linux anyway.

(And it would only work sporadically as the game needs to enable the
 extension)

CC: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3801
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8414>
2021-02-22 13:18:53 +00:00
Dave Airlie 5a340c0929 vulkan/util: add api to reset object magic + private data.
This will be used to for reissuing dispatchable objects like
command buffers.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9145>
2021-02-22 09:32:13 +10:00
Michel Zou 6ccbb89207 meson: invalid keyword argument dependencies
Fixes: e4cc52c0 (vulkan: Add common extension tables)
Reviewed-by: Dylan Baker <dylan.c.baker@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8821>
2021-02-16 11:35:32 +00:00
Lionel Landwerlin 3414d4fdc5 vulkan: document flags choice for vkGetDeviceQueue
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9053>
2021-02-15 21:01:28 +02:00
Michel Zou 664a803879 vulkan: Fix windows api conflict
It must be undefined in the header too

Fixes: e487ae1b
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8975>
2021-02-11 17:56:27 +00:00
Michel Zou e487ae1b99 vulkan: Fix windows api conflict
Closes #4247

Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8956>
2021-02-10 17:10:50 +00:00
Michel Zou 2ef3dca476 vulkan/lavapipe: add missing VKAPI_ATTR/CALL
Acked-by: Jose Fonseca <jfonsec@vmware.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8823>
2021-02-09 19:21:03 +00:00
Jason Ekstrand 2d6de5d227 anv,vulkan: Move anv_icd.py to a common location
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tested-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8792>
2021-02-04 20:02:12 +00:00
Jason Ekstrand cf54fc768e vulkan: Rework extension disabling on Android
Instead of building it into the auto-generated condition we use for the
per-driver ${driver}_physical_device_get_supported_extensions()
function, generate a table and handle it inside the various common
extension enumeration and verification routines.  This reduces our
reliance on code-gen for extension enables.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tested-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8792>
2021-02-04 20:02:12 +00:00
Jason Ekstrand 0260b4a7e7 vulkan: Add a common helper for enumerating instance extension properties
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tested-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8792>
2021-02-04 20:02:12 +00:00
Jason Ekstrand f2545f22f4 vulkan: Drop the type_prefix parameter from gen_extensions
Now that all the drivers are converted, it's set to 'vk' by everyone so
there's no point in having the parameter.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:25 +00:00
Jason Ekstrand bafd0c680d vulkan: Rework vk_device_init and friends
Now that all drivers are converted over, we can make a few changes.
First off, vk_device_init no longer takes two separate allocators
because we can assume that the parent instance is non-null and it can
pull the instance allocator from that.  Second, dispatch tables and the
instance extension table are no longer optional.  We leave the device
extension table optional for now because we don't do any verification at
vk_init_physical_device time and some drivers find it more convenient to
set the extensions later in their own physical_device_init for various
reasons.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:25 +00:00
Jason Ekstrand 3a7514ea09 anv,radv: Use common entrypoints for VK_KHR_deferred_operation
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:25 +00:00
Jason Ekstrand 23ba48a0c7 vulkan: Make the debug_report implementation internal
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:25 +00:00
Jason Ekstrand 41318a5819 vulkan: Use vk_object_base::type for debug_report
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:25 +00:00
Jason Ekstrand bd1705a480 vulkan: Make vk_debug_report_callback derive from vk_object_base
Fixes: 51c6bc13ce "anv,vulkan: Implement VK_EXT_private_data"
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:25 +00:00
Jason Ekstrand 3a8060271c turnip: Drop some legacy wrappers in favor of common code
Acked-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:24 +00:00
Jason Ekstrand eef79aab1c vulkan: Add a truly common VK_EXT_debug_report implementation
Now that we've got a common vk_instance, we can put the debug_report
stuff there and make it truly common.  For drivers to use this
implementation, they need to delete their own vk_debug_report_instance
and make sure everything references the common one.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:24 +00:00
Jason Ekstrand 06f877f6e6 vulkan,anv: Move VK_KHR_copy_commands2 wrappers to common code
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:24 +00:00
Jason Ekstrand ac6be0ef22 vulkan,anv: Move a bunch of trivial wrappers to common code
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:24 +00:00
Jason Ekstrand 3536bec0fa vulkan,anv: Add common entrypoints for VK_EXT_private_data
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:24 +00:00
Jason Ekstrand f8bc9a4e7a vulkan,anv: Move GetDeviceProcAddr to common code
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:24 +00:00
Jason Ekstrand 94d02e8dea vulkan: Add framework for common entrypoints
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:24 +00:00
Jason Ekstrand 9be7aa3fc8 vulkan: Add a common entrypoint table generator
This is based on the one in ANV but it's a bit different because it uses
vk_entrypoint_table instead of vk_dispatch_table.  This is because,
without knowing what extensions are implemented by a driver, we have to
generate a table with everything and sort it all out later.  We use the
same trick as ANV with weak function declarations to provide NULL values
for any entrypoints NOT implemented by the driver.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:24 +00:00
Jason Ekstrand 66cdc0c0db vulkan: Add common Get*ProcAddr implementations
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:24 +00:00
Jason Ekstrand 46ecbff39b vulkan: Add entrypoint tables and related helpers
Entrypoint tables are distinct from dispatch tables because they are not
de-duplicated.  These are needed to make codegen easier.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:24 +00:00
Jason Ekstrand eff07c0407 vulkan: Add generators for instance trampoline functions
ANV needs these because we have a different dispatch table for each
hardware generation and Vulkan requires that the device entrypoints
returned from vkGetInstanceProcAddr work regardless of which device
they're used with.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:24 +00:00
Jason Ekstrand d360a996f9 vulkan: Add common instance and physical device structs
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:24 +00:00
Jason Ekstrand 0f22fdad95 vulkan: Add dispatch table lookup helpers
These both look up a name by string and check to see if it's actually
supported given instance and possibly device extension tables.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
2021-02-01 18:54:24 +00:00