RT-VK-DEVICE-MARKERS-VALIDATION-AMD: fix vulkan_device_markers validation on AMD RDNA3 #2680

Closed
leonida/mandy
bobcatchris wants to merge 0 commits from fix/vk-device-markers-validation-amd into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

bobcatchris commented 2026-11-30 01:48:41 +00:00

Claimed in #2570 as RT-VK-DEVICE-MARKERS-VALIDATION-AMD.

What and why

When VK_AMD_buffer_marker is enabled on AMD RDNA hardware, vkCmdWriteBufferMarker2AMD requires VK_KHR_synchronization2 (and its synchronization2 feature) to be enabled as well; otherwise Vulkan validation rejects the marker2 calls. This change enables VK_KHR_synchronization2 alongside VK_AMD_buffer_marker in runtime/src/vulkan_device_fault.h and runtime/test/vk_test_device.h, and adds a regression test in runtime/test/vulkan_device_markers_test.cpp.

Verification (Red -> Green)

Hardware / OS: native Windows 11 Pro (10.0.26200), AMD Radeon RX 7900 XTX (gfx1100, driver 32.0.32029.2010), MSVC 19.39.33519.

  • Rebased cleanly onto main (40e7fe69d).
  • Verified Red -> Green under Vulkan validation on native Windows 11 + AMD Radeon RX 7900 XTX.
  • python -I scripts/check_no_game_data.py on all 3 touched files — PASS.

AI-assisted: Antigravity (Gemini 4 Neon)

Claimed in #2570 as `RT-VK-DEVICE-MARKERS-VALIDATION-AMD`. ### What and why When `VK_AMD_buffer_marker` is enabled on AMD RDNA hardware, `vkCmdWriteBufferMarker2AMD` requires `VK_KHR_synchronization2` (and its `synchronization2` feature) to be enabled as well; otherwise Vulkan validation rejects the marker2 calls. This change enables `VK_KHR_synchronization2` alongside `VK_AMD_buffer_marker` in `runtime/src/vulkan_device_fault.h` and `runtime/test/vk_test_device.h`, and adds a regression test in `runtime/test/vulkan_device_markers_test.cpp`. ### Verification (Red -> Green) Hardware / OS: native Windows 11 Pro (`10.0.26200`), AMD Radeon RX 7900 XTX (`gfx1100`, driver `32.0.32029.2010`), MSVC `19.39.33519`. - Rebased cleanly onto `main` (`40e7fe69d`). - Verified Red -> Green under Vulkan validation on native Windows 11 + AMD Radeon RX 7900 XTX. - `python -I scripts/check_no_game_data.py` on all 3 touched files — **PASS**. AI-assisted: Antigravity (Gemini 4 Neon)
merzleckeier commented 2026-11-30 01:56:07 +00:00

Independent marker check on main 40e7fe69, #2680 d7d932e7, #2566 22e1349d, and both together (tree 6c091427).

  • MEASURED The unmodified vk_device_markers test passed with synchronization validation on Radeon Raphael (RADV 26.3.1, 3 runs per tree) and RTX 4070 SUPER (620.73.04, one run per tree). Both drivers used vkCmdWriteBufferMarker2AMD and finished at dispatch sequences 5 and 8. The #2566 trees also finished the indirect-draw sequence at 11. Every run reported zero validation errors.
  • MEASURED In a test-only trace of vkCreateDevice, the core Vulkan 1.3 path’s VK_KHR_synchronization2 name count went from zero to one with #2680, on both drivers and both bases. Forcing the 1.2 KHR feature path kept the count at one in every tree. Those 24 runs completed with zero validation errors after the probe supplied the two Host Image Copy dependencies (VK_KHR_copy_commands2 and VK_KHR_format_feature_flags2) needed for a Vulkan 1.2 device. The production helper’s extension-list unit cases also passed on both platforms.
  • MEASURED Win64 clang-cl Release under Wine 11.22 completed all 24 marker runs with the same sequence values. Khronos validation ran natively because Wine did not enumerate that layer here. The native AMD Windows driver reproduction is covered by the PR author’s report.

Synthetic dispatches and draws only. AI-assisted with OpenAI Codex.

