Skip to content

Runtime: support RGB96 footprint copies on dedicated COPY queues - #4817

Open
gabrielsteglich wants to merge 2 commits into
ItsNotRexed:mainfrom
gabrielsteglich:fix/rgb96-copy-queue
Open

gabrielsteglich wants to merge 2 commits into
ItsNotRexed:mainfrom
gabrielsteglich:fix/rgb96-copy-queue

Conversation

@gabrielsteglich

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue #4683.

Depends on: #4107, #3481, #4577 for merge-order conflicts. This branch builds directly on main (98fa503f).

What and why

A standard RGB96 buffer–texture copy needs compute to repack 12-byte D3D12 texels into the 16-byte Vulkan image format. On a dedicated transfer-only family, submit the affected logical COPY batch on the primary compute-capable queue. Ordinary COPY batches still use the dedicated family. Cross-queue handoffs wait on the previous COPY timeline ticket, including handoffs involving fence signals and sparse binds. Keep the compute write in the readback-to-host barrier and share conversion scratch across the queue families that use it.

This change covers standard RGB96 footprints. The emulated D24-only path on a transfer-only family remains unsupported.

Tested

Head 71821118 against main at 98fa503f.

Windows 11 Pro 26300, Visual Studio 2022 Build Tools (MSVC 19.44.35229, Windows SDK 10.0.26100.0), Vulkan SDK 1.4.363.0, NVIDIA GeForce RTX 3090 on 621.01, x64 RelWithDebInfo, with core and synchronization validation enabled.

  • d3d12_rgb96_copy_queue matched 420 texel bytes and 1,436 sentinels for a 7×5 texture and an offset 3×3 patch. It exercises DIRECT → COPY → DIRECT waits on both a dedicated family and a shared primary queue.
  • The Vulkan API trace showed COPY work going from family 1 (ordinary transfer) to family 0 (two compute dispatches) and back to family 1. The internal waits targeted COPY timeline tickets 1 and 2. No Vulkan validation errors were reported.
  • Native D3D12 on the same GPU accepted the standard COPY-queue upload and readback and matched all 35 texels.
  • Full runtime CTest passed with 158 passes, 8 skips, and 1 disabled test. depth24_convert also verifies that the RGB96 readback barrier covers compute writes.

AI-assisted (Codex). No game data, keys, or decryption.

@Atomic258

Copy link
Copy Markdown

Tested 718211187570798f3dbfe213103bea7d830cb2b0 on Windows 11, RTX 5090 (617.42), Vulkan SDK 1.4.363.0, MSVC 14.44/Ninja x64 RelWithDebInfo.

Built via vcvars64 and cmake --build runtime\build --target d3d12_rgb96_test depth24_convert_test. Ran ctest --test-dir runtime\build -V -R "^(d3d12_rgb96|d3d12_rgb96_copy_queue|depth24_convert)$": 3/3 passed, also 3/3 with LEONIDA_VK_VALIDATION=1 (no validation errors reported). The DIRECT → COPY → DIRECT test matched the 7×5 texels, shifted 3×3 patch and footprint sentinels on dedicated COPY family 1 (flags 0xc) and primary family 0. The standard suite matched eight texture shapes against WARP; the depth24 test verified RGB96 host-readback visibility barriers.

Red control: rebuilt baseline 98fa503f using the PR versions of the two test sources. d3d12_rgb96_test.exe --copy-queue-roundtrip exited 1 (byte 0: got 00, want ee); depth24_convert failed at line 615 (host_src_stages == VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT). Restored the PR checkout, rebuilt, and verified clean worktree.

AI-assisted (Devin); no game files.

@XFlawless1

XFlawless1 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Tested 71821118 merged with main de671352 (clean merge) on Windows 11 Pro 26300, MSVC 19.44, Vulkan SDK 1.4.363.0, RelWithDebInfo built with scripts/build_runtime.ps1, LEONIDA_VK_VALIDATION=1: pass on both GPUs.

RTX 5080, driver 621.14 Radeon iGPU of the Ryzen 7 9800X3D (RDNA2), driver 32.0.21042.62
COPY family used by the test 1, flags 0xc (transfer + sparse, no compute): the transfer-only path this PR adds 1, flags 0xe (compute + transfer + sparse): the conversion can stay on that family
d3d12_rgb96_copy_queue pass: dedicated-family round trip, then COPY on the shared primary family 0; 7x5 texels, shifted 3x3 patch and footprint sentinels match pass, same lines
d3d12_rgb96, depth24_convert, d3d12_depth24_draw pass pass
full ctest 168/168 168/168

No validation messages in either run. So the RTX 5080 run checks the transfer-only handoff to the primary queue on a second NVIDIA generation, after the PR's RTX 3090. The Radeon checks that a COPY family with compute is unaffected.

AI-assisted (Claude Code).

@Parakeet-Wheat

Copy link
Copy Markdown
Contributor

Tested 7182111 (on its base main 98fa503f) on an RTX 3070 (610.88, Windows 11 26300, MSVC VS 2022, Vulkan SDK 1.4.363 layers), with the validation layer including synchronization validation: pass. Full ctest is 174/174, including the new d3d12_rgb96_copy_queue. Run directly, it prints RGB96 dedicated COPY family 1 (flags 0xc), primary family 0, so the transfer-only path is reached on this GPU. It then matches the 7×5 texels, the shifted 3×3 patch and the sentinels on both devices, with 0 validation errors. It passed 50 of 50 repeated runs. depth24_convert_test passes, including the host-readback barrier check. The two build warnings (C4456 in d3d12_vulkan_device_test.cpp) are in a file this PR doesn't touch.

Controls (one change at a time, rebuilt, then restored):

Change Result
switch_queue = false in submit(), so a batch that moves between the transfer and primary queues no longer waits on the COPY timeline d3d12_rgb96_copy_queue passed 19 of 20 runs; run 14 failed with byte 0: got 00, want ee. No validation error in any run
execution_kind = kind_, so the repack batch keeps the COPY stage mask depth24_convert_test fails (line 615: host_src_stages == VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT); d3d12_rgb96_copy_queue passes 20 of 20

The second row is pinned by the updated depth24_convert_test. The first row is the handoff ordering this PR adds, and the test catches its removal only now and then: here, 1 run in 20. Byte 0 is the footprint prefix, which mixed fills from the upload buffer. So the failure is most likely the last DMA copy, on family 1, reading packed before the mixed batch on family 0 has written it. Synchronization validation didn't report the missing cross-queue wait, so the byte compare is the only thing that notices, and only when the race goes the wrong way. A deterministic check would help. One option is a depth24_convert_test-style hook on vkQueueSubmit: assert that the first submission on the other physical queue waits on the logical queue's own timeline at the previous ticket, in both directions. Another is to make dma_in slow enough that mixed would overtake it without the wait, for example with a much larger buffer copy in dma_in ahead of the patch copy.

AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants