Commit graph

2253 commits

Author SHA1 Message Date
Yiwei Zhang
90caf9bdbd vulkan/wsi/headless: drop the wsi_create_null_image_mem override
The existing wsi code paths work in the most correct manner now w.r.t
implicit fencing, memory allocation, prime buffer blit, etc.

With this and the prior change, ANV with headless doubled the perf and
beats the windowed vkmark run.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36687>
2025-08-10 07:16:46 +00:00
Yiwei Zhang
6ac8ac38f1 vulkan/wsi/headless: acquire the most likely idle image
Previously the present marks the image free, and the next acquire would
immediately acquire the just presented image back, which likely still
has pending gpu work going on. To avoid introducing a present queue in
headless, we simply tweak to acquire swapchain images in a loop to give
the app the most likely idle image.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36687>
2025-08-10 07:16:46 +00:00
llyyr
dbb779967c vulkan: Update enum_to_str conversion to handle AMDX enum names
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Without this, mesa fails to build with:
src/vulkan/util/vk_enum_to_str.c:684:14: error:
‘VK_COMPRESSED_TRIANGLE_FORMAT_AMDX_MAX_ENUM’ undeclared (first use in
this function); did you mean
‘VK_COMPRESSED_TRIANGLE_FORMAT_MAX_ENUM_AMDX’?

Fixes: c74ad9f142 ("vulkan: Update headers/xml for 1.4.325")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36693>
2025-08-09 01:24:10 +00:00
Caio Oliveira
c74ad9f142 vulkan: Update headers/xml for 1.4.325
Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36681>
2025-08-08 22:41:14 +00:00
Caio Oliveira
c00b167d16 vulkan: Update enum_to_str conversion to handle ARM enum names
Next Vulkan update will have
VK_DATA_GRAPH_PIPELINE_PROPERTY_MAX_ENUM_ARM and similar names,
so apply the same rule for ARM prefix.

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36681>
2025-08-08 22:41:14 +00:00
Yiwei Zhang
5b1104476f vulkan/wsi/headless: drop redundant chain struct members
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Reviewed-by: Janne Grunau <j@jannau.net>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36658>
2025-08-08 16:34:26 +00:00
Yiwei Zhang
24cb071d47 vulkan/wsi/headless: allow explicit modifiers
When wsi device has modifier support, simply allow all driver supported
modifiers for the requested format.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12534
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13636
Reviewed-by: Janne Grunau <j@jannau.net>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36658>
2025-08-08 16:34:26 +00:00
Hyunjun Ko
609ef617c9 vulkan/video: align with spec correctly for h265 slice header.
Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36211>
2025-08-08 11:26:13 +00:00
Karol Herbst
fe09dfbcf3 vulkan: use p_atomic_read on vk_descriptor_set_layout::ref_cnt
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36652>
2025-08-08 10:26:52 +00:00
Konstantin Seurer
fe4c3dcab8 vulkan: Add MESA_VK_SHADER_STAGE_ALL
For masking invalid bits.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36371>
2025-08-07 20:46:24 +00:00
Simon Perretta
ba92104b56 wsi/display: make HDR_OUTPUT_METADATA, Colorspace properties optional
Fixes some dEQP-VK.wsi.display.* issues on platforms that don't
support said properties following their addition in !35461.

Fixes: b4176393a0 ("wsi/display: Implement VK_EXT_hdr_metadata on KHR_display swapchain")

Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Reviewed-by: David Rosca <david.rosca@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36607>
2025-08-07 20:32:02 +01:00
Qiang Yu
196569b1a4 all: rename gl_shader_stage to mesa_shader_stage
It's not only for GL, change to a generic name.

Use command:
  find . -type f -not -path '*/.git/*' -exec sed -i 's/\bgl_shader_stage\b/mesa_shader_stage/g' {} +

Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36569>
2025-08-06 10:28:40 +08:00
Qiang Yu
799806d85e all: rename PIPE_SHADER_MESH_TYPES to MESA_SHADER_MESH_STAGES
Use command:
  find . -type f -not -path '*/.git/*' -exec sed -i 's/\bPIPE_SHADER_MESH_TYPES\b/MESA_SHADER_MESH_STAGES/g' {} +

Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36569>
2025-08-06 10:28:40 +08:00
Ernst Persson
2bdbc72d27 vulkan/util: Use str.removeprefix() from Python 3.9
Signed-off-by: Ernst Persson <ernstp@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36398>
2025-08-05 21:39:58 +00:00
Hyunjun Ko
b59552628e vulkan/video: fix to set ref_pic_list_modification_flag_l1 correctly
Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36152>
2025-08-05 09:16:56 +00:00
Hyunjun Ko
62b07c01d1 vulkan/video: fix to write a h264 slice header for CAVLC mode
In CAVLC mode, slice header doesn't need to be aligned. Instead
encoder needs exact bits written in the slice header in order to
set the offset correctly.

