Commit graph

207441 commits

Author SHA1 Message Date
Gert Wollny
141e06caca r600/sfn: split kcache evaluation into try and commit
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Assisted-by: Copilot (auto mode)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41945>
2026-06-07 21:36:57 +00:00
Gert Wollny
81d359de55 r600/sfn: simplify ALU scheduling failure handling
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Assisted-by: Copilot (auto mode)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41945>
2026-06-07 21:36:57 +00:00
Gert Wollny
033dd489de r600/sfn: collaps no_schedule and scheduled
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Assisted-by: Copilot (auto mode)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41945>
2026-06-07 21:36:57 +00:00
Gert Wollny
4698c17b9d r600/sfn: make ALU scheduling return values more meaningful
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Assisted-by: Copilot (auto mode)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41945>
2026-06-07 21:36:57 +00:00
Gert Wollny
b4efcadbb8 r600/sfn: extract idx load state handling in scheduler
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Assisted-by: Copilot (auto mode)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41945>
2026-06-07 21:36:57 +00:00
Gert Wollny
100061cdcf r600/sfn: extract t-slot allocation when filling ALU groups
Also replace the magic number 0x10 with AluOp::t to make it easier to
understand what is tested.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Assisted-by: Copilot (auto mode)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41945>
2026-06-07 21:36:57 +00:00
Gert Wollny
e083a06bf5 r600/sfn: Extract group fill failure handling
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Assisted-by: Copilot (auto mode)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41945>
2026-06-07 21:36:57 +00:00
Gert Wollny
2e9f035060 r600/sfn: pass reference to group when possible
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Assisted-by: Copilot (auto mode)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41945>
2026-06-07 21:36:57 +00:00
Gert Wollny
d654241931 r600/sfn: extract fill_alu_group
Assisted-by: Copilot (auto mode)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41945>
2026-06-07 21:36:56 +00:00
Gert Wollny
b7cd79ae3f r600/sfn: Extract schedule alu groups first
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Assisted-by: Copilot (auto mode)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41945>
2026-06-07 21:36:56 +00:00
Gert Wollny
ba7d7cd108 r600/sfn: don't use return parameters in extracted method
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Assisted-by: Copilot (auto mode)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41945>
2026-06-07 21:36:56 +00:00
Gert Wollny
7268a696d5 r600/sfn: Extract some helpers from schedule_alu
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Assisted-by: Copilot (auto mode)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41945>
2026-06-07 21:36:56 +00:00
Mike Blumenkrantz
6094bed5a4 llvmpipe: create a zeroed payload for use without task shaders
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
this is never accessed, but spec requires that mesh shaders
can declare it (which implicitly accesses it because llvm branching)

fixes dEQP-VK.mesh_shader.ext.misc.payload_not_accessed

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41963>
2026-06-07 19:30:41 +00:00
Vinson Lee
3515c52e8c ethosu/mlw_codec: silence -Wunused-const-variable in vendored encoder
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Compiling with clang produces a -Wunused-const-variable warning in the
weight codec vendored from Arm's Regor compiler:

  src/gallium/drivers/ethosu/mlw_codec/source/mlw_decode.cpp:313:15:
  warning: unused variable 'INITIAL_BLOCKS' [-Wunused-const-variable]

This warning is emitted only by clang, not by GCC, in the same vendored
mlw_codec sources whose other warnings are already suppressed at the
build-config level. Extend the existing cpp_args with
-Wno-unused-const-variable rather than patching the imported source, so
the files stay pristine for clean re-vendoring.

Fixes: d66d2c05d3 ("ethosu: Switch to the weight encoder from Regor")
Assisted-by: Claude Code (Claude Opus 4.8)
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42070>
2026-06-06 21:44:50 -07:00
Christian Gmeiner
b9c763454e etnaviv: Use integer texture formats for R32/RG32 integer textures
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
R32_SINT/UINT and R32G32_SINT/UINT are sampled as float, so a missing
channel is filled with a float default. A channel-expanding integer blit
then gets a float 1.0 alpha instead of integer 1, which fails 8 cases of
dEQP-GLES3.functional.fbo.blit.conversion such as rg32i_to_rgba8i.

The hardware support for integer texturing is unclear from RE and the
feature databases, so enable it on halti5 GPUs as a conservative
starting point.

