Commit Graph

986 Commits

Author SHA1 Message Date
Erik Faye-Lund b27a2ba4fc vulkan: explicitly cast object-type enum
VkObjectType and VkDebugReportObjectTypeEXT has the same enum-values.
Why the Vulkan WG thought this was a good idea, beats me. But it's what
we have to live with now.

Anyway, instead of having a statement that implicitly casts two
different values from the former to the latter, let's fully relsove the
type as the former, and cast the value when using it instead.

Fixes: 41318a5819 ("vulkan: Use vk_object_base::type for debug_report")
Acked-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15547>
2022-04-19 06:54:47 +00:00
Jason Ekstrand b284c512e6 vulkan/drm_syncobj: Implement WAIT_PENDING with a sync_file lookup
The v3dv kernel driver doesn't support timelines yet but we want
threaded submit and that requires WAIT_PENDING.  Fortunately, it should
never sit in this loop for long in practice.  The primary use-case is
sorting out dependencies and these checks will always trivially succeed
for non-shared semaphores because v3dv only has a single queue.

Acked-by: Alejandro Piñeiro <apinheiro@igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15704>
2022-04-13 17:22:14 +00:00
Boris Brezillon f0667be8b5 vulkan/util: Make STACK_ARRAY() C++-friendly
C++ doesn't like the {0} initializer pattern when the first
field is not an integer, let's use the {} when __cplusplus is
defined.

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15698>
2022-04-08 11:54:44 +00:00
Jason Ekstrand dd340ce1a1 vulkan,docs: Document vk_device
Acked-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15472>
2022-04-07 16:32:21 +00:00
Jason Ekstrand 6073610d7a vulkan,docs: Document vk_physical_device
Acked-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15472>
2022-04-07 16:32:21 +00:00
Jason Ekstrand f6d4641433 vulkan,docs: Document vk_instance
Acked-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15472>
2022-04-07 16:32:21 +00:00
Jason Ekstrand f06fa8f7e0 vulkan,docs: Document vk_object_base
Acked-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15472>
2022-04-07 16:32:21 +00:00
Jason Ekstrand 0ca8b95824 vulkan: vk_object_base_init/finish have no unused parameters
Acked-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15472>
2022-04-07 16:32:21 +00:00
Jason Ekstrand 2f6bca6a74 vulkan: Use timespec_add_nsec in vk_sync_timeline
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15651>
2022-04-06 00:38:22 +00:00
Mike Blumenkrantz 9a6ea51388 vulkan: check 3D image type for VK_IMAGE_CREATE_2D_VIEW_COMPATIBLE_BIT_EXT
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15754>
2022-04-05 20:30:31 +00:00
Mike Blumenkrantz b591409b6c vulkan: spec update to 1.3.211
Acked-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15752>
2022-04-05 12:55:21 +00:00
Benjamin Cheng 4489933842 vulkan/queue: Destroy wait temps if they are skipped
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6223
Fixes: 8a11d2a31b ("vulkan: Add a dummy sync type")
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15727>
2022-04-04 20:52:46 +00:00
Rajnesh Kanwal d5405c1608 vulkan: Move common format function to vulkan/util/vk_format.h
Moving duplicate vk_format helper functions to common
vulkan/util/vk_format.h and also renaming
vk_format_get_component_size_in_bits to match how amd and
freedreno name the same function. Not moving this function
to common code as freedreno's implementation is a bit different.