This fixes encoding with entropy_coding_mode_flag false.

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36152>
2025-08-05 09:16:56 +00:00
David Rosca
94619a0f4b wsi/display: Add RGBA16, RGBA16F and A2RGB10(SRGB) formats
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35461>
2025-08-05 08:50:07 +00:00
David Rosca
d977951d64 wsi/display: Report supported formats based on plane formats
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35461>
2025-08-05 08:50:05 +00:00
Joshua Ashton
13137393f6 wsi/display: Expose HDR10 colorspace based on EDID
Uses libdisplay-info to parse the edid, grab the metadata and see
if HDR10 is supported by the display.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35461>
2025-08-05 08:50:05 +00:00
Joshua Ashton
1ed78dd7ec wsi/display: Clean up DRM hdr/color state on swapchain destruction
Reset our color outcome to defaults, and update the state.
We need to clean up after our mess, for any other compositors,
etc that come after us that may not be aware of properties
we have set.
We can do this by just setting ourselves back to sRGB and therefore
SDR and updating like normal.
We only need to do this if we have a color outcome serial that isn't
0, the default.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35461>
2025-08-05 08:50:05 +00:00
Joshua Ashton
b4176393a0 wsi/display: Implement VK_EXT_hdr_metadata on KHR_display swapchain
Signed-off-by: Joshua Ashton <joshua@froggi.es>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35461>
2025-08-05 08:50:05 +00:00
Joshua Ashton
b465d144ca wsi/common: Track VkColorSpaceKHR with wsi swapchain
Signed-off-by: Joshua Ashton <joshua@froggi.es>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35461>
2025-08-05 08:50:05 +00:00
Valentine Burley
1dfe5bbd09 vulkan/wsi/wayland: Enable 4444 formats
Expose 4444 formats when they are available.

Fixes dEQP-EGL.functional.*rgba4444* with zink on ANV.

Signed-off-by: Valentine Burley <valentine.burley@collabora.com>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36111>
2025-08-05 06:04:28 +00:00
Yiwei Zhang
83b9c13b6f Revert "android: moving HMI symbol to separate file"
This reverts commit 6c7f7e4953.

The original change wasn't properly reviewed and the rationale was
obscure. Meanwhile, it was for gfxstream Android frontend which was not
built in upstream mesa at all.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36532>
2025-08-01 23:44:49 +00:00
Antonio Ospite
ddf2aa3a4d build: avoid redefining unreachable() which is standard in C23
In the C23 standard unreachable() is now a predefined function-like
macro in <stddef.h>

See https://android.googlesource.com/platform/bionic/+/HEAD/docs/c23.md#is-now-a-predefined-function_like-macro-in

And this causes build errors when building for C23:

-----------------------------------------------------------------------
In file included from ../src/util/log.h:30,
                 from ../src/util/log.c:30:
../src/util/macros.h:123:9: warning: "unreachable" redefined
  123 | #define unreachable(str)    \
      |         ^~~~~~~~~~~
In file included from ../src/util/macros.h:31:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:456:9: note: this is the location of the previous definition
  456 | #define unreachable() (__builtin_unreachable ())
      |         ^~~~~~~~~~~
-----------------------------------------------------------------------

So don't redefine it with the same name, but use the name UNREACHABLE()
to also signify it's a macro.

Using a different name also makes sense because the behavior of the
macro was extending the one of __builtin_unreachable() anyway, and it
also had a different signature, accepting one argument, compared to the
standard unreachable() with no arguments.

This change improves the chances of building mesa with the C23 standard,
which for instance is the default in recent AOSP versions.

All the instances of the macro, including the definition, were updated
with the following command line:

  git grep -l '[^_]unreachable(' -- "src/**" | sort | uniq | \
  while read file; \
  do \
    sed -e 's/\([^_]\)unreachable(/\1UNREACHABLE(/g' -i "$file"; \
  done && \
  sed -e 's/#undef unreachable/#undef UNREACHABLE/g' -i src/intel/isl/isl_aux_info.c

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36437>
2025-07-31 17:49:42 +00:00
Antonio Ospite
b4c7d3a08e build: stop calling unreachable() without arguments
The unreachable(str) macro defined in src/util/macros.h is defined to
accept a literal string as an argument.

However the way it checks that the argument is a string literal, by
prepending an empty string where the argument is used, i.e.:

  #define unreachabel(str) assert(!"" str)

still allows users to call the macro with no arguments.

This is confusing, so pass an empty string to all invocations of
unreachable() for consistency.

This is done with the following command:

  git grep -l '[^_]unreachable();' -- "src/**" | sort | uniq | \
  while read file; \
  do \
    sed -e 's/\([^_]\)unreachable();/\1unreachable("");/g' -i "$file";
  done

This should not change the behaviour of the callers of unreachable() in
a meaningful way, but there will be some cosmetic consequence.

The changed invocations will now print:

  Assertion `!"" ""' failed.

instead of

  Assertion `!""' failed.

But this is also what happens for the invocations that do pass an
argument, for instance `unreachable("Invalid type")` currently prints:

  Assertion `!"" "Invalid type"' failed.

So all invocations now also have the same output style.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36437>
2025-07-31 17:49:40 +00:00
Sergii Ushakov
6c7f7e4953 android: moving HMI symbol to separate file
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
To support "surfaceless" builds on Android it is required to still have
HMI symbol exported by the library while no other android-specific code is
needed.

Reviewed-by: Gurchetan Singh <gurchetansingh@google.com>
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36459>
2025-07-31 17:11:51 +00:00
David Rosca
2c3bb204a5 vulkan/video: Fix h265 level values
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
From spec:
"general_level_idc shall be set equal to a value of 30 times the level number."

Fixes: 8243145f02 ("vulkan/video: add a h265 level translator.")
Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36285>
2025-07-31 10:08:05 +00:00
Konstantin Seurer
656acb96b0 vulkan/cmd_queue: Reorder memcpy in get_struct_copy
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Using the temporary variable for the memcpy makes sure they are always
used so the "(void)tmp_src123" can be removed.

Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36331>
2025-07-31 08:13:59 +00:00
Konstantin Seurer
d29f446aa3 vulkan/cmd_queue: Clean up generating copies
Using the builder makes it much easier to see what is happening and
fixes indentation in the process.

Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36331>
2025-07-31 08:13:58 +00:00
Konstantin Seurer
d824525a01 vulkan/cmd_queue: Recursively free struct members
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36331>
2025-07-31 08:13:58 +00:00
Konstantin Seurer
ea7a2f9834 vulkan/cmd_queue: Improve struct free code indentation
It also cleans up the way the string is generated because using large templates was a mess.

Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36331>
2025-07-31 08:13:58 +00:00
Konstantin Seurer
c29db0965c vulkan/cmd_queue: Do not free if driver_free_cb is provided
Avoids crashes when the custom implementation allocates differently.

Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36331>
2025-07-31 08:13:58 +00:00
Eric Engestrom
fdcad6e547 meson: include VkLayer_MESA_anti_lag in the devenv
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
See https://github.com/KhronosGroup/Vulkan-Loader/blob/main/docs/LoaderLayerInterface.md#linux-layer-discovery

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36346>
2025-07-30 23:53:51 +00:00
Eric Engestrom
55d5c3dd8f meson: include VkLayer_MESA_vram_report_limit in the devenv
See https://github.com/KhronosGroup/Vulkan-Loader/blob/main/docs/LoaderLayerInterface.md#linux-layer-discovery

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36346>
2025-07-30 23:53:51 +00:00
Eric Engestrom
56c910aafc meson: include VkLayer_MESA_screenshot in the devenv
See https://github.com/KhronosGroup/Vulkan-Loader/blob/main/docs/LoaderLayerInterface.md#linux-layer-discovery

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36346>
2025-07-30 23:53:51 +00:00
Eric Engestrom
45789ac396 meson: fix VkLayer_MESA_device_select in the devenv
It's an implicit layer, not an explicit one like the others in that MR,
which I missed in the previous commit.

Fixes: 294d8ce80a ("meson: include VkLayer_MESA_device_select in the devenv")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36346>
2025-07-30 23:53:51 +00:00
Eric Engestrom
a8e9af2ce9 wsi/display: pass the plane's modifiers to the image
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
This should cause us to choose a better-than-linear format modifier
automatically based on the intersection of the driver's support and the
display plane's support.

Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36341>
2025-07-29 16:44:04 +00:00
Emma Anholt
0c0d9c05e0 wsi/display: Do connector setup before swapchain init.
The connector setup decides on a CRTC/plane, and can be done early.  We're
going to need that to get the modifiers list before we have swapchain init
create the images.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36341>
2025-07-29 16:44:04 +00:00
Emma Anholt
fe7652eae9 wsi/display: Pull DRM format translation up a level.
Saves doing it multiple times, but more importantly we want to know it
before wsi_swapchain_init() soon.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36341>
2025-07-29 16:44:03 +00:00
Eric Engestrom
b16a6a56d8 wsi/display: pass the image's DRM modifiers to the kernel
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36341>
2025-07-29 16:44:02 +00:00
Thomas H.P. Andersen
f8741cc344 anti-lag: pass a proper dataSize
dataSize was passed as sizeof(uint64_t)

From spec:
dataSize is the size in bytes of the buffer pointed to by pData.
dataSize must be large enough to contain the result of each query

The NVK driver checks that the dataSize is large enough and hit an assert.

This patch changes dataSize to sizeof(struct query) * num_timestamps.

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36402>
2025-07-29 15:24:14 +00:00
Faith Ekstrand
064b9e5645 vulkan/wsi/x11: Handle VK_NOT_READY in AcquireNextImage()
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
This check assumed that we would always get `VK_TIMEOUT` from
wsi_queue_pull() but the new explicit sync wait is smart enough to do
that for us.  Unfortunately, the X11 code weasn't smart enough to know
that VK_NOT_READY (which is a positive return code) was also an early
exit condition.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12971
Fixes: 899263ecfc ("wsi/x11: support explicit sync")
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tested-by: Adam Ivora
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36419>
2025-07-29 15:05:40 +00:00
Christoph Pillmayer
a501d26dee vk/sync: Pass dependencyFlags in vk_common_CmdPipelineBarrier
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>

Fixes: 97f0a449 ("vulkan: implement legacy entrypoints on top of VK_KHR_synchronization2")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36321>
2025-07-29 11:11:29 +00:00
Yiwei Zhang
aac51c3a0b vulkan/android: improve memoryTypeBits reporting in AHB props query
Instead of reporting all memory types being compatible, at least we can
limit the types to those compatible for dma-buf import. Optionally, we
can do even better here to actually create the image or buffer with the
AHB to get more accurate memory type bits for memory import. However, it
is optional since we can touch up in the common layer upon actual AHB
import time.

Reviewed-by: Antonio Ospite <antonio.ospite@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36388>
2025-07-29 07:50:09 +00:00
Mike Blumenkrantz
05cc38bb68 vulkan: silence typed_memcpy -Waddress warnings
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36413>
2025-07-28 17:31:54 +00:00
Maíra Canal
ab3aaad957 vulkan: don't destroy vk_sync_timeline if a point is still pending
Currently, vk_sync_timeline_wait() may report idle while we still have
time points outstanding in vk_queue. This race between vk_sync_timeline
and vk_queue is problematic as vk_queue_submit_cleanup() can end-up
trying to unref a timeline point that was already destroyed in
vk_sync_timeline_finish(), leading to an use-after-free.

Address this race-condition by introducing a reference counter to the
timeline. Each timeline point takes a reference to the timeline when
it's checked out and drops the reference when it's freed. Now, the
timeline is only destroyed when all the references had been dropped.

To guarantee that all references will be dropped and the timeline will
be destroyed, vk_sync_timeline_finish() waits for all pending points
to be checked out.

This commit fixes several Mesa CI flakes in v3dv related to timeline
semaphores.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12648
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35921>
2025-07-24 18:49:02 -03:00
Faith Ekstrand
088a979e79 vulkan: Hold a reference to pending vk_sync_timeline_points
Previously, we had a sort of double reference count with refcount being
used to track how many waits were holding a reference and pending being
used to track whether or not it was in the pending list. This meant
that the unref operation actually had to look at both refcount and
pending in order to determine if it could free the time point. This is
way too confusing. Instead, we should just always take a reference
while we're pending.

This also simplifies the over-all interface because there's no longer a
difference between free and release. `struct vk_sync_timeline_point` is
now just a reference-counted API.

Reviewed-by: Maíra Canal <mcanal@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35921>
2025-07-24 18:49:02 -03:00
Faith Ekstrand
54eb41588c vulkan: Rename a bunch of vk_sync_timeline helpers
Whenever we assume the timeline state is locked, we use _locked, pass in
the timeline state explicitly, and rename it so it's clearly an action
which the timeline does on the point.  This makes it far more clear who
owns a reference to what and where.

Reviewed-by: Maíra Canal <mcanal@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35921>
2025-07-24 18:49:02 -03:00
Maíra Canal
d73b9a7229 vulkan: create a wrapper struct for vk_sync_timeline
The lifetime of `struct vk_sync_timeline` is tied to the lifetime of
`vk_fence` or `vk_semaphore` objects. To better manage this lifecycle,
create a wrapper struct `vk_sync_timeline_state` that contains the
timeline state and is dynamically allocated when the timeline is
initialized. This separation allows the timeline state to persist
independently of the sync object lifecycle.

Signed-off-by: Maíra Canal <mcanal@igalia.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35921>
2025-07-24 18:48:19 -03:00