Fixes: 64c7cdcae5 ("etnaviv: add missing formats")
Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41884>
2026-06-06 22:20:56 +00:00
Christian Gmeiner
7089c6710a etnaviv: Use the full 64-bit clear value for 64bpp render targets
A 64bpp color render target that is fast-cleared and then partially rendered
came back with its high 32-bit word wrong - the low clear word was duplicated
into both halves.

TS was never told the render target is 64bpp, so its fast-clear filled tiles
from a 32-bit clear value.

Helps with at least the following CTS:
 - dEQP-GLES3.functional.fbo.blit.default_framebuffer.rgba16f_nearest_scale_blit_from_default
 - dEQP-GLES3.functional.draw_buffers_indexed.random.max_implementation_draw_buffers.7

Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41909>
2026-06-06 22:02:04 +00:00
Christian Gmeiner
5080dddf2b etnaviv: Update headers from rnndb
Update to rnndb commit 7a829b97fc59

Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41909>
2026-06-06 22:02:04 +00:00
LingMan
e92c7efa21 rusticl: Drop custom addr implementation
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
It's been stabilized in Rust 1.84.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42065>
2026-06-06 17:17:11 +02:00
Vinson Lee
25930dbc34 ethosu/mlw_codec: silence warnings in the vendored Regor encoder
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
gcc reports two warnings in the weight encoder vendored from Arm's
Regor compiler (Ethos-U Vela):

  src/gallium/drivers/ethosu/mlw_codec/source/mlw_encode.cpp:224:9:
  warning: variable 'common_val' set but not used
  [-Wunused-but-set-variable]

  src/gallium/drivers/ethosu/mlw_codec/source/mlw_encode.cpp:426:33:
  warning: comparison of integer expressions of different signedness:
  'int' and 'long unsigned int' [-Wsign-compare]

These files are imported verbatim from upstream, so rather than patch
the vendored source (which would diverge from upstream and be lost on
the next re-import) silence the two known warnings at build-config
level via cpp_args on the mlw_codec static library. The suppression is
kept narrow so that any other warning introduced by a future re-vendor
still surfaces.

Fixes: d66d2c05d3 ("ethosu: Switch to the weight encoder from Regor")
Assisted-by: Claude Code (Claude Opus 4.8)
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42064>
2026-06-06 08:56:12 +00:00
Vinson Lee
bd402153af mesa/main: cast GLhandleARB to unsigned int in api trace
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
The generated api_trace.c passes GLhandleARB arguments to _mesa_debug()
with a "%u" conversion. On macOS GLhandleARB is unsigned long, so this
triggers -Werror=format and breaks the build:

  api_trace.c:5307:52: error: format specifies type 'unsigned int' but
  the argument has type 'GLhandleARB' (aka 'unsigned long')

Cast the value to unsigned int to match the "%u" conversion on all
platforms. GL handles fit in 32 bits, and on Linux GLhandleARB is
already unsigned int, so behavior is unchanged.

Fixes: 9f7f5a27a7 ("mesa/main: Auto-generate MESA_VERBOSE=api trace dispatch")
Assisted-by: Claude Code (Claude Opus 4.8)
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42059>
2026-06-05 23:43:49 -07:00
Connor Abbott
31db17f653 ir3: Implement round-robin workaround
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
On later a6xx and a7xx, round-robin does not work properly when there
are more than 8 active waves from the same dispatch in the same uSP. We
have to clamp the register usage to a minimum to guarantee there aren't
more waves. There is a problem for very large workgroups, which will
have to be solved the same way as the problem with deep control flow,
through implementing ReuseGPRMode.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41562>
2026-06-05 23:43:11 +00:00
Connor Abbott
25f7765d21 freedreno: Add round_robin_errata to device info
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41562>
2026-06-05 23:43:11 +00:00
Connor Abbott
3dc789215d tu: Add TU_DEBUG=computeroundrobin
This will be useful to check if games are hanging due to scheduler
fairness.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41562>
2026-06-05 23:43:11 +00:00
Connor Abbott
8a67ad65ae ir3, tu, freedreno: Plumb through round-robin mode
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41562>
2026-06-05 23:43:11 +00:00
Connor Abbott
61b0130291 freedreno: Document SP_CS_CNTL_0::COMPUTERRMODEEN
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41562>
2026-06-05 23:43:09 +00:00
Connor Abbott
c4165ef390 spirv: Implement concurrent workgroup hint from vkd3d-proton
This will signal shaders that require concurrent workgroup dispatch,
until we get a proper Vulkan extension.

