Skip to content

TEST-599: give d3d12_subgroup_test a --pc-tail-ubo variant - #3279

Open
1TrickOmen wants to merge 6 commits into
ItsNotRexed:mainfrom
1TrickOmen:test599-pr
Open

1TrickOmen wants to merge 6 commits into
ItsNotRexed:mainfrom
1TrickOmen:test599-pr

Conversation

@1TrickOmen

Copy link
Copy Markdown
Contributor

TEST-599: give d3d12_subgroup_test a --pc-tail-ubo variant

Claimed as TEST-599 in #3047.

This branch is stacked on #2046's head bf1c90e and #2402's head d230040, so the PR diff still shows those commits until they land; it will be rebased once they merge.

Depends on: #2046
Depends on: #2402

What and why

d3d12_subgroup_test built 144-byte push-constant shaders, so it failed on devices limited to Vulkan's 128-byte minimum with pipelines need 144 bytes of push constants. It now uses --pc-tail-ubo modules throughout, the same path #2402 proved for d3d12_compute and d3d12_draw:

  • runtime/test/shaders/build.py: LEONIDA_PC_TAIL_UBO=1 passes --pc-tail-ubo to the translator.
  • runtime/CMakeLists.txt: the four subgroup shaders are translated with the flag; cs_sg_probe.comp is compiled a second time with -DPC_TAIL to cs_sg_probe_tail.spv.
  • runtime/test/glsl/cs_sg_probe.comp: gains the #ifdef PC_TAIL branch (128-byte block + set-1 PcTail); the other probe shaders declare no push constants.
  • runtime/test/d3d12_subgroup_test.cpp: make_library() declares 128 bytes; the compute probe uses the tail SPV and declares pc_tail {set 1, binding 0, bytes 16}.

Only synthetic GLSL and index metadata changed. No game data, keys or decryption.

Tested

AI-assisted. Windows 11, RX 9070 (Adrenalin 26.11.1) and Ryzen 7 7700X iGPU (26.10.1), LEONIDA_VK_VALIDATION=1: d3d12_subgroup exits 0 on both, all three cases exact, fragment probe 64, ps 4096/4096 exact; iGPU 3 shaders judged exact, 9070 4 shaders judged exact (the pixel readlane is judged on the 9070, which can require 64 for a wave64 pixel shader). Full ctest: 100% passed out of 129 (7 skipped/disabled, no failures).

whoalin1 and others added 3 commits November 22, 2026 20:17
…ush-constant devices

