vulkan: the depth24 conversion keeps its shader barriers on a copy queue (RT-DEPTH24-COPY-QUEUE-BARRIERS) #2469

Open
github-bot wants to merge 2 commits from github-bot/gh-2469 into main AGit
Owner

@⁠Tyrannys on GitHub · 2026-11-27 14:40 UTC · original
Tyrannys:rt-depth24-copy-queue-barriers → main · +110 −43 · 3 files · 2 commits · open

Claimed in the coordination issue as: RT-DEPTH24-COPY-QUEUE-BARRIERS (#1608)

What and why

Found by @⁠kevincommits in #1608 (#1608), thanks for the precise write-up.

A D3D12 copy queue whose Vulkan family can run compute also runs the depth24/rgb96 footprint conversion: depth24_prepare is installed whenever the family is not the transfer-only one. But that queue's replay uses queue_stages_copy, which has no COMPUTE_SHADER bit, so:

  • detail::restrict_to_queue zeroed the shader access of the four barriers around run_depth24 (dstAccessMask = 0 before the dispatch, srcAccessMask = 0 after it). The copy's writes were not made visible to the shader, nor the shader's writes to the copy or readback that follows.
  • The host-readback barrier masked COMPUTE_SHADER away and fell back to TRANSFER / TRANSFER_WRITE -> HOST, so the conversion's writes were not made available to the host.

This keeps the copy-queue conversion (which depth24_convert_test exercises) and fixes its barriers:

  • New detail::depth24_barrier: the barriers around the conversion's dispatch are restricted to the queue's stages plus COMPUTE_SHADER, the stage the dispatch already uses on that queue. restrict_to_queue and memory_barrier now go through restrict_to_stages / memory_barrier_within; every other barrier is unchanged.
  • The host-readback barrier in VulkanQueue allows COMPUTE_SHADER where depth24_prepare is installed.
  • queue_stages itself is unchanged, so the other compute paths stay refused on a copy queue.

depth24_convert_test now watches vkCmdPipelineBarrier through the context's device proc. On direct, compute and copy queues, the depth24 and rgb96 readbacks must have a barrier into the shader's reads and one out of its writes, and the host barrier must come from COMPUTE_SHADER / MEMORY_WRITE. The old test asserted the TRANSFER fallback on a copy queue; that assertion is replaced.

Staying apart from #1988 (Depth24Converter bounds); no shared files.

Tested

Windows 11, MSVC (VS 18), Vulkan SDK 1.4.341, RelWithDebInfo, on this branch merged with main (ec91d695c).

  • depth24_convert: passes, also with LEONIDA_VK_VALIDATION=1 (validation and sync validation on, no messages).
  • Negative control, new test against main's vulkan_backend.h and vulkan_replay.h: fails at to_shader_barriers >= 1 && from_shader_barriers >= 1 (the conversion's barriers lose their shader access). With only the replay half of the fix, it fails at host_src_stages == VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT (the host barrier). Both halves are needed.
  • Sync validation on SDK 1.4.341 does not flag main here either, matching @⁠kevincommits' note that 1.4.363 no longer flags it; the barrier check in the test is what catches it.
  • Related ctests (vk_*, depth24*, replay_*, d3d12_queue*, d3d12_*copy*, predicated_copy, guarded_copy, queue_proxy, xbox_present_readback_size), 84 tests: all pass except
    • d3d12_queue_handover, _two_queues, _shared_queue: failed only under ctest -j 4 load; pass when run alone.
    • vk_compile_gate_calibration: "no verdict on NVIDIA (unclear)" under load; passes alone (3/3).
    • vk_sync_validation: skipped.
  • vk_*, depth24*, replay_* with LEONIDA_VK_VALIDATION=1 (58 tests): all pass except vk_device_markers, which fails the same way on main (sync validation WRITE_AFTER_WRITE between two vkCmdWriteBufferMarker2AMD writes); unrelated to this change.

GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