Reviewed-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Danylo Piliaiev <danylo.piliaiev@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41562>
2026-06-05 23:43:09 +00:00
Connor Abbott
e6fc75c23d spirv: Use correct opcode in non-semantic OpExtInst handling
It seems we weren't actually using the opcode, but be consistent with
the other place we call OpExtInst handlers.

Reviewed-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Danylo Piliaiev <danylo.piliaiev@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41562>
2026-06-05 23:43:09 +00:00
Connor Abbott
1f7520680c spirv: Remove redundant OpExtInst handling
According to the SPIR-V spec OpExtInst cannot appear before types,
constants, and global variable declarations. We were handling it anyway,
which is wrong.

Reviewed-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Danylo Piliaiev <danylo.piliaiev@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41562>
2026-06-05 23:43:08 +00:00
Connor Abbott
a013713e3e compiler/shader_info: Introduce occupancy_bounded_workgroup_fairness
This encapsulates the forward progress guarantee required by PRAGMATA,
the so-called "occupancy bounded execution" over workgroups. On
Adreno we need to be aware of this and compile the shader differently.
There isn't yet a Vulkan extension for this, so we will set this via a
hack in coordination with vkd3d-proton.

Reviewed-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Danylo Piliaiev <danylo.piliaiev@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41562>
2026-06-05 23:43:06 +00:00
Gert Wollny
a9b8c4b5cc r600/sfn: run additional optimization only after successful address split
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Otherwise the shader was already fully optimized, so no need for further
optimization.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41907>
2026-06-05 22:41:05 +00:00
Gert Wollny
ff73701b12 r600/sfn: signal progress when splitting address loads
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41907>
2026-06-05 22:41:04 +00:00
Valentine Burley
1d829f3a89 panfrost/ci: Switch traces over to gpu-trace-perf
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Convert the two nightly panfrost trace replay jobs to @anholt's new GPU
trace snapshot comparison tool.

This allows running a few traces on t860 that couldn't be replayed
before.

Signed-off-by: Valentine Burley <valentine.burley@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42018>
2026-06-05 17:35:35 +00:00
Valentine Burley
0a65376b2e turnip/ci: Update ANGLE trace checksum
This changed with https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41419.

Signed-off-by: Valentine Burley <valentine.burley@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42042>
2026-06-05 17:06:35 +00:00
Natalie Vock
6a16319133 radv/rt: Cache stack sizes of ahit/isec shaders from imported NIR
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
We need to save the stack size here separately, because the library
doesn't have the ahit/isec shader that uses stack.

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42050>
2026-06-05 15:13:09 +00:00
Samuel Pitoiset
0ec4cc9cd5 vulkan: Update spec to 1.4.353
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42039>
2026-06-05 16:11:45 +02:00
Christian Gmeiner
9f7f5a27a7 mesa/main: Auto-generate MESA_VERBOSE=api trace dispatch
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
With the trace plumbing in place, fill in the wrappers from
gl_and_es_API.xml so the trace tracks new entrypoints.

Generated-by: Claude
Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41147>
2026-06-05 11:57:29 +00:00
Christian Gmeiner
d128c6f111 mesa/main: Add trace dispatch plumbing for MESA_VERBOSE=api
Reintroduce VERBOSE_API as a bit that will cause a parallel trace
dispatch table to be installed at context create. The table itself is
populated in a follow-up commit. This commit only wires the TLS-publish
indirection via _mesa_set_dispatch(..).

With Trace NULL (the common case), the helper is equivalent to a plain
_mesa_glapi_set_dispatch — no behaviour change yet.

Assisted-by: Claude
Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41147>
2026-06-05 11:57:29 +00:00
Erik Faye-Lund
1bd114d9c7 pan/ci: mark missing xfails
Fixes: 6425c6507e ("pan/ci: drop needless skips")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42030>
2026-06-05 11:39:31 +00:00
Samuel Pitoiset
24af1196c0 radv/amdgpu: destroy the BO for the NULL PRT workaround earlier
This caused a crash with RADV_DEBUG=bo_history because the logfile
was destroyed before.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/work_items/15608
Fixes: 41fa965386 ("radv/amdgpu: emulate sparse residency for the SMEM loads with NULL PRT workaround")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42011>
2026-06-05 11:15:56 +00:00
Samuel Pitoiset
e622cbee64 radv: fix a memory leak with perfcounters
radv_physical_device::perfcounters must be freed.

Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41991>
2026-06-05 10:51:48 +00:00
Samuel Pitoiset
c9acff31fb radv/rt: fix a memory leak with ahit/isec group
Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41991>
2026-06-05 10:51:48 +00:00
Samuel Pitoiset
68273972d8 radv/rt: fix a memory leak with the RT prolog NIR
radv_meta_nir_init_shader() allocates it and it must be freed.

Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41991>
2026-06-05 10:51:48 +00:00
Samuel Pitoiset
e247bdae0f radv/rt: fix a memory leak with hash tables
Found with ASAN.

Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41991>
2026-06-05 10:51:47 +00:00
Emma Anholt
b6661df5f0 vulkan: Enable GOOGLE_display_timing on KHR_display across multiple drivers.
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
This covers some drivers which expose KHR_display and EXT_present_timing.

