Skip to content

d3d12_indirect_dispatch_count_test: its compute fixture reads the root UAV at s4:s5 (D3D-448 layout) - #5792

Open
mrp1no wants to merge 1 commit into
ItsNotRexed:mainfrom
mrp1no:d3d-indirect-count-fixture-s4
Open

mrp1no wants to merge 1 commit into
ItsNotRexed:mainfrom
mrp1no:d3d-indirect-count-fixture-s4

Conversation

@mrp1no

@mrp1no mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as a new D3D item: #5581 (comment)

What and why

On main 561b65a8, d3d12_indirect_dispatch_count_test exits 1. The first case it prints is count 0 update 1: host 6/10, layer 0/0, expected 6/10. Once the test is changed to go on past a failure, the layer gives 0/0 in all eight cases. This happens on an Intel UHD 750 and on an RTX 3060, with and without validation, and the D3D12 calls all succeed.

Two merges landed close together and conflict on meaning:

  • D3D-448 (7c225260) moved compute root arguments to the console layout (rt::rootsig::pack_stage, from s4) and updated the compute GLSL fixtures to read the new places.
  • cs_indirect_dispatch_count.comp came with c262fb7b at the same time. It still reads its root UAV at s[0]:s[1], so every layer dispatch wrote through an address that isn't the UAV.

The fixture now reads s[4]:s[5], like cs_sg_probe.comp. One file changes, and the runtime is unchanged.

Tested

Windows 11, MSVC RelWithDebInfo, on the branch head:

  • d3d12_indirect_dispatch_count_test exits 0 with "8 native WARP / Vulkan GPU comparisons passed" on:
    • an Intel UHD Graphics 750, with and without LEONIDA_VK_VALIDATION=1;
    • an NVIDIA GeForce RTX 3060, with and without LEONIDA_VK_VALIDATION=1.
  • d3d12_m4_compute_test, d3d12_compute_test and d3d12_indirect_zero_test still pass on the UHD 750.
  • Control: on 561b65a8 without this change, the test exits 1 on both GPUs (layer 0/0).

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

🤖 Generated with Claude Code

…e compute layout

D3D-448 (7c22526) moved compute root arguments to rt::rootsig::pack_stage's
layout, from s4, and moved the compute GLSL fixtures with it. This fixture came
with c262fb7 at the same time and still read its root UAV at s0:s1, so on
main every Vulkan dispatch of d3d12_indirect_dispatch_count_test wrote through
the wrong address. The layer read back 0/0 in all eight cases and the test
exited 1 on an Intel UHD 750 and an RTX 3060. It now reads s4:s5, like
cs_sg_probe.comp. The runtime is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 988048d on Windows 11 with an NVIDIA GeForce RTX 4090 (32.0.16.2101) and AMD Radeon(TM) Graphics (32.0.21043.5001): pass.

I ran the four tests below on each adapter with Vulkan validation off and on. The runtime identified the selected adapter in every run. All 16 test runs passed. The changed fixture matched native WARP in all eight dispatch cases on each run.

foreach ($adapter in 'NVIDIA','AMD') {
    $env:LEONIDA_VK_DEVICE = $adapter
    foreach ($validation in '0','1') {
        $env:LEONIDA_VK_VALIDATION = $validation
        ctest --test-dir E:/Leonida-review-work-build -C RelWithDebInfo -V -R '^d3d12_(indirect_dispatch_count|indirect_zero|m4_compute|compute)$'
    }
}

On parent 561b65a, the indirect dispatch count test failed in all four configurations. For count 0 update 1, WARP returned 6/10 and the Vulkan layer returned 0/0. The expected result was 6/10.

AI-assisted. Synthetic GPU tests only.

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested 988048d on Intel UHD Graphics 770, driver 32.0.101.7088: d3d12_indirect_dispatch_count_test builds at this head and exits 0 with "counted ExecuteIndirect(DISPATCH): 8 native WARP / Vulkan GPU comparisons passed; count=0,1,max,>max, nonzero offsets and GPU count overwrite, no validation errors", with device line "Intel(R) UHD Graphics 770 (validation on)" under LEONIDA_VK_VALIDATION=1 and the same 8 comparisons without it. With VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation set, the loader prints "Insert instance layer" for the validation layer and the run passes with no validation errors. LEONIDA_VK_VALIDATION=1 alone did not load the layer here. I did not run main.