Signed-off-by: Rajnesh Kanwal <rajnesh.kanwal@imgtec.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15696>
2022-03-31 17:18:22 +00:00
Jason Ekstrand 51077e821a vulkan: Allow the driver to manually enable threaded submit
This is useful for drivers that wish to be able to block inside their
vk_queue::driver_submit hook.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15566>
2022-03-30 23:17:56 +00:00
Jason Ekstrand 08512aea09 vulkan: Replace various uses of device->timeline_mode
What we really care about is if we're DEFERRED so we need to do a flush
and if there can be any other threads we might race against.  We don't
really care about the timeline mode itself.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15566>
2022-03-30 23:17:56 +00:00
Jason Ekstrand 8e51778acf vulkan/queue: Rework vk_queue_submit()
Instead of basing everything on the timeline mode, base it on the submit
mode of the queue.  This makes a lot more sense since it's what we
really care about anyway.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15566>
2022-03-30 23:17:56 +00:00
Jason Ekstrand e0ffdc8ce0 vulkan/queue: Rework submit thread enabling
Now that we have a threading mode in the device, we can set that based
on the environment variable instead of delaying it to submit time.  This
allows us to avoid the static variable trickery we use to avoid reading
environment variables over and over again.  We also move the enabling of
the submit thread up a level or two and give it a bit more obvious
condition.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15566>
2022-03-30 23:17:56 +00:00
Jason Ekstrand 9ddab162b7 vulkan/queue: Add a submit mode enum
This encapsulates all three possible submit modes: immediate, deferred,
and threaded.  It's more clear than the has_thread boolean combined with
device-level checks.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15566>
2022-03-30 23:17:56 +00:00
Jason Ekstrand dc2c9bae25 vulkan: Add more VU comments to justify framebuffer asserts
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15674>
2022-03-30 20:43:12 +00:00
Mike Blumenkrantz 8c3b4dd996 vulkan: update spec to 1.3.210
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15635>
2022-03-29 07:59:23 -04:00
Jakob Bornecrantz 9e31991c6e vulkan-device-select: Don't leak xcb_query_extension_reply_t
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15600>
2022-03-28 11:06:11 +00:00
Adam Jackson 8006179cfd wsi/x11: xcb_wait_for_special_event failure is an error
The only ways that function can return NULL are:

- the xcb connection was closed
- the window for the swapchain was destroyed
- the special event listener was unregistered from another thread
- malloc failure

All of these are permanent errors, the swapchain is no longer in a
usable state, so we should treat this as VK_ERROR_SURFACE_LOST_KHR.

Acked-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15558>
2022-03-25 19:31:13 +00:00
Boris Brezillon 7e0ab29cfd vulkan/util: Make STACK_ARRAY() work for arrays of pointers
And add an explicit cast on the pointer returned by malloc() to
make C++ happy.

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14766>
2022-03-25 16:21:45 +00:00
Boris Brezillon bb1fb07ecd vulkan/image: Make MSVC C++ compiler happy
Fix 'error C4576: a parenthesized type followed by an initializer
list is a non-standard explicit type conversion syntax' errors by
declaring an actual variable and returning it in
vk_image_view_subresource_range().

All those MSVC/c++ related-constraints are quite annoying to be honest,
but it looks like the D3D12 headers have been updated to plain C
recently, which will allow us to write the driver in C, and hopefully
get all this sort of issues behind us.

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14766>
2022-03-25 16:21:45 +00:00
Boris Brezillon b000abbe7f vulkan/util: Get rid of VK_OUTARRAY_MAKE()
Get rid of VK_OUTARRAY_MAKE() so people don't get tempted to
use it and produce code that doesn't compile with MSVC, which
doesn't support typeof().