Based on Emma Anholt's work from 2025, rebased on current Mesa 26.2-devel,
tiny compile fixes and docs/features updates by Mario Kleiner.
See MR 38472 for reference of Emma's work, based on Keith's work.

Tested locally on AMD Polaris for radv, Intel Kabylake for anv, and on
Mesa CI's VK-CTS VK_GOOGLE_display_timing test case for AMD radv,
Intel anv, Qualcomm Adreno tu.

Original code of Emma is
Reviewed-by: Mario Kleiner <mario.kleiner.de@gmail.com>

Update of docs/features.txt + new_features.txt updates is

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41168>
2026-06-05 10:21:51 +00:00
Mario Kleiner
b1c48c8f0e wsi/common: Add VK_GOOGLE_display_timing support for KHR_display.
This adds the common plumbing and support for the VK_GOOGLE_display_timing
extension. A followup commit will enable it for KHR_display. It should
also optionally work for suitable other backends like Wayland and X11
on suitable Wayland and X11 servers, if those servers and backends
mostly support VK_EXT_present_timing (minus the relative timing support,
which is not needed for this extension to work). However, fully conformant
use on Wayland or X11 is not possible, as the extension lacks the ability
to report per VKSurface capabilities wrt. timing. Therefore the extension
should only be enabled for Wayland or X11 via explicit opt-in, not by
default.

The extension provides two things:

 1) Detailed information about when frames are displayed, including
    slack time between GPU execution and display frame.

 2) Absolute time control over swapchain queue processing. This allows
    the application to request frames be displayed at specific
    absolute times, using the same timebase as that used in 1).

It is implemented on top of the VK_EXT_present_timing extension
infrastructure.

This code is inspired by Emma Anholt's work from late 2025, which itself
is based on Keith Packard's original work from 2018. Only a few lines of
their code is left though after an almost complete rewrite on top of
EXT_present_timing. Specifically calculation of .earliestPresentTime
and .presentMargin in fixed refresh rate (FRR) mode is based on Keith
original math, and the followup commit for driver enable is a modified
version of Emma's commit.

See MR 38472 for reference of Emma's work, based on Keith's work.

The final implementation as a whole is so far successfully tested on top
of an AMD Polaris gpu (radv), a Intel Kabylake gpu (anv), and Mesa CI
for direct display mode on AMD radv, Intel anv, and Qualcomm Adreno turnip.

Both VK_EXT_present_timing and VK_GOOGLE_display_timing can be enabled
at the same time on a VkDevice, but only one of the extensions can be
used on a given swapchain for that device. If both extensions are enabled
on a device and VK_EXT_present_timing is requested on some swapchains, it
will be used on those swapchains, whereas on all other swapchains the
VK_GOOGLE_display_timing will be used.

On drivers which don't support queue timestamps, reported values for
earliestPresentTime are identical to actualPresentTime, and presentMargin
is reported as zero, which is a reasonable fallback behaviour. Currently
drivers with this limitation would be pvr, panvk and kk.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41168>
2026-06-05 10:21:51 +00:00
Mario Kleiner
7215c4ef5f wsi/wayland: Unconditionally assign present_timing.time_domain.
This is a tiny simplification, which should not have any practical
differences, except for a tiny bit more simple enablement of
VK_GOOGLE_display_timing in a followup commit, and dropping one
line of code.

The time_domain can always be assigned, even if present_timing
is not enabled (and neither is GOOGLE_display_timing), because

1. The field isn't used if none of these extensions is enabled.
2. The field would default to a valid initial value of zero ==
   VK_TIME_DOMAIN_DEVICE_KHR anyway.
3. Even if wp_presentation_feedback is unavailable, and therefore
   presentation_clock_id has an "unknown clock" value of -1, the
   mapping through clock_id_to_vk_time_domain(-1) would again map
   to VK_TIME_DOMAIN_DEVICE_KHR.