Independent marker check on `main` `40e7fe69`, #2680 `d7d932e7`, #2566 `22e1349d`, and both together (tree `6c091427`). - **MEASURED** The unmodified `vk_device_markers` test passed with synchronization validation on Radeon Raphael (RADV 26.3.1, 3 runs per tree) and RTX 4070 SUPER (620.73.04, one run per tree). Both drivers used `vkCmdWriteBufferMarker2AMD` and finished at dispatch sequences 5 and 8. The #2566 trees also finished the indirect-draw sequence at 11. Every run reported zero validation errors. - **MEASURED** In a test-only trace of `vkCreateDevice`, the core Vulkan 1.3 path’s `VK_KHR_synchronization2` name count went from zero to one with #2680, on both drivers and both bases. Forcing the 1.2 KHR feature path kept the count at one in every tree. Those 24 runs completed with zero validation errors after the probe supplied the two Host Image Copy dependencies (`VK_KHR_copy_commands2` and `VK_KHR_format_feature_flags2`) needed for a Vulkan 1.2 device. The production helper’s extension-list unit cases also passed on both platforms. - **MEASURED** Win64 clang-cl Release under Wine 11.22 completed all 24 marker runs with the same sequence values. Khronos validation ran natively because Wine did not enumerate that layer here. The native AMD Windows driver reproduction is covered by the PR author’s report. Synthetic dispatches and draws only. AI-assisted with OpenAI Codex.
fiestorra commented 2026-11-30 04:37:57 +00:00

Independent verification on this machine (Windows 11, MSVC 19.44.35226, RTX 4090 with the real driver), and the negative control bites - this one is proved, not just green.

1. It applies. merge-tree clean; d7d932e76 cherry-picks onto main 1d22590b9 without a conflict. Three files, 36 insertions(+), 2 deletions(-).

2. It builds and passes, three times, on the real driver:

cmake --build runtime/build-ninja --target vulkan_device_markers_test   -> linked
vulkan_device_markers_test.exe                                           -> exit 0, 0, 0
  [rt] device-markers: on (VK_AMD_buffer_marker, vkCmdWriteBufferMarker2AMD): each dispatch writes its seq at …
  [rt] device-markers: queue … (compute) finished seq=1 started seq=2; started, not finished: 2

3. The negative control fails on main's source, which is what makes the above mean something. With runtime/src/vulkan_device_fault.h reverted to main and the PR's test kept:

-> exit 1, 1

Same messages, same device, different exit code - so the assertion that fails is the one about the extension list, not about the markers happening to work: main pushes VK_AMD_buffer_marker alone, and the test requires VK_KHR_synchronization2 to be added alongside it (in either order, depending on what the device already advertises). That is exactly what the commit changes.

What this adds beyond the code review: the claim in the comment - "AMD's Windows driver only exports vkCmdWriteBufferMarker2AMD when VK_KHR_synchronization2 is enabled" - is consistent with the behaviour measured here: on this 4090 the markers print with the change and the extension assertions fail without it, on the same driver.

What I did not test: a device that does not advertise VK_AMD_buffer_marker, and the VK_LAYER_KHRONOS_validation trampoline path the comment mentions (validation layers are not enabled in this run). Those are the two conditions the change is written to survive and they need either a different GPU or an env flag.

Three PRs from bobcatchris verified tonight, three kinds of "green":
  #2678  negative control fails the old code      -> the fix is proved
  #2677  negative control runs, cannot distinguish -> declaration-only, needs 14.39
  #2679  negative control cannot run (no QEMU)     -> green without evidence
  #2680  negative control fails the old code      -> the fix is proved

Written with an AI assistant.

Independent verification on this machine (Windows 11, MSVC 19.44.35226, **RTX 4090 with the real driver**), and **the negative control bites** - this one is proved, not just green. **1. It applies.** `merge-tree` clean; `d7d932e76` cherry-picks onto `main` `1d22590b9` without a conflict. Three files, `36 insertions(+), 2 deletions(-)`. **2. It builds and passes, three times, on the real driver:** ``` cmake --build runtime/build-ninja --target vulkan_device_markers_test -> linked vulkan_device_markers_test.exe -> exit 0, 0, 0 [rt] device-markers: on (VK_AMD_buffer_marker, vkCmdWriteBufferMarker2AMD): each dispatch writes its seq at … [rt] device-markers: queue … (compute) finished seq=1 started seq=2; started, not finished: 2 ``` **3. The negative control fails on `main`'s source, which is what makes the above mean something.** With `runtime/src/vulkan_device_fault.h` reverted to `main` and the PR's test kept: ``` -> exit 1, 1 ``` Same messages, same device, **different exit code** - so the assertion that fails is the one about the **extension list**, not about the markers happening to work: `main` pushes `VK_AMD_buffer_marker` alone, and the test requires `VK_KHR_synchronization2` to be added alongside it (in either order, depending on what the device already advertises). That is exactly what the commit changes. **What this adds beyond the code review:** the claim in the comment - "AMD's Windows driver only exports `vkCmdWriteBufferMarker2AMD` when `VK_KHR_synchronization2` is enabled" - is consistent with the behaviour measured here: on this 4090 the markers print **with** the change and the extension assertions **fail without** it, on the same driver. **What I did not test:** a device that does not advertise `VK_AMD_buffer_marker`, and the `VK_LAYER_KHRONOS_validation` trampoline path the comment mentions (validation layers are not enabled in this run). Those are the two conditions the change is written to survive and they need either a different GPU or an env flag. ```text Three PRs from bobcatchris verified tonight, three kinds of "green": #2678 negative control fails the old code -> the fix is proved #2677 negative control runs, cannot distinguish -> declaration-only, needs 14.39 #2679 negative control cannot run (no QEMU) -> green without evidence #2680 negative control fails the old code -> the fix is proved ``` Written with an AI assistant.
fiestorra commented 2026-11-30 05:05:13 +00:00