AI-assisted.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Head: 988048d.

  • Built d3d12_indirect_dispatch_count_test (Ninja, RelWithDebInfo) and ran with LEONIDA_VK_DEVICE='RTX 5070 Ti': exit 0, 8 native WARP / Vulkan GPU comparisons passed, no validation errors.
  • Reverting only the fixture to pc.s[0], pc.s[1] and rebuilding reproduces count 0 update 1: host 6/10, layer 0/0, expected 6/10, exit 1.
  • rt::rootsig::pack_stage(Stage::Compute) starts at s4 and a root UAV is two dwords, so s4:s5 is the runtime layout; the assertions are unchanged.

Verdict: approve; fixture fix, not a test masking a shim bug.

@DenRakEiw

Copy link
Copy Markdown

Tested commit 988048d2716b (trial-merged cleanly onto origin/main at 561b65a83, git diff --check clean) on Windows 11 x64 with NVIDIA GeForce RTX 5090 (driver 32.0.16.1088, Vulkan SDK 1.4.363.0, MSVC 2022 + Ninja Release build):

  • d3d12_indirect_dispatch_count_test.exe with LEONIDA_VK_DEVICE=NVIDIA, LEONIDA_VK_VALIDATION=1 (VK_LAYER_PATH=C:\VulkanSDK\1.4.363.0\Bin): pass (exit 0).
    • device: NVIDIA GeForce RTX 5090 (validation on)
    • counted ExecuteIndirect(DISPATCH): 8 native WARP / Vulkan GPU comparisons passed; count=0,1,max,>max, nonzero offsets and GPU count overwrite, no validation errors
  • d3d12_indirect_dispatch_count_test.exe with LEONIDA_VK_DEVICE=NVIDIA, LEONIDA_VK_VALIDATION=0: pass (exit 0), same 8 comparisons passed.
  • Diff check: updates runtime/test/glsl/cs_indirect_dispatch_count.comp to read the root UAV address from pc.s[4]:pc.s[5] (matching the D3D-448 compute layout in rt::rootsig::pack_stage). Did not run against unpatched main.

AI-assisted (Gemini 4 Neon).

@tunczzz

tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 988048d2 on Windows 11 10.0.26300 with an NVIDIA GeForce RTX 5070 Ti (driver 616.56), MSVC 19.44, Ninja, RelWithDebInfo: pass. d3d12_indirect_dispatch_count_test exits 0 with "8 native WARP / Vulkan GPU comparisons passed ... no validation errors". On main 561b65a8 it exits 1 with the same first line you quote, and with the test changed to go on past a failure, every one of the 8 cases gives layer 0/0.

A git bisect between 3faac557 (pass) and 561b65a8 (fail) confirms your cause independently. It rebuilt and ran only this test at each step, 11 steps. It ends at the merge of #4312 (f54c6395, D3D-448). That merge's first parent 7878871c passes and the merge fails. The D3D-448 commit 7c225260 alone couldn't be built for the test, because it sits on aa2988cc, from before the test existed, so bisect skipped it. So the regression comes in with the compute root layout move, as described.

Not run: the rest of ctest on this head (only the GLSL fixture changes), other GPUs. No game files. AI-assisted (Claude Code).

@FIocker

FIocker commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Independent Windows RTX 5080 check of 988048d2 against 561b65a8, AI-assisted. I used the same MSVC 19.44 runtime and test executable throughout. The full native baseline completed with 233 passes, 13 skips, one disabled test, and one failure in d3d12_indirect_dispatch_count.

Using Khronos validation 1.4.357 with synchronization checks active, the original shader reproduced count 0 update 1: host 6/10, layer 0/0, expected 6/10. I compiled this PR's synthetic shader with the same glslangValidator Vulkan 1.2 configuration and swapped only the generated fixture. All eight WARP/Vulkan comparisons passed, including the GPU-written count update, with zero validation errors. Restoring the original shader bytes brought back the same failure. The three neighboring compute/indirect CTests also passed. Windows 11 26200, NVIDIA 621.01.