Iow. with or without the dropped if statement, the field gets a
nominally valid value, and also a value that does not get used
can do no harm.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41168>
2026-06-05 10:21:51 +00:00
Mario Kleiner
3d43a0a05c wsi/common: Allow to return queue_done_time in host time domain.
wsi_swapchain_present_timing_sample_query_pool() queries the timestamp
queue_done_time, corresponding to VK_EXT_present_timing's present stage
VK_PRESENT_STAGE_QUEUE_OPERATIONS_END_BIT_EXT.

The time domain of returned timestamps depends on the number of
available bits for queue timestamps. The same timestamp is needed
as input to calculate timestamps and headroom for some elements
returned by VK_GOOGLE_display_timing, but that extension always
requires timestamps in the host time domain. To allow use of this
function also for a future implementation of GOOGLE_display_timing
in a followup commit, add a flag that asks to always return queue
timestamps in the host time domain.

The flag is set to false to keep current behaviour for use by
VK_EXT_present_timing.

Also clamp a returned queue_done_time in host time domain to the
provided upper_bound, as useful for upcoming GOOGLE_display_timing.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41168>
2026-06-05 10:21:51 +00:00
Mario Kleiner
2beb0c8820 wsi/common: Allow VK_EXT_present_timing present without presentStageQueries.
Spec allows to request a present at a specific target time or duration
without actually storing + querying any present records about completion
time. Iow. it allows VkPresentTimingInfoEXT.presentStageQueries == 0.

In this case, skip allocation and processing of a timing history record,
but still assign a VkPresentTimingInfoEXT.targetTime for timed present.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Fixes: 47d69664d8 ("vulkan/wsi: Add common infrastructure for EXT_present_timing.")
Reviewed-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41168>
2026-06-05 10:21:51 +00:00
Mario Kleiner
784a41cb8b wsi/common: Small compliance fixes for VK_EXT_present_timing.
- Queueing a present with VkPresentTimingsInfoEXT in the .pNext chain of
VkPresentInfoKHR, but VkPresentTimingsInfoEXT.pTimingInfos == NULL is
allowed and must not crash, just no-op.

- VkPresentTimingInfoEXT.targetTime == 0 means to ignore targetTime and
to simply present as soon as possible. This is achieved by setting
info->targetTime == 0 ==> target_time = 0. Make sure target_time stays
also 0 if targetTimeDomainPresentStage is set to
VK_PRESENT_STAGE_QUEUE_OPERATIONS_END_BIT_EXT, ie. skip the device->cpu
conversion via wsi_swapchain_present_convert_device_to_cpu(), as that
might map a zero info->targetTime device time to a non zero cpu
target_time.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Fixes: 47d69664d8 ("vulkan/wsi: Add common infrastructure for EXT_present_timing.")
Reviewed-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41168>
2026-06-05 10:21:51 +00:00
Mario Kleiner
d7b23e9f3a wsi/display: Deal with vblank-less systems for VK_EXT_present_timing.
Some hw + kms driver combos do not support vblank related functions
at all, ie. no drmCrtc[Get/Queue]Sequence() ioctl, no crtc sequence
events, no vblank of pageflip completion reported in pageflip events.

Most notable under the present_timing supported Vulkan drivers is
Asahi Linux on Apple Silicon Macs, with no such support: Only pageflip
events with a valid flip timestamp are supported.

To deal with this, we detect lack of vblank support and instead
use the current "vrr timing" path, which doesn't use vblanks, but
absolute time and timed waits. This also required a slight restructuring
of the setup logic.

Also fix semantics of requested relative timed presents via
VK_PRESENT_TIMING_INFO_PRESENT_AT_RELATIVE_TIME_BIT_EXT. The
spec states that the given target time should be relative to
the most recently presented image on a swapchain, and that if
no such image was presented yet (during the first present on
a swapchain), the relative target present time should be ignored.
Take care of this by tracking vblank count and time of the most
recent completed swapchain present separately from the most recent
known vblank count and time of the connector. Choose the swapchain
most recent present vblank data as baseline for relative timed
presents, to optimally implement spec semantics, but the connectors
vblank data for absolute timed presents to minimize rounding errors
and drift when converting between time and vblank cycle counts.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Fixes: 5e2814c8a4 ("wsi/display: Implement present timing on KHR_display.")
Reviewed-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41168>
2026-06-05 10:21:51 +00:00