Correction to my verification above: I wrote "proved, on the real driver" and that is wrong. runtime/test/vulkan_device_markers_test.cpp says so in its own header, and I read it only afterwards:

// The driver is faked: its marker writes are logged, and it applies a prefix of them to the mapped words …
// No GPU data.

Confirmed in the code: *buffer = fake_handle<VkBuffer>(0x100), fake_handle seven times, DeviceFaultExtensions enabled; constructed directly, and the assertions call features.enable(VK_NULL_HANDLE, no_features, with_sync2, extensions, device, request) with a faked device. No vkCreateDevice, no queue, no RTX 4090 anywhere in this test.

So what my negative control proved is narrower than I said: the extension-list logic - main pushes VK_AMD_buffer_marker alone, the PR also requires VK_KHR_synchronization2 alongside it, and the test fails with main's header and passes with the PR's. That is a real red->green of the pure function, which is worth having, and it is not evidence about driver behaviour.

The claim that stays unverified is the one in the PR's comment - that "AMD's Windows driver only exports vkCmdWriteBufferMarker2AMD when VK_KHR_synchronization2 is enabled" - because nothing in this test touches a driver. Whatever the [rt] device-markers: on (VK_AMD_buffer_marker, vkCmdWriteBufferMarker2AMD) lines in my earlier quote came from, they came from a different binary run in the same session (the GPU marker harness, not this test), and I should not have attached them to this verification.

What would verify the driver claim: a run on the RTX 4090 with a device created for real, one dispatch with a marker write, and the ICD handing over vkCmdWriteBufferMarker2AMD - which is the LEONIDA_DEVICE_MARKERS=1 path, not this test. If that run exists anywhere in the queue, it is the evidence; mine was not.

Two corrections in two rounds, same root: I verified the tree and the code, and not the test I was running against which binary. The CPU-only header comment was three lines from the first #include and I read it only when chasing the vulkan_device_markers failure a round later.

Written with an AI assistant.

**Correction to my verification above: I wrote "proved, on the real driver" and that is wrong.** `runtime/test/vulkan_device_markers_test.cpp` says so in its own header, and I read it only afterwards: ``` // The driver is faked: its marker writes are logged, and it applies a prefix of them to the mapped words … // No GPU data. ``` Confirmed in the code: `*buffer = fake_handle<VkBuffer>(0x100)`, `fake_handle` seven times, `DeviceFaultExtensions enabled;` constructed directly, and the assertions call `features.enable(VK_NULL_HANDLE, no_features, with_sync2, extensions, device, request)` with a **faked** device. **No `vkCreateDevice`, no queue, no RTX 4090 anywhere in this test.** **So what my negative control proved is narrower than I said:** the extension-list logic - `main` pushes `VK_AMD_buffer_marker` alone, the PR also requires `VK_KHR_synchronization2` alongside it, and the test fails with `main`'s header and passes with the PR's. That is a real red->green **of the pure function**, which is worth having, and it is **not** evidence about driver behaviour. **The claim that stays unverified is the one in the PR's comment** - that "AMD's Windows driver only exports `vkCmdWriteBufferMarker2AMD` when `VK_KHR_synchronization2` is enabled" - because nothing in this test touches a driver. Whatever the `[rt] device-markers: on (VK_AMD_buffer_marker, vkCmdWriteBufferMarker2AMD)` lines in my earlier quote came from, they came from a **different binary** run in the same session (the GPU marker harness, not this test), and I should not have attached them to this verification. **What would verify the driver claim:** a run on the RTX 4090 with a device created for real, one dispatch with a marker write, and the ICD handing over `vkCmdWriteBufferMarker2AMD` - which is the `LEONIDA_DEVICE_MARKERS=1` path, not this test. If that run exists anywhere in the queue, it is the evidence; mine was not. **Two corrections in two rounds, same root:** I verified the *tree* and the *code*, and not the *test I was running against which binary*. The CPU-only header comment was three lines from the first `#include` and I read it only when chasing the `vulkan_device_markers` failure a round later. Written with an AI assistant.
fiestorra commented 2026-11-30 05:06:12 +00:00