@liamhob

liamhob commented Nov 23, 2026

Copy link
Copy Markdown

Verified on Windows 11, MSVC 19.44, Vulkan SDK 1.4.363.0 on AMD Radeon RX 9070 XT (driver 26.10.1):

  • \d3d12_indirect_dispatch_count_test.exe: PASS (exit code 0).
  • Output: \counted ExecuteIndirect(DISPATCH): 8 native WARP / Vulkan GPU comparisons passed; count=0,1,max,>max, nonzero offsets and GPU count overwrite, no validation errors.
  • Clean fix for the compute root UAV argument layout discrepancy.

@Stalkerino

Copy link
Copy Markdown

Tested the corrected fixture at 988048d27 on the Ryzen 7 9800X3D integrated Radeon (RADV RAPHAEL_MENDOCINO, Mesa 26.3.1). All eight Vulkan layer readbacks matched expected() under both Wine 11.22 and Proton-CachyOS 11.0-20261015 SLR. With the initial count at zero, the two accumulation words were 0/0 without an update and 6/10 after the in-list GPU copy set the count to three. With an initial count of seven, the readbacks were 6/10 and 12/20, exercising the clamp to the maximum of three records.

These are layer-versus-CPU measurements. I used a local copy of the fixture that calls the existing run(layer, …) and expected() for each original case and omits the WARP setup and host comparison. The runtime, synthetic GLSL, queue commands and GPU readback are the ones from this PR. The stock executable under Wine exits before any GPU work because its reference HLSL fails to compile (InterlockedAdd on RWByteAddressBuffer, 0x80004005), as already tracked in #4362. No game files. AI-assisted.

@Exopus-0x65f7ad0

Copy link
Copy Markdown
Contributor

Tested 988048d2 on RTX 5060 Ti / NVIDIA 621.14, Windows 11 26300, MSVC 14.51, Vulkan SDK 1.4.363.0, built with -DLEONIDA_LLVM_MC: pass.

  • Negative control: on main 561b65a8 on the same machine, d3d12_indirect_dispatch_count_test exits 1. It's one of the two tests that fail in my full ctest runs on main today.
  • This PR: LEONIDA_VK_VALIDATION=1 ctest -R ^d3d12_indirect_dispatch_count$ passes 5 of 5, and a direct run prints counted ExecuteIndirect(DISPATCH): 8 native WARP / Vulkan GPU comparisons passed; count=0,1,max,>max, nonzero offsets and GPU count overwrite, no validation errors.

AI-assisted (Claude Code).

@ttd0x

ttd0x commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Independent confirmation on an RTX 2080 Ti (Turing, driver 610.88, Windows 11 26200, MSVC from VS 18). On main 561b65a83, ctest -R ^d3d12_indirect_dispatch_count$ fails with count 0 update 1: host 6/10, layer 0/0, expected 6/10, 2 of 2 runs. With the same one-line change (pc.s[4], pc.s[5]) rebuilt at 561b65a83, it passes. I tested my own copy of the change, not the head of this PR.

The cause and bisect are written up in #6162: first-parent bisect limited to runtime/src and runtime/shims, good 43f41a1d8, bad f54c6395e (the merge of #4312), the same result as the bisect above. I also scanned the other runtime/test/glsl/*.comp files for reads of pc.s[0]/pc.s[1]; there are none. I opened a duplicate PR (#6210) by mistake, since I had not checked #5781; it is closed in favour of this one. #6162 can be closed when this merges. No game files. AI-assisted (Claude Code).

@0klavair

Copy link
Copy Markdown
Contributor

Tested 988048d2 (contains main 561b65a8) on NVIDIA GeForce RTX 5060, driver 621.01, Windows 11 23H2 (in-box D3D12/WARP 10.0.22621.5415), MSVC 19.44, Ninja, Vulkan SDK 1.4.363: pass.

AI-assisted (Claude Code).

gahitchi added a commit to gahitchi/Leonida that referenced this pull request Nov 23, 2026
…otRexed#6162