A device whose maxPushConstantsSize is 128 (AMD Windows driver on RDNA2 iGPUs, some Intel Arc drivers; D3D-14's push_constants_need_fallback) cannot hold the 144-byte ShaderUserData push-constant block, so previously every D3D12 PSO was refused there with E_NOTIMPL.

With --pc-tail-ubo (PR ItsNotRexed#2046), translated shaders keep s0..s31 in 128 push-constant bytes and move the 16-byte tail (heap base, code base) to a uniform block at set 1, binding 0 when a stage reads it. This wires that path through the D3D12 -> Vulkan layer:

- runtime/src/shader_library.h: ShaderEntry parses pc_tail.bytes into pc_tail_bytes (tested in shader_library_test).
- runtime/src/vulkan_replay.h: ComputePipeline and GraphicsPipeline carry push_bytes, tail_set and tail_offset; detail::bind_user_data binds set 0 (if present), set 1 with dynamic offset (if present), and pushes push_bytes at all three push sites (ExecuteIndirect dispatch, Dispatch, Draw); the three unsupported checks cover tail_set.
- runtime/shims/d3d12_vulkan_device.cpp: DeviceState::pc_tail creates one UNIFORM_BUFFER_DYNAMIC descriptor over the arena (range 16) plus an empty set-0 layout once per device. PipelineState::user_data_layout sizes the push-constant range from each stage's push_constant_bytes / pc_tail_bytes (so a --pc-tail-ubo stage that reads neither heap nor code base still fits 128 bytes), adds set 1 when any stage has pc_tail, writes the 16-byte tail once into the arena, and releases it on destruction. 144-byte shaders remain refused on <144-byte devices with a log pointing to --pc-tail-ubo.
- Tests: d3d12_compute_test and d3d12_draw_test verify 144-byte refusal and --pc-tail-ubo dispatch/draw (including VS without pc_tail + PS with set-1 tail) on both simulated 128-byte devices and the host GPU, and skip the 144-byte passes when run on a real 128-byte device.
- Docs: docs/d3d12_vulkan.md (sections 3.2, 5.2, Q13) and d3d12_com.h comment updated.

Step 3 of the uniform-buffer tail claimed in ItsNotRexed#1902.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Gemini 4 Neon <noreply@google.com>
# Conflicts:
#	docs/design.md
#	runtime/shims/d3d12_vulkan_device.cpp
@ddm-j

ddm-j commented Nov 22, 2026

Copy link
Copy Markdown

Tested 0a3df64 under Wine 11.21 (Fedora 45) on AMD Radeon 610M iGPU (RDNA2 gfx1036, RADV Mesa 26.2.6, subgroup 32..64) and NVIDIA RTX 4070 Ti (615.78.08, subgroup 32..32): fail, d3d12_draw regresses on both GPUs. The cause is a one-line semantic conflict between #2402 and main's #2109 that came in with the origin/main merge, not this PR's subgroup change. Fix below.

d3d12_subgroup itself passes on both GPUs:

  • RADV: subgroup size: 4 shaders judged exact through the layer's PSOs (sizes 32..64, default 64). Native w64 cs_w64x_readlane exact, emulated exact, ps_w64x_readlane 4096 of 4096 pixels exact.
  • NVIDIA: subgroup size: 2 shaders judged exact through the layer's PSOs (sizes 32..32, default 32). Native wave64 and the wave64 pixel shader are "not judged" (no 64-wide subgroup), and emulated w64 is exact.

Full ctest (cross-built with clang-cl + xwin, MSVC 14.44 / SDK 10.0.26100):

base f847748 this PR 0a3df64
RADV RAPHAEL 120 passed, 18 skipped, 0 failed 118 passed, 19 skipped, 1 failed (d3d12_draw)
RTX 4070 Ti 120 passed, 18 skipped, 0 failed 118 passed, 18 skipped, 2 failed (d3d12_draw, dxgi_swapchain)

dxgi_swapchain (4070) passed when rerun alone. RAPHAEL's extra skip, d3d12_xdxr_rt_check, also passed when rerun. I don't attribute either one to this PR.

d3d12_draw: the --pc-tail-ubo graphics draw renders the clear colour, on both the forced 128-byte device and the normal one:

tail draw pixel (0, 0): got 0,0,255,255 (128-byte) and 0,0,255,255, want 255,0,0,255
line 358: !tail_mismatches

Bisect:

Cause: #2109 made the graphics PSO stages {vs, gs, ps} (81ec7f7 fixed the same slip in the f16 link). #2402's graphics PSO still collects the user-data layout from stages[0] and stages[1], so it reads the empty GS slot and never sees the PS's pc_tail. No set 1 is made or bound, and the PS reads a garbage heap base. In runtime/shims/d3d12_vulkan_device.cpp (line 2711 at 0a3df64):

-        if (!user_data_layout({stages[0].entry, stages[1].entry}, user)) return E_NOTIMPL;
+        if (!user_data_layout({stages[0].entry, stages[1].entry, stages[2].entry}, user)) return E_NOTIMPL;

With that line changed locally (not pushed): d3d12_draw, d3d12_compute and d3d12_subgroup pass on both GPUs. This belongs in #2402 too, since it'll hit the same thing when it's rebased onto main.

Not run: d3d12_present (hangs on a real GPU under Xvfb here) and device_proxy (Fedora's Wine has no host D3D12). The Linux run_gpu_tests.py suite wasn't run because the PR only changes D3D12 layer tests.

AI-assisted (Claude Code); numbers copied from the run logs.

@1TrickOmen

Copy link
Copy Markdown
Contributor Author

Applied, thanks — the one-line fix is in (commit f431351). Verified on Windows 11, RX 9070 (Adrenalin 26.11.1) and Ryzen 7 7700X iGPU (26.10.1), validation on: d3d12_draw passes on both (tail VS+PS PSO 4096/4096 matched, plus the rest of the draw suite), d3d12_subgroup passes on both (9070: 4 judged exact, iGPU: 3 judged exact).

@kapitche

Copy link
Copy Markdown
Contributor

Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head merged with main f847748, MSVC 14.51; the head still carries #2046 and #2402):

  • RTX 4080 SUPER: shader_library, d3d12_compute, d3d12_draw and d3d12_subgroup pass.
  • Intel UHD 770 (VK_LOADER_DRIVERS_DISABLE=*nv*): shader_library, d3d12_compute and d3d12_draw pass; d3d12_subgroup fails. It fails the same way on plain main f847748 on this GPU (built separately: pass on NVIDIA, fail on Intel), so it is the known Intel subgroup failure and not this PR's doing.
  • Negative control: with the four runtime files reverted to main, shader_library_test no longer compiles (ShaderEntry::pc_tail_bytes is missing), so the tests depend on the change.

Only these four tests were built and run, not the full ctest.

@ddm-j

ddm-j commented Nov 22, 2026

Copy link
Copy Markdown

Tested f431351 under Wine 11.21 (Fedora 45) on AMD Radeon 610M iGPU (RDNA2 gfx1036, RADV Mesa 26.2.6, subgroup 32..64) and NVIDIA RTX 4070 Ti (615.78.08, subgroup 32..32): pass. The fix resolves the d3d12_draw regression I reported on 0a3df64.

  • d3d12_draw, both GPUs: --pc-tail-ubo graphics: a 128-byte device built the tail VS+PS PSO (VS without pc_tail, PS with set-1 tail) and 4096/4096 pixels matched there and on this GPU
  • d3d12_subgroup: RADV 4 shaders judged exact (sizes 32..64, default 64), NVIDIA 2 shaders judged exact (sizes 32..32, default 32)

Full ctest:

base f847748 0a3df64 (before) f431351 (this head)
RADV RAPHAEL 120 passed, 18 skipped, 0 failed 118 / 19 / 1 120 passed, 18 skipped, 0 failed
RTX 4070 Ti 120 passed, 18 skipped, 0 failed 118 / 18 / 2 120 passed, 18 skipped, 0 failed

Not run, as before: d3d12_present (hangs on a real GPU under Xvfb) and device_proxy (no host D3D12 in Fedora's Wine).

AI-assisted (Claude Code); numbers copied from the run logs.

@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Windows + GPU check: AMD Radeon RX 9070 (RDNA4), Windows 11, MSVC Release, Vulkan SDK 1.4.363. Tested head 0a3df64 merged onto main f847748 (clean merge), full build.

  • Full ctest -C Release -j 4: 130/132, with d3d12_typeless_rtv and d3d12_draw failing. That run shared the machine with other builds; main passed 132/132 just before it.
  • Rerun in isolation (ctest -R "^(d3d12_typeless_rtv|d3d12_draw)$", three times, same build): both pass 3/3.

So the failures look like load-related flakiness in the parallel run, not this PR, but I'm reporting the parallel result as it was.

AI-assisted (Claude Code); runs on my machine.

@bielfreedom

Copy link
Copy Markdown

Tested f4313518 (on its base f847748c) on AMD Radeon RX 9070 XT (RDNA4), AMD driver 32.0.32029.2010 (subgroup 32..64), Windows 11 Pro build 26200, with Vulkan validation on (LEONIDA_VK_VALIDATION=1, Vulkan SDK 1.4.363, VK_LOADER_LAYERS_DISABLE=~implicit~), MSVC build of runtime/: pass.

  • d3d12_subgroup (the test this PR gives a --pc-tail-ubo variant), d3d12_compute and d3d12_draw pass.
  • Full ctest: 140/140 pass, 0 failures, 0 validation errors.

This GPU has 256 bytes of push constants, so the UBO-tail path runs here because the test forces it, not because the device needs it.

AI-assisted (Claude Code). No game files.

# Conflicts:
#	docs/d3d12_vulkan.md
#	docs/design.md
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/src/vulkan_replay.h
#	runtime/test/d3d12_compute_test.cpp
#	runtime/test/d3d12_draw_test.cpp
@Vonsek

Vonsek commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 7473165 on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran ctest -R "^(d3d12_compute|d3d12_draw|d3d12_subgroup|shader_library)$" (the tests this PR changes): pass on both GPUs, 4/4 each. No game files.

AI-assisted.

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.

7 participants