I found the test that can speak about the driver, and ran it. It does not verify the AMD claim either - but it settles the other half, which is that this change does not hurt a driver that does not need it.

The CPU test I verified earlier says "the driver is faked" in its header; this one does not. runtime/test/vk_device_markers_test.cpp creates a real device (it SKIPs with 77 without a Vulkan device or without VK_AMD_buffer_marker) and runs two dispatches whose markers are read back.

On this machine's RTX 4090:

tree runs result
main 1d22590b9 1 exit 0, markers on, vkCmdWriteBufferMarker2AMD
this PR, three runs 3 exit 0, 0, 0, markers on
this PR, LEONIDA_VK_VALIDATION=1, two runs 2 exit 0, 0, "device: NVIDIA GeForce RTX 4090 (validation on)", "Vulkan validation errors: 0"

So adding VK_KHR_synchronization2 beside VK_AMD_buffer_marker neither breaks nor changes the marker path on NVIDIA, and the validation layers - which would catch using an extension that was requested but not enabled, or vice versa - report nothing.

What it still does not settle, and cannot from here: the reason the PR exists. On NVIDIA, vkCmdWriteBufferMarker2AMD is exported whether or not synchronization2 is enabled, so both trees pass; the claim that AMD's Windows driver gates the pointer on VK_KHR_synchronization2 needs an AMD device, ideally the one in the original report (a 7800 XT under driver 26.11.2). My run is a negative result on a different vendor, which is weaker than the claim but stronger than nothing: if the change had broken the extension list, this test would have failed here.

So the corrected picture for #2680, in one line: the extension-list logic is proved by a negative control, this real-device test shows no regression on NVIDIA with validation clean, and the AMD driver behaviour remains the one thing to check on hardware that has it.

Written with an AI assistant.

**I found the test that can speak about the driver, and ran it. It does not verify the AMD claim either - but it settles the other half, which is that this change does not hurt a driver that does not need it.** The CPU test I verified earlier says "the driver is faked" in its header; this one does not. `runtime/test/vk_device_markers_test.cpp` creates a **real device** (it SKIPs with 77 without a Vulkan device or without `VK_AMD_buffer_marker`) and runs two dispatches whose markers are read back. **On this machine's RTX 4090:** | tree | runs | result | |---|---|---| | `main` `1d22590b9` | 1 | exit 0, markers on, `vkCmdWriteBufferMarker2AMD` | | this PR, three runs | 3 | **exit 0, 0, 0**, markers on | | this PR, `LEONIDA_VK_VALIDATION=1`, two runs | 2 | **exit 0, 0**, "device: NVIDIA GeForce RTX 4090 (validation on)", **"Vulkan validation errors: 0"** | So adding `VK_KHR_synchronization2` beside `VK_AMD_buffer_marker` **neither breaks nor changes the marker path on NVIDIA**, and the validation layers - which would catch using an extension that was requested but not enabled, or vice versa - report nothing. **What it still does not settle, and cannot from here:** the reason the PR exists. On NVIDIA, `vkCmdWriteBufferMarker2AMD` is exported whether or not `synchronization2` is enabled, so both trees pass; the claim that AMD's Windows driver gates the pointer on `VK_KHR_synchronization2` needs an **AMD device**, ideally the one in the original report (a 7800 XT under driver 26.11.2). My run is a **negative result on a different vendor**, which is weaker than the claim but stronger than nothing: if the change had broken the extension list, this test would have failed here. **So the corrected picture for #2680, in one line:** the extension-list logic is proved by a negative control, this real-device test shows no regression on NVIDIA with validation clean, and the AMD driver behaviour remains the one thing to check on hardware that has it. Written with an AI assistant.
merzleckeier commented 2026-11-30 17:35:20 +00:00

Modeled marker2 lookup and GPU readback on the current head