**@⁠Tyrannys** on GitHub · 2026-11-27 14:40 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2469) `Tyrannys:rt-depth24-copy-queue-barriers` → `main` · +110 −43 · 3 files · 2 commits · open Claimed in the coordination issue as: RT-DEPTH24-COPY-QUEUE-BARRIERS (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why Found by @⁠kevincommits in #1608 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608), thanks for the precise write-up. A D3D12 copy queue whose Vulkan family can run compute also runs the depth24/rgb96 footprint conversion: `depth24_prepare` is installed whenever the family is not the transfer-only one. But that queue's replay uses `queue_stages_copy`, which has no `COMPUTE_SHADER` bit, so: - `detail::restrict_to_queue` zeroed the shader access of the four barriers around `run_depth24` (`dstAccessMask = 0` before the dispatch, `srcAccessMask = 0` after it). The copy's writes were not made visible to the shader, nor the shader's writes to the copy or readback that follows. - The host-readback barrier masked `COMPUTE_SHADER` away and fell back to `TRANSFER / TRANSFER_WRITE -> HOST`, so the conversion's writes were not made available to the host. This keeps the copy-queue conversion (which `depth24_convert_test` exercises) and fixes its barriers: - New `detail::depth24_barrier`: the barriers around the conversion's dispatch are restricted to the queue's stages plus `COMPUTE_SHADER`, the stage the dispatch already uses on that queue. `restrict_to_queue` and `memory_barrier` now go through `restrict_to_stages` / `memory_barrier_within`; every other barrier is unchanged. - The host-readback barrier in `VulkanQueue` allows `COMPUTE_SHADER` where `depth24_prepare` is installed. - `queue_stages` itself is unchanged, so the other compute paths stay refused on a copy queue. `depth24_convert_test` now watches `vkCmdPipelineBarrier` through the context's device proc. On direct, compute and copy queues, the depth24 and rgb96 readbacks must have a barrier into the shader's reads and one out of its writes, and the host barrier must come from `COMPUTE_SHADER / MEMORY_WRITE`. The old test asserted the `TRANSFER` fallback on a copy queue; that assertion is replaced. Staying apart from #1988 (Depth24Converter bounds); no shared files. ### Tested Windows 11, MSVC (VS 18), Vulkan SDK 1.4.341, RelWithDebInfo, on this branch merged with `main` (`ec91d695c`). - `depth24_convert`: passes, also with `LEONIDA_VK_VALIDATION=1` (validation and sync validation on, no messages). - Negative control, new test against `main`'s `vulkan_backend.h` and `vulkan_replay.h`: fails at `to_shader_barriers >= 1 && from_shader_barriers >= 1` (the conversion's barriers lose their shader access). With only the replay half of the fix, it fails at `host_src_stages == VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT` (the host barrier). Both halves are needed. - Sync validation on SDK 1.4.341 does not flag `main` here either, matching @⁠kevincommits' note that 1.4.363 no longer flags it; the barrier check in the test is what catches it. - Related ctests (`vk_*`, `depth24*`, `replay_*`, `d3d12_queue*`, `d3d12_*copy*`, `predicated_copy`, `guarded_copy`, `queue_proxy`, `xbox_present_readback_size`), 84 tests: all pass except - `d3d12_queue_handover`, `_two_queues`, `_shared_queue`: failed only under `ctest -j 4` load; pass when run alone. - `vk_compile_gate_calibration`: "no verdict on NVIDIA (unclear)" under load; passes alone (3/3). - `vk_sync_validation`: skipped. - `vk_*`, `depth24*`, `replay_*` with `LEONIDA_VK_VALIDATION=1` (58 tests): all pass except `vk_device_markers`, which fails the same way on `main` (sync validation `WRITE_AFTER_WRITE` between two `vkCmdWriteBufferMarker2AMD` writes); unrelated to this change. GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11 AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A D3D12 copy queue on a compute-capable Vulkan family runs the depth24/rgb96
footprint conversion (depth24_prepare is installed whenever the family is not
the transfer-only one), but its replay's queue_stages are queue_stages_copy,
which have no COMPUTE_SHADER bit. restrict_to_queue then zeroed the shader
access of the four barriers around run_depth24, and the host-readback barrier
was masked down to TRANSFER, so neither the copy's writes reached the
dispatch nor the dispatch's writes the host. Found by kevincommits in #1608.

- detail::depth24_barrier: the barriers around the conversion's dispatch are
  restricted to the queue's stages plus COMPUTE_SHADER, the stage the
  dispatch already needs on that queue. restrict_to_queue and memory_barrier
  now take their stages through restrict_to_stages/memory_barrier_within;
  every other barrier is unchanged.
- The host-readback barrier allows COMPUTE_SHADER where depth24_prepare is
  installed.
- queue_stages itself is unchanged, so the other compute paths stay refused on
  a copy queue.

depth24_convert_test watches vkCmdPipelineBarrier through the context's
device proc: on every queue kind, the depth24 and rgb96 readbacks must have a
barrier into the shader's reads and one out of its writes, and the host
barrier must come from COMPUTE_SHADER/MEMORY_WRITE. Both checks fail on main.

AI-assisted (Claude Code)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 14:46:00 +00:00
Author
Owner

@⁠lixonik on GitHub · 2026-11-27 15:20 UTC · original · reviewed

Reviewed and tested at 0e204a9ab (merged cleanly onto main ec91d695c).

Clean, targeted fix:

  • Confirmed replay.depth24_prepare is only installed when !transfer_only (runtime/src/vulkan_backend.h:3388), so adding VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT to allowed for host-readback visibility on copy queues is safe even on GPUs with a dedicated transfer-only queue family.
  • Confirmed copy_depth_uav() (runtime/src/vulkan_replay.h:3536) already refuses queues whose vk.queue_stages omits COMPUTE_SHADER_BIT, so the four CopyTextureRegion depth24/rgb96 barriers updated to depth24_barrier() are the only ones reachable on a copy queue.
  • Minor test-coverage note: watch_dispatch_barriers in depth24_convert_test.cpp currently checks the image-->buffer readback dispatches on a copy queue; asserting to_shader_barriers / from_shader_barriers on a buffer-->image upload on a copy queue too would cover both halves of the vulkan_replay.h change.

Verified locally on Windows 11 (MSVC 19.44.35230.0, Ninja Release, NVIDIA GeForce RTX 5070, driver 610.88, Vulkan 1.4.341; note VK_LAYER_KHRONOS_validation is not installed locally so Vulkan validation layers did not run):

  • depth24_convert (GPU): passed (all 10 sub-checks including the new copy-queue shader barrier and host-readback visibility assertions)
  • scripts/check_no_game_data.py and git diff --check: clean

No blocking findings.

AI-assisted.

**@⁠lixonik** on GitHub · 2026-11-27 15:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2469#pullrequestreview-6090272415) · **reviewed** Reviewed and tested at `0e204a9ab` (merged cleanly onto `main` `ec91d695c`). Clean, targeted fix: - Confirmed `replay.depth24_prepare` is only installed when `!transfer_only` (`runtime/src/vulkan_backend.h:3388`), so adding `VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT` to `allowed` for host-readback visibility on copy queues is safe even on GPUs with a dedicated transfer-only queue family. - Confirmed `copy_depth_uav()` (`runtime/src/vulkan_replay.h:3536`) already refuses queues whose `vk.queue_stages` omits `COMPUTE_SHADER_BIT`, so the four `CopyTextureRegion` depth24/rgb96 barriers updated to `depth24_barrier()` are the only ones reachable on a copy queue. - Minor test-coverage note: `watch_dispatch_barriers` in `depth24_convert_test.cpp` currently checks the image-->buffer readback dispatches on a copy queue; asserting `to_shader_barriers` / `from_shader_barriers` on a buffer-->image upload on a copy queue too would cover both halves of the `vulkan_replay.h` change. Verified locally on Windows 11 (MSVC 19.44.35230.0, Ninja Release, NVIDIA GeForce RTX 5070, driver 610.88, Vulkan 1.4.341; note `VK_LAYER_KHRONOS_validation` is not installed locally so Vulkan validation layers did not run): - `depth24_convert` (GPU): passed (all 10 sub-checks including the new copy-queue shader barrier and host-readback visibility assertions) - `scripts/check_no_game_data.py` and `git diff --check`: clean No blocking findings. AI-assisted.
Author
Owner

@⁠djrolfes on GitHub · 2026-11-27 15:26 UTC · original

Independent Linux/Wine + NVIDIA check at head 0e204a9ab (merged cleanly onto origin/main ec91d695c in a local integration stack alongside #2467, #2463, #2470, #2461, #2126, #2091, and two local V# patches).

  • Environment: Linux 7.2.15, wine-11.22, clang-cl + xwin cross-build, NVIDIA GeForce RTX 3070 Ti 8 GB, driver 620.73.04, Ryzen 7 5800X, 32 GB RAM. No game files.
  • CTest: depth24_convert passed (14.66 s) on RTX 3070 Ti under Wine (all 10 checks including host-readback visibility barriers, shared-buffer offsets, and concurrent VulkanQueue::execute).
  • Code review: depth24_barrier cleanly preserves VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT for copy queues running on compute-capable families without widening unrelated transfer barriers.

AI-assisted.

**@⁠djrolfes** on GitHub · 2026-11-27 15:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2469#issuecomment-7222060740) Independent Linux/Wine + NVIDIA check at head `0e204a9ab` (merged cleanly onto `origin/main` `ec91d695c` in a local integration stack alongside `#2467`, `#2463`, `#2470`, `#2461`, `#2126`, `#2091`, and two local V# patches). - **Environment:** Linux `7.2.15`, `wine-11.22`, `clang-cl` + `xwin` cross-build, NVIDIA GeForce RTX 3070 Ti 8 GB, driver `620.73.04`, Ryzen 7 5800X, 32 GB RAM. No game files. - **CTest:** `depth24_convert` **passed** (`14.66 s`) on RTX 3070 Ti under Wine (all 10 checks including host-readback visibility barriers, shared-buffer offsets, and concurrent `VulkanQueue::execute`). - **Code review:** `depth24_barrier` cleanly preserves `VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT` for copy queues running on compute-capable families without widening unrelated transfer barriers. AI-assisted.
Author
Owner

@⁠Tauwni on GitHub · 2026-11-27 16:17 UTC · original

Tested on a Mac under Wine. On Macs every D24 depth target takes this conversion path: neither MoltenVK nor KosmicKrisp has D24_UNORM_S8_UINT, so it's D32 there.

Tree depth24_convert d3d12_d24_support d3d12_depth24_draw
main pass pass pass
this PR's depth24_convert_test.cpp on main, no fix fail: line 635: to_shader_barriers >= 1 && from_shader_barriers >= 1 pass pass
main + this PR pass pass pass

GPUs tested: Apple M3 (profile S), macOS 26.5.1, Wine 11.0 (WineHQ macOS build) with its MoltenVK 1.4.1, clang-cl/lld-link 23.1.6 cross build, main ec91d695c. No game files. MEASURED, 1 run each.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠Tauwni** on GitHub · 2026-11-27 16:17 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2469#issuecomment-7223090646) Tested on a Mac under Wine. On Macs every D24 depth target takes this conversion path: neither MoltenVK nor KosmicKrisp has `D24_UNORM_S8_UINT`, so it's D32 there. | Tree | `depth24_convert` | `d3d12_d24_support` | `d3d12_depth24_draw` | |---|---|---|---| | `main` | pass | pass | pass | | this PR's `depth24_convert_test.cpp` on `main`, no fix | **fail**: `line 635: to_shader_barriers >= 1 && from_shader_barriers >= 1` | pass | pass | | `main` + this PR | pass | pass | pass | GPUs tested: Apple M3 (profile S), macOS 26.5.1, Wine 11.0 (WineHQ macOS build) with its MoltenVK 1.4.1, clang-cl/lld-link 23.1.6 cross build, `main` `ec91d695c`. No game files. MEASURED, 1 run each. AI-assisted (Claude Code, Claude Opus 5.5).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2469/head:github-bot/gh-2469'
git switch 'github-bot/gh-2469'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2469'
git switch 'github-bot/gh-2469'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2469'
git switch 'github-bot/gh-2469'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2469'
git switch 'main'
git merge --squash 'github-bot/gh-2469'
git switch 'main'
git merge --ff-only 'github-bot/gh-2469'
git switch 'main'
git merge 'github-bot/gh-2469'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.