On c6384df, six direct compute controls write at offset zero with the old fixture and at the chosen byte offset with s4:s5. Actual Windows indirect dispatch remains a separate acceptance check. AI-assisted integration.
@DeSunShine

Copy link
Copy Markdown

Tested 988048d27 merged with main 1cc6e3c12 on NVIDIA GeForce RTX 4090 (driver 621.24), Windows 11 Pro 26200, MSVC (VS Build Tools 18) + Ninja via scripts/build_runtime.ps1, Vulkan SDK 1.4.363: pass. d3d12_indirect_dispatch_count passes 3/3 (ctest --repeat until-fail:3); on main alone it fails deterministically here with count 0 update 1: host 6/10, layer 0/0, expected 6/10. AI-assisted (Claude Code).

@trick-ye

Copy link
Copy Markdown

Tested 988048d2 on AMD Radeon RX 7800 XT (RDNA3), AMD 26.11.2 (Windows driver 32.0.32029.2010), Windows 11 26200: pass; it fixes a failure this card has on main.

  • main 561b65a8: d3d12_indirect_dispatch_count fails with count 0 update 1: host 6/10, layer 0/0, expected 6/10.
  • This head: 3 runs alone with LEONIDA_VK_DEVICE=7800, exit 0 each: counted ExecuteIndirect(DISPATCH): 8 native WARP / Vulkan GPU comparisons passed; count=0,1,max,>max, nonzero offsets and GPU count overwrite, no validation errors.
  • Only this test was built and run. MSVC 14.42 (VS 2022), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0 (glslangValidator 16.6.0), RelWithDebInfo. Synthetic test only, no game files.

AI-assisted (Claude Code).

@SloppyBro

Copy link
Copy Markdown

Reviewed and tested 988048d27 merged into current main 8f800c06e on an NVIDIA GeForce RTX 4080 SUPER (driver 621.24), Windows 11 Pro 26200, MSVC (VS 2022 Build Tools) + Ninja, Vulkan SDK 1.4.363.0. AI-assisted (Claude Code).

Review: the change is right. pack_stage places compute root arguments from s4 since D3D-448 (7c2252609), and the other compute fixtures that commit updated (cs_user_data.comp, cs_sg_probe.comp) read the root UAV at s4:s5 too. I reached the same cause independently before finding this PR: on main, adding a plain Dispatch(1,1,1) after the ExecuteIndirect also left the output at 0, and so did a gate shader that ignored the count and wrote constant (1,1,1) records. So the counted-dispatch gate was never the problem, only the fixture's address.

Tests (merged with 8f800c06e):

  • d3d12_indirect_dispatch_count: pass 5/5 (ctest --repeat until-fail:5), and pass with LEONIDA_VK_VALIDATION=1 (no validation errors).
  • Full runtime ctest: 251/251 passed (22 skipped by their own checks).
  • Before: on 561b65a83 it failed every run with count 0 update 1: host 6/10, layer 0/0, expected 6/10.

About the red macos check: it fails in "GPU tests on MoltenVK" on cs_w32_permlane_fi, which this PR doesn't touch. main fixed that in 5a78b4b7d (#6322), after this branch's base 561b65a83. Merging main into the branch should turn the check green.

@caltr98

caltr98 commented Nov 23, 2026

Copy link
Copy Markdown

Tested 988048d on NVIDIA GeForce RTX 5080 Laptop GPU, driver 621.14 (Blackwell), Windows 11 (build 26300), MSVC 14.44, RelWithDebInfo: pass, and it fixes a failure on main.

  • main at 1cc6e3c: d3d12_indirect_dispatch_count fails with count 0 update 1: host 6/10, layer 0/0, expected 6/10, as in the PR description.
  • This PR: d3d12_indirect_dispatch_count, d3d12_indirect_zero and d3d12_indirect_rt pass; the test reports counted ExecuteIndirect(DISPATCH): 8 native WARP / Vulkan GPU comparisons passed; count=0,1,max,>max, nonzero offsets and GPU count overwrite, no validation errors.

A third GPU family after the UHD 750 and RTX 3060. 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.