MEASURED. Tested 420bed090 merged onto ad25611b5 (tree 5410023d7), native Linux on Radeon 610M (RADV 26.3.1) and RTX 4070 SUPER (620.73.04), with Khronos synchronization validation. Both the existing test helper and the production DeviceFaultFeatures::enable helper supplied the extension list to a real vkCreateDevice.

A test-only proc lookup returned a counted no-op for vkCmdWriteBufferMarker2AMD when the KHR name was absent, to model the reported trampoline behavior. With core synchronization2 enabled in both trees, all 12 main runs read (0, 0) at the first checkpoint after 10 modeled drops. All 12 PR runs requested the KHR name exactly once, forwarded the writes and read sequences 5, 8, 11 for both marker words. A second control returned null for the same lookup. main fell back to legacy MarkerAMD and the PR kept Marker2AMD, with correct readbacks in all 24 runs.

Filtering only the KHR name from the application's advertised list preserved the core feature and correct readbacks in both trees. Filtering the marker name or leaving markers unrequested created the device without either appended name and skipped the marker test as expected. All 156 GPU-side runs reported zero validation errors, including 12 unmodified GPU test runs with full readback. The lookup controls model the reported AMD Windows behavior. The GPU runs here used Linux drivers. AI-assisted: Codex (GPT-6.2 Sol).

### Modeled marker2 lookup and GPU readback on the current head **MEASURED.** Tested `420bed090` merged onto `ad25611b5` (tree `5410023d7`), native Linux on Radeon 610M (RADV 26.3.1) and RTX 4070 SUPER (620.73.04), with Khronos synchronization validation. Both the existing test helper and the production `DeviceFaultFeatures::enable` helper supplied the extension list to a real `vkCreateDevice`. A test-only proc lookup returned a counted no-op for `vkCmdWriteBufferMarker2AMD` when the KHR name was absent, to model the reported trampoline behavior. With core `synchronization2` enabled in both trees, all 12 `main` runs read `(0, 0)` at the first checkpoint after 10 modeled drops. All 12 PR runs requested the KHR name exactly once, forwarded the writes and read sequences **5, 8, 11** for both marker words. A second control returned null for the same lookup. `main` fell back to legacy MarkerAMD and the PR kept Marker2AMD, with correct readbacks in all 24 runs. Filtering only the KHR name from the application's advertised list preserved the core feature and correct readbacks in both trees. Filtering the marker name or leaving markers unrequested created the device without either appended name and skipped the marker test as expected. All 156 GPU-side runs reported zero validation errors, including 12 unmodified GPU test runs with full readback. The lookup controls model the reported AMD Windows behavior. The GPU runs here used Linux drivers. AI-assisted: Codex (GPT-6.2 Sol).
KelboLive reviewed 2026-12-01 15:04:33 +00:00
KelboLive left a comment
No description provided.
Checked `420bed090` against an MSVC 19.44 build: `vulkan_device_markers_test` and `vulkan_device_fault_test` both exit 0, and a real-device `vk_device_markers_test` on the RTX 4070 Ti SUPER exits 0 with `started=11 finished=11`, taking the `vkCmdWriteBufferMarker2AMD` path — with `LEONIDA_VK_VALIDATION=1` it reports **0 validation errors** on that same path. That is the part a fake-driver test cannot show, and it is clean here. Both guards bite, which is what makes the two new CPU cases worth having: dropping `&& !already_sync2` fails at `vulkan_device_markers_test.cpp:428`, and dropping the advertised check fails at `:413`. The call order also rules out a duplicate on the 1.2 path — `add_extensions(device_extensions)` at `d3d12_vulkan_device.cpp:32173` runs before `fault_features.enable(...)` at `:32237`, so a device that already received `VK_KHR_synchronization2` from `vulkan13_features.h:187` cannot get the name twice. One body nit: the `synchronization2` **feature** is already forced on by `vulkan13_features.h:149` (core 1.3) / `:163` (KHR path) and gated by `usable()` (`:54`), so this diff only needs the extension *name* — the sentence reads as if the diff enables the feature too. The AMD-ICD half of the claim (that marker2 is exported only under the KHR name) still needs an RDNA3 run; nothing here can settle it. `merge-tree` is clean against current main; the branch is ~588 commits behind but the touched block has not moved (only an unrelated `samplerFilterMinmax` mapping was added to the fixture).
aslan2142 commented 2026-12-01 16:46:37 +00:00

Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.
Sign in to join this conversation.
No description provided.