Suggested-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15522>
2022-03-25 11:00:03 +00:00
Boris Brezillon 5f309da5e4 vulkan/wsi: Stop using VK_OUTARRAY_MAKE()
We're trying to replace VK_OUTARRAY_MAKE() by VK_OUTARRAY_MAKE_TYPED()
so people don't get tempted to use it and make things incompatible with
MSVC (which doesn't support typeof()).

Suggested-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15522>
2022-03-25 11:00:03 +00:00
Boris Brezillon 52a2aa44f3 vulkan/device_select: Stop using VK_OUTARRAY_MAKE()
We're trying to replace VK_OUTARRAY_MAKE() by VK_OUTARRAY_MAKE_TYPED()
so people don't get tempted to use it and make things incompatible with
MSVC (which doesn't support typeof()).

Suggested-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15522>
2022-03-25 11:00:03 +00:00
Jason Ekstrand e500faebc2 vulkan: Add a vk_image_view_subresource_range helper
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15535>
2022-03-24 21:21:10 +00:00
Boris Brezillon 5b12a498f5 vulkan/runtime: Add vk_cmd_queue.h to idep_vulkan_runtime_headers
If we don't do that, meson might start compiling source files
including vk_command_buffer.h which in turn includes vk_cmd_queue.h
before this file is even generated, and we end up with errors like
that https://gitlab.freedesktop.org/mesa/mesa/-/jobs/20157936#L1119.

Fixes: 6bd8a3c7e4 ("vulkan/runtime: Add a vk_cmd_queue object to vk_command_buffer")
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15546>
2022-03-24 19:43:02 +00:00
Lionel Landwerlin 3889dda1f1 vulkan: move EXT_tooling_info implementation to runtime
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15491>
2022-03-23 09:51:57 +00:00
Brian Paul 03d342e4b2 vulkan/wsi/x11: add null pointer check for the has_dri3_v1_2 test
This fixes a crash (ver_reply is NULL) when DISPLAY points to
a remote display.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6040
Signed-off-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15469>
2022-03-23 03:19:40 +00:00
Jason Ekstrand df92f56d8d vulkan/runtime: Add emulated secondary command buffer support
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14406>
2022-03-18 17:29:16 +00:00
Boris Brezillon 25542f12d7 vulkan/cmd_queue: Fix the allocation scope
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND is used for transient allocations that
are not expected to live outside the vkXxx(). Use
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT for cmd_entry allocations.

v2 (Jason Ekstrand):
 - Also fix the manually typed entrypoints in vk_cmd_enqueue.c

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14406>
2022-03-18 17:29:16 +00:00
Boris Brezillon 1437ee749b vulkan/cmd_queue: Track allocation errors in vk_cmd_queue
Needed to report allocation failures when vkEndCommandBuffer() is
called.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14406>
2022-03-18 17:29:16 +00:00
Jason Ekstrand 6cb95877b5 vulkan/cmd_queue: Auto-generate more vk_cmd_enqueue_unless_primary_Cmd*
Instead of one MANUAL_COMMANDS, we now have two deny-lists:
MANUAL_COMMANDS and NO_ENQUEUE_COMMANDS.  The former is for things which
have a manually typed implementation in vk_cmd_enqueue.c and the later
is for things we want to ignore entirely.  This lets us auto-generate
vk_cmd_enqueue_unless_primary_Cmd* entrypoints for the manually typed
vk_cmd_enqueue_Cmd* entrypoints.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14406>
2022-03-18 17:29:16 +00:00
Jason Ekstrand 3cffffc441 vulkan/cmd_queue: Generate enqueue_if_not_primary entrypoints
These check the command buffer level and enqueue the command if it's not
a primary but uses vk_device::command_dispatch_table for primaries.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14406>
2022-03-18 17:29:16 +00:00
Jason Ekstrand 8f29c833da vulkan/cmd_queue: Add a vk_cmd_queue_execute() helper
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14406>
2022-03-18 17:29:16 +00:00
Jason Ekstrand 25664c6194 vulkan: Add a 2 wrapper for vkGetPhysicalDeviceQueueFamilyProperties
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15459>
2022-03-18 10:10:33 -05:00
Emma Anholt da834a12cf vulkan: Make sure we've loaded our connectors when querying plane props.
If you hadn't already called wsi_GetPhysicalDeviceDisplayProperties2KHR or
wsi_GetDrmDisplayEXT before calling
GetPhysicalDeviceDisplayPlaneProperties2KHR, then the connectors list
wouldn't be populated and you'd get no plane properties.  Fixes failure of
dEQP-VK.wsi.display.get_display_plane_capabilities when run on its own.

Fixes: #4575
Cc: mesa-stable
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15353>
2022-03-16 21:43:46 +00:00
Jason Ekstrand 030b231ba9 vulkan/framebuffer: Add a flags field
Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14961>
2022-03-16 12:51:15 -05:00
Jason Ekstrand c3d8ca9300 vulkan/render_pass: Add an optimization for UNDEFINED+LOAD_OP_CLEAR
Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14961>
2022-03-16 12:51:15 -05:00
Jason Ekstrand 17395d395a vulkan/render_pass: Support fragment shading rate
Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14961>
2022-03-16 12:51:15 -05:00
Jason Ekstrand 6b61953684 vulkan/render_pass: Provide self-dependeny information
Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14961>
2022-03-16 12:51:15 -05:00
Jason Ekstrand ca5ad9cbee vulkan: Add helpers for getting rendering info from a renderpass
These helpers are used by vkCreateGraphicsPipelines to get the
VkPipelineRenderingCreateInfo and in vkCmdBeginCommandBuffer to get the
VkCommandBufferInheritanceRenderingInfo.  This is required because the
Vulkan runtime code can't yet hook and modify calls made to driver-
provided functions.  Instead, we just provide a helper to be used in leu
of vk_find_struct_const().  The structs themselves are stored in the
render pass so we can pass back a pointer and there's no need to
construct one on the stack or stuff it in the pipeline.

Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14961>
2022-03-16 12:51:15 -05:00
Jason Ekstrand 1d726940d2 vulkan: Add a common CmdBegin/EndRederPass implementation
This implements vkCmdBeginRenderPass, vkCmdEndRenderPass, and
vkCmdNextSubpass in terms of the new vkCmdBegin/EndRendering included in
VK_KHR_dynamic_rendering and Vulkan 1.3.  All subpass dependencies and
implicit layout transitions are turned into actual barriers.  It does
require VK_KHR_synchronization2 because it always uses the 64-bit
version of the pipeline stage and access bitfields.

Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14961>
2022-03-16 12:51:15 -05:00
Jason Ekstrand 874aeb8743 vulkan: Add a common vk_render_pass struct
This basically contains everything in pCreateInfo plus one or two extra
bits that might be useful.

Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14961>
2022-03-16 12:51:15 -05:00
Jason Ekstrand d84e6b8f22 vulkan: Add a common vk_framebuffer struct
Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14961>
2022-03-16 12:51:15 -05:00
Jason Ekstrand 21b405fbbc vulkan: Add a vk_shader_module_to_nir() helper
This encapsulates all the little bits needed to turn a shader module
into some mostly reasonable NIR.  It handles inlining functions,
lowering variable initializers, handling per-member structs and other
trickiness that is needed for consuming the output of spirv_to_nir.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15305>
2022-03-15 23:13:16 +00:00
Bas Nieuwenhuizen 6c0bc7eb07 vk: Update xml and headers to 1.3.207.
Acked-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15363>
2022-03-15 18:52:41 +00:00
Jason Ekstrand 95a44a5b09 lavapipe: Use the auto-generated vk_enqueue_BeginRendering
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15325>
2022-03-11 11:40:41 -06:00
Jason Ekstrand f76621f719 vulkan/cmd_queue: Properly support non-array pointer members
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5440
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15325>
2022-03-11 11:36:53 -06:00
Jason Ekstrand 94ea3b9c03 vulkan/cmd_queue: Add a common vk_cmd_enqueue_CmdBindDescriptorSets
In order for this to work, the driver must reference-count pipeline
layouts so we can take a reference while the command is in the queue.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15329>
2022-03-10 21:08:36 +00:00
Jason Ekstrand c1070556a0 vulkan/cmd_queue: Add a driver_free_cb hook
If a driver sets driver_data but not driver_free_cb, driver_data will
get freed along with the command.  If a driver sets driver_free_cb,
driver_data will not get automatically freed but the callback will get
called before the rest of the data structure is freed.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15329>
2022-03-10 21:08:36 +00:00
Jason Ekstrand cc4f0e804e vulkan,lavapipe: Move some enqueue helpers to common code
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15311>
2022-03-10 15:52:10 +00:00
Boris Brezillon b98cfe9cb4 lavapipe: Re-use auto-generated vk_cmd_enqueue entrypoints
Re-use auto-generated vk_cmd_enqueue entrypoints instead of generating
our own version doing the same thing.  In order to effectively do this,
we also add an allow-list of which entrypoints lavapipe actually handles
to avoid issues where the autogenerated one stomps a vkCmdFoo2 wrapper.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15311>
2022-03-10 15:52:10 +00:00
Jason Ekstrand 719b949575 vulkan/cmd_queue: Generate enqueue entrypoints
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15311>
2022-03-10 15:52:10 +00:00
Boris Brezillon 47fc0b39c7 vulkan/cmd_queue: Properly deconstify array of pointers
When manipulating an array of pointers, what we want to desconstify is
the array, not the entry type.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15311>
2022-03-10 15:52:10 +00:00
Jason Ekstrand 0d5dc6ef6a vulkan/cmd_queue: Stop generating enqueue helpers for INTEL perf queries
They don't return void and they're not used by anyone except the Intel
drivers so there's no point in supporting them.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15311>
2022-03-10 15:52:10 +00:00
Jason Ekstrand cf8cf8a827 vulkan/cmd_queue: Re-flow MANUAL_COMMANDS
This just makes it all a bit easier to read.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15311>
2022-03-10 15:52:10 +00:00
Boris Brezillon 290e33ab20 vulkan/cmd_queue: Remove duplicate entries in MANUAL_COMMANDS
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15311>
2022-03-10 15:52:10 +00:00
Louis-Francis Ratté-Boulianne 6bd8a3c7e4 vulkan/runtime: Add a vk_cmd_queue object to vk_command_buffer
This is paving the road for generic secondary command buffer support,
where commands are simply recorded in a software queue and replayed
on the primary command buffer when vkCmdExecuteCommands() is called.

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15311>
2022-03-10 15:52:10 +00:00
Louis-Francis Ratté-Boulianne ad4d2da90a vulkan/cmd_queue: Add an initializer for the vk_cmd_queue object
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15311>
2022-03-10 15:52:10 +00:00
Boris Brezillon dd0f6cb45b vulkan/cmd_queue: Constify vk_cmd_queue.alloc
The implementation shouldn't modify the allocator.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15311>
2022-03-10 15:52:10 +00:00
Yogesh Mohan Marimuthu 3332fcd9c0 vulkan/device_select: add has_vulkan11 flag with has_pci_bus flag
In EnumeratePhysicalDevices(), pci bus info is available only in
vulkan version >= 1.1. hence adding has_vulkan11 flag in places
where has_pci_bus is used in EnumeratePhysicalDevices() code flow.

Signed-off-by: Yogesh Mohan Marimuthu <yogesh.mohanmarimuthu@amd.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14535>
2022-03-08 14:23:41 +00:00
Yogesh Mohan Marimuthu 1cc549949d vulkan/device_select: for vulkan 1.0 use vid/did for boot_vga
In device select layer EnumeratePhysicalDevices() function pci
bus information is available only in case of vulkan >= 1.1.
Hence use vid/did to match boot_vga device in case of vulkan 1.0.

Signed-off-by: Yogesh Mohan Marimuthu <yogesh.mohanmarimuthu@amd.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14535>
2022-03-08 14:23:41 +00:00
Michel Zou f1f1b3d7f8 vulkan/wsi: drop unused wsi_create_win32_image
fixes: ed391d2a

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15088>
2022-03-03 06:13:07 +00:00
Dave Airlie 48b3ef625e vulkan/wsi: handle queue families properly for non-concurrent sharing mode.
"queueFamilyIndexCount is the number of queue families having access to the image(s) of the
swapchain when imageSharingMode is VK_SHARING_MODE_CONCURRENT.
pQueueFamilyIndices is a pointer to an array of queue family indices having access to the
images(s) of the swapchain when imageSharingMode is VK_SHARING_MODE_CONCURRENT."

If the type isn't concurrent, don't attempt to access the arrays.

dEQP-VK.wsi.xlib.swapchain.create.exclusive_nonzero_queues on lavapipe.

Fixes: 5b13d74583 ("vulkan/wsi/drm: Break create_native_image in pieces")
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15101>
2022-03-02 20:47:16 +00:00
Erik Faye-Lund 5c5243adb7 vulkan/wsi: use buffer-image code-path on Windows
This means we no longer map optimal-tiling images in order to display
them on screen, but instead copy via a buffer, which is guaranteed to
linearize.

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12210>
2022-02-22 10:04:34 +00:00
Erik Faye-Lund 2e8c119531 vulkan/wsi: add transition to/from transfer-src state
Without these barriers, we'll try to blit from the image when it's in
the incorrect layout, which is illegal.

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12210>
2022-02-22 10:04:34 +00:00
Erik Faye-Lund 25a37fabb7 vulkan/wsi: untangle buffer-images from prime
Not all Vulkan implementations allows rendering to linear images, so in
order to support scanning out from these on Windows we might have to copy
through a buffer like we do in the PRIME path.

To avoid reimplementing the same, let's instead generalize the code a
bit so it doesn't have to specfy any PRIME-specific details.

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12210>
2022-02-22 10:04:34 +00:00
Boris Brezillon 32c2db1b25 vulkan/wsi: Don't open-code vk_format_get_blocksize()
We already have a standard helper to retrieve the texel block size from
a VkFormat, let's use it instead of adding a new helper.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Suggested-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12210>
2022-02-22 10:04:34 +00:00
Boris Brezillon 7c1c6606d0 vulkan/wsi: Use ALIGN_POT() instead of open-coding it
align_u32() and ALIGN_POT() are doing the same thing.
Replace align_u32() calls by ALIGN_POT() ones and get rid
of align_u32().

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Suggested-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12210>
2022-02-22 10:04:34 +00:00
Erik Faye-Lund 83938a1bb3 vulkan/wsi: pass win32-swapchain directly
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12210>
2022-02-22 10:04:34 +00:00
Jason Ekstrand 818c5dedf4 vulkan: Add back vk_image_view::format
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15007>
2022-02-16 00:14:50 +00:00
Jason Ekstrand 05e9e7767d vulkan: Rename vk_image_view::format to view_format
When I originally added vk_image_view, I was overly clever when it came
to the format field.  I decided to make it only contain the bits of the
format contained in the selected aspects.  However, this is confusing
(not generally a good thing) and it's also not always what you want.
The Vulkan 1.3.204 spec says:

    "When using an image view of a depth/stencil image to populate a
    descriptor set (e.g. for sampling in the shader, or for use as an
    input attachment), the aspectMask must only include one bit, which
    selects whether the image view is used for depth reads (i.e. using a
    floating-point sampler or input attachment in the shader) or stencil
    reads (i.e. using an unsigned integer sampler or input attachment in
    the shader). When an image view of a depth/stencil image is used as
    a depth/stencil framebuffer attachment, the aspectMask is ignored
    and both depth and stencil image subresources are used."

So, while the restricted format makes sense for texturing, it doesn't
for when the image is being used as an attachment.  What we probably
actually want is both versions of the format.  We'll call the one given
by the VkImageViewCreateInfo vk_image_view::format and the restricted
one vk_image_view::view_format.

This is just the first commit which switches format to view_format so
the compiler will make sure we get them all.  The next commit will
re-add vk_image_view::format but this time unmodified.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15007>
2022-02-16 00:14:50 +00:00
Simon Ser ffdac8bfa7 vulkan/wsi/wayland: ensure added formats have flags
A format needs to be either alpha or opaque, but can't be neither.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14874>
2022-02-15 09:13:21 +00:00
Simon Ser 5617d5c885 vulkan/wsi/wayland: de-duplicate wsi_wl_display_add_wl_shm_format
Re-use wsi_wl_display_add_drm_format_modifier from
wsi_wl_display_add_wl_shm_format instead of maintaining two
separate switches for DRM and shm formats.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14874>
2022-02-15 09:13:21 +00:00
Simon Ser 1bdf350197 vulkan/wsi/wayland: introduce wsi_wl_display_add_vk_format_modifier
This is a helper to avoid repetitive code in
wsi_wl_display_add_drm_format_modifier.

No functional changes, just refactoring.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14874>
2022-02-15 09:13:21 +00:00
Simon Ser 8ac42a3b1b vulkan/wsi/wayland: switch from alpha/opaque bools to bitfield
This makes the numerous wsi_wl_display_add_vk_format calls easier
to follow: "ALPHA" is easier to decode than "true, false".

No functional changes, just refactoring.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14874>
2022-02-15 09:13:21 +00:00
Jason Ekstrand 37f3da90dd vulkan: Implement of a bunch of VkCommandPool functions
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14917>
2022-02-11 08:06:25 +00:00
Jason Ekstrand f424d1e9ab vulkan/queue: Assert command buffers have the right queue family
We've got enough information in common code to track this now so we may
as well throw in a helpful assert.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14917>
2022-02-11 08:06:25 +00:00
Jason Ekstrand bda4c4f6b6 vulkan: Take a vk_command_pool in vk_command_buffer_init()
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14917>
2022-02-11 08:06:25 +00:00
Jason Ekstrand a10b6d1c6f vulkan: Add a common vk_command_pool base struct
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14917>
2022-02-11 08:06:24 +00:00
Louis-Francis Ratté-Boulianne 5e263cc324 vulkan/runtime: Add a level field to vk_command_buffer
Looks like 3 implementations already have that field in their private
command_buffer struct, and having it at the vk_command_buffer opens the
door for generic (but suboptimal) secondary command buffer support.

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14917>
2022-02-11 08:06:24 +00:00
Jason Ekstrand 4c61c8a0b8 vulkan,lavapipe: Simplify command recording code-gen
The Entrypoint class already has utilities for gettingt he parameter
list as either declarations or as comma-separated argument names for a
call.  Use that instead of hand-rolling it.  The only modification we
need to make is to add the ability to start the list somewhere other
than at the beginning.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14919>
2022-02-08 19:50:57 +00:00
Mike Blumenkrantz 8335fdfeaf vk/sync: add asserts for timeline semaphore count matching
spec requires that the number of timeline waits/signals matches the
base number of waits/signals if there are any timeline semaphores
being processed by the submit, so asserting here is in line with what
validation will yield

failure to match these will also hang every driver I've tested, so asserting
here potentially saves some people their desktop session

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14741>
2022-02-08 04:09:13 +00:00
Erik Faye-Lund 3abe9ccbd4 vulkan/util: simplify multialloc init
The syntax we're using doesn't work when included into C++ sources. So
let's make it C++ compabible.

It turns out, nobody needs this extra definition which is what's causing
issues. Let's just make the initializer trivial without casting the
struct.

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14850>
2022-02-04 10:16:42 +00:00
Erik Faye-Lund 0d0ecbd987 vulkan/util: Add explicit casts to make c++ happy
We're about to need including this header from a C++ source, so let's
add some explicit casts for C++ compatibility.

In one case we can make things a bit cleaner by moving the
char-pointer-ism to the place that needs it, so let's clean that up
while we're at it.

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14850>
2022-02-04 10:16:42 +00:00
Erik Faye-Lund 676c65d8d5 vulkan/util: Add extern "C" to allow inclusion from c++
We're about to need including this header from a C++ source, so let's
wrap the whole thing in extern "C".

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14850>
2022-02-04 10:16:42 +00:00
Simon Ser 713a4363e5 vulkan/wsi/wayland: remove format switch from wl_shm_format_for_vk_format
Instead of maintaining two similar switches (one for DRM formats,
one for wl_shm formats), only maintain a single switch (for DRM)
and convert DRM formats to enum wl_shm_format. This reduces the
risk to have inconsistencies between these two functions.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14634>
2022-02-01 08:00:22 +00:00
Simon Ser 5a82232e5c vulkan/wsi/wayland: use DRM_FORMAT_INVALID
Instead of using the magic value 0, use the define.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14634>
2022-02-01 08:00:22 +00:00
Simon Ser fda2aecb8b vulkan/wsi/wayland: use enum wl_shm_format
libwayland defines an enum for wl_shm formats. Let's use it instead
of uint32_t.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14634>
2022-02-01 08:00:22 +00:00
Jason Ekstrand 27042d135e vulkan/wsi: Add image create and bind helpers
These are needed to properly implement the Vulkan 1.1 swapchain image
create/bind functionality.

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:55 +00:00
Jason Ekstrand ca791f5c5d wsi/common: Set VK_IMAGE_CREATE_ALIAS_BIT
With Vulkan 1.1, we have a VkImageSwapchainCreateInfoKHR struct which
lets you create a new VkImage which aliases a swapchain image.  However,
there is no corresponding swapchain create flag so we have to set
VK_IMAGE_CREATE_ALIAS_BIT all the time.

We need to do a bit of work in ANV to prevent it from asserting the
moment it sees one of these.  Fortunately, they're already safe because
WSI images go through a different bind path for
VkBindImageMemorySwapchainInfoKHR.

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:55 +00:00
Jason Ekstrand 1abab1a28f vulkan/wsi/drm: Drop wsi_create_native/prime_image
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:55 +00:00
Jason Ekstrand ed391d2a46 vulkan/wsi/win32: Break create_win32_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 and calls
wsi_create_image to walk through the three-step process.

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:55 +00:00
Jason Ekstrand d7ad73d6b7 vulkan/wsi/win32: Delete unnecessary copy+paste from DRM
The Win32 WSI just does a copy into the window on the CPU.  There's no
need for external memory or modifiers or implicit sync or any of that.
While we're at it, rename to create_win32_image.

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:55 +00:00
Jason Ekstrand d95e3fd98c vulkan/wsi/display: Split image creation
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:55 +00:00
Jason Ekstrand b626a5be43 vulkan/wsi/wayland: Split image creation
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:55 +00:00
Jason Ekstrand d67250d444 vulkan/wsi/x11: Split image creation
Store the wsi_image_create_info in the swapchain and call
wsi_configure_*_image once per swapchain and then use wsi_create_image
for each image.

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 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