Skip to content

d3d12: ExecuteIndirect accepts the argument ranges newer D3D12 runtimes accept (D3D-EXECIND-RANGE) - #337

Closed
natterman12 wants to merge 1 commit into
ProjectLeonida:mainfrom
natterman12:d3d12/execute-indirect-host-divergence
Closed

natterman12 wants to merge 1 commit into
ProjectLeonida:mainfrom
natterman12:d3d12/execute-indirect-host-divergence

Conversation

@natterman12

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D-EXECIND-RANGE (#14)

Alternative to: #306 (draft, carried over from old-pr/10041). Both start from the same measurement; they decide the layer's behaviour in opposite ways, so please take one and close the other. See "Why not only the test" below.

What and why

d3d12_execute_indirect_validation fails on main on any host with a current D3D12 runtime. PC runtimes disagree on five ExecuteIndirect cases:

narrower rule wider rule
Argument range max_count * stride (max_count - 1) * stride + record_size
max_count 0 the offset must still be inside the buffer nothing is checked beyond alignment
Measured on WARP and an RTX 5060 (e1ec785's message) D3D12Core 10.0.26100.9818 on Windows 11 26300: WARP and RTX 3080 Ti here; WARP and RX 9070 XT in #306

e1ec785 moved the layer from the wider rule to the narrower one to match the hosts its author had, which made the test fail on every host with the wider rule, as it had failed on narrower hosts before. On this machine: 49 parity cases ... 5 failures, each layer=0 warp=1 hw=1 expected=0.

This change:

  • Layer, recording (runtime/shims/d3d12_com.cpp): the argument range is (max_count - 1) * stride + record_size, checked only when max_count is non-zero. The record-size, stride, alignment, buffer-dimension and count-buffer checks are unchanged.
  • Layer, replay (runtime/src/vulkan_replay.h): the same arithmetic. A zero count, which recording never passes on, needs alignment only.
  • Test: the five cases carry host_varies. The layer has to accept them; a live host may answer either way and is reported, not judged. Every other case still requires layer, WARP and hardware to agree. Two cases neither rule accepts are added (244+16>256, 224+20+16>256), so the wider rule's own boundary is pinned. The positive GPU path now also replays a padded-stride dispatch at the end of the buffer and a zero count at an offset outside it, with validation on.

Why not only the test

Keeping the layer strict and making the test tolerant (the approach of #306) leaves the layer refusing calls that the current Windows runtime runs. A refusal here fails Close() and the whole command list is dropped. Accepting costs nothing:

  • the wider rule is the one Vulkan states for vkCmdDrawIndirect / vkCmdDrawIndexedIndirect (stride * (drawCount - 1) + offset + sizeof(command) <= size), so replay needs no special handling;
  • no byte outside the argument buffer is read under it;
  • a title that only ever made calls valid under the narrower rule is unaffected.

What neither pull request can answer is which rule the console's own driver applies; that needs the executable. If you would rather keep the layer strict until then, #306 is the one to take.

Tested

Windows 11 10.0.26300.9974, NVIDIA GeForce RTX 3080 Ti, driver 621.24, D3D12Core and WARP 10.0.26100.9818, MSVC 19.44.35230, Vulkan SDK 1.4.363.0. Clean build of this branch (RelWithDebInfo). No game files.

AI-assisted: yes (Claude Code)

Checklist

  • 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. (not applicable: no translator change)

🤖 Generated with Claude Code

…es accept

PC D3D12 runtimes disagree on five ExecuteIndirect cases. Older Windows 11
builds bound max_count * stride and check the argument offset at a zero
count; newer ones (D3D12Core 10.0.26100.9818 on Windows 11 26300, WARP and
NVIDIA alike) bound (max_count - 1) * stride + record_size and check
nothing at a zero count. e1ec785 moved the layer to the older rule, so
d3d12_execute_indirect_validation failed on every newer host, as it had
failed on older ones before.

The layer takes the wider rule again, in recording (d3d12_com.cpp) and in
replay (vulkan_replay.h): it is the rule vkCmdDraw*Indirect states, no byte
outside the buffer is read, and a refusal drops the whole command list for
a call a shipping runtime runs.

The test marks the five cases host_varies: the layer has to accept them and
a live host may answer either way, so the test stops failing on one group
of machines or the other. Two cases that neither rule accepts are added,
and the positive GPU path replays both disputed shapes with validation on.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@demoz53

demoz53 commented Nov 24, 2026 •

Copy link
Copy Markdown

Tested on a second host with the runtime this PR describes.

Host: NVIDIA GeForce RTX 4060 Ti (driver 32.0.16.1088), Windows 11 26300, D3D12Core and WARP (d3d10warp.dll) 10.0.26100.9818, MSVC 2022 RelWithDebInfo, Vulkan SDK 1.4.363.

  • main at d2cd6c0d9: d3d12_execute_indirect_validation fails the same 5 of 49 parity cases. The layer refuses them; WARP and the hardware driver both accept them (layer=0 warp=1 hw=1 expected=0). The five are the same rows as on the RTX 3080 Ti: arg_offset=260 >width (max=0 no-op), arg_offset=U64MAX-3 aligned (max=0 no-op), draw stride=20 off=240 max=1, draw stride=20 off=220 max=2 and dispatch stride=20 off=244 max=1.
  • This PR merged onto main at 8f481cf16 (it merges cleanly): the build succeeds, d3d12_execute_indirect_validation passes, and the whole ctest run is 303/303.

So this host's runtime has the same (max_count - 1) * stride + record_size bound as the RTX 3080 Ti measurement. No game files were used.

(AI-assisted: Claude Code ran the build and tests.)

@moffington

Copy link
Copy Markdown
Contributor

Tested 7f96cff on Linux with an RTX 3060. The runtime suite reported 68 passed, 2 skipped, and 0 failed.

In a replay harness, the PR accepted all three padded-stride cases where the last indirect record ended exactly at the buffer boundary. The merge base (84347bb) rejected those same cases. The PR still rejected all three cases where the last record extended past the buffer. This covers the Linux replay path. The Windows D3D12 shim and its ExecuteIndirect validation test remain unverified in this run.

@sodove

sodove commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Independent check on Windows 11 26100.7623, RTX 5070 Ti (610.74), MSVC 19.44.35220 Release. I verified that this test process loaded the system D3D12Core.dll and d3d10warp.dll, both 10.0.26100.7309.

This extends the measured wider behavior to D3D12Core 10.0.26100.7309 on Windows build 26100. Vulkan validation was off for these runs because the Khronos validation layer was unavailable on this host. Synthetic fixtures only. AI-assisted verification.

@GrahamboJangles

Copy link
Copy Markdown

Reviewed the diff against main at d478a92 (CPU read; I could not build the D3D12 side on this machine, so no new measurements here).

What I checked in the layer change itself:

  • max=0 path is alignment-only, as the body claims. On main, d3d12_com.cpp validates argument_buffer_offset % 4 != 0 and the count-buffer/offset checks before the range block, so dropping the range checks at max_count == 0 leaves alignment and buffer-dimension rules intact. Matches the "any aligned offset at a zero count" row in the test table.
  • No overflow in the new arithmetic. max_command_count and stride are both UINT, so UINT64(max_command_count - 1) * stride + record_size tops out at (2³²−1)² + 28 < 2⁶⁴; and arg_desc.Width - argument_buffer_offset is guarded by the argument_buffer_offset > arg_desc.Width check that still runs first. The U64MAX-3/U64MAX cases are caught by that offset check, as the table expects.
  • The replay rule matches the Vulkan spec's own wording. vkCmdDrawIndirect requires stride*(drawCount-1) + offset + sizeof(VkDrawIndirectCommand) <= size, which is exactly what vulkan_replay.h now computes; the max_count == 0 branch checking only (buffer_offset | argument_offset) % 4 is consistent with the layer.
  • The two added negative cases pin the wider rule's boundary correctly: 244+16>256 and 224+20+16>256 are refused by width - offset < required under the new formula, and by both runtimes under either rule.

Two notes for whoever triages this against draft #306:

  1. The red CI on this head is cancelled jobs, not a failing test. The windows job (138192326043) log ends 04:16:23 ##[error]The operation was canceled while ctest was running — the build finished and every d3d12_*_test.exe linked. So CI currently measures nothing for this PR; the author's 51-case run on D3D12Core 10.0.26100.9818 remains the only direct measurement, and the PR's "not tested on a host with the narrower rule" line still stands untested.
  2. The coordination side is in order: claim D3D-EXECIND-RANGE and the done: comment are both on Coordinating who works on what #14, and the ID is in the body — the coordination-claim validators should see a clean claim.

Not reviewed here: the host_varies judgement logic beyond reading it — a narrow-rule host would print refusals for the five cases and still pass, since only the layer is judged.

🤖 AI-assisted (Hermes agent; CPU review only, no measurements added)

@Timon360SB

Copy link
Copy Markdown
Contributor

Independent GPU verification — RTX 5070 and RTX 2060 SUPER

Tested PR head 7f96cff90da27e822d45c3380a193ca6bf00c0b3 on two Windows systems.

Test environments

Configuration RTX 5070 RTX 2060 SUPER
Architecture Blackwell Turing
NVIDIA driver 621.14 621.14
Windows 11 build 26200 28000
Vulkan API 1.4.357 1.4.357
Upload heaps VRAM (Resizable BAR) System memory
Build RelWithDebInfo RelWithDebInfo

ExecuteIndirect results

Check RTX 5070 RTX 2060 SUPER
Parity cases passed 51/51 51/51
Live WARP Yes Yes
Live hardware D3D12 Yes Yes
Positive GPU dispatch PASS PASS
Parity failures 0 0
Runtime-dependent host answers accepted 10 10
Runtime-dependent host answers refused 0 0

All five previously failing cases now return S_OK on the layer, WARP and hardware D3D12 on both systems.

Both newly added out-of-bounds cases are correctly rejected on all three paths.

Verified against the complete LastTest.log output, not just the CTest summary.

Full Runtime CTest

Result RTX 5070 RTX 2060 SUPER
Registered 303 303
Passed 289 284
Failed 2 7
Skipped 11 11
Disabled 1 1

Both systems reproduce the known d3d12_vulkan_device and d3d12_depth_resolve failures (#262, #238, #66).

The five additional RTX 2060 SUPER failures were also present in my earlier baseline at d42773d0734d5fd7b3a32a1bfd536f61186322a5.

All eight tested ExecuteIndirect-related runtime checks pass on both systems.

Conclusion

The wider argument-range behavior is confirmed on Blackwell and Turing, including both VRAM-backed and system-memory upload heaps.

Limitations: Global Vulkan validation was not enabled. Exact loaded D3D12Core and WARP DLL versions were not collected. The earlier baseline was not the exact PR merge base.

AI-assisted testing and report analysis.

@LewisCodesWebsites

Copy link
Copy Markdown

Tested 7f96cff (cherry-picked onto main 21625bc) on AMD Radeon 660M (RDNA2 iGPU), Adrenalin 32.0.21045.1000, Windows 11 26200, MSVC 2026: d3d12_execute_indirect_validation passes (fails on main with the 5 rows in #504). First AMD result. AI-assisted.

@natterman12 natterman12 closed this by deleting the head repository Nov 24, 2026
aslan2142 pushed a commit that referenced this pull request Nov 25, 2026
…on main 21625bc (GPU-RTX5070TI-WIN)

run_gpu_tests.py on a clean main build: 257/257 translated and valid;
197/248 passed, 49 skipped native, 229/248 passed, 17 skipped with
LEONIDA_W64_EMULATE=1; the two failures are the known tfe fixtures (#31).
Runtime CTest: 281 passed, 11 skipped, 1 disabled, 1 failed (the known
d3d12_execute_indirect_validation parity cases, #337 / #306).
ms_wave_info_s3 passes, so the original repository's issue 8369 no
longer reproduces on this GPU. The record is indexed in
docs/gpu_test_results.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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