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

Manually merged
github merged 1 commit from gh-pr/1066/head into gh-pr/1066/base 2026-11-26 09:36:23 +00:00
Owner

@⁠klikso on GitHub · 2026-11-24 17:39 UTC · original
klikso:carry/d3d-execind-range → main · +63 −26 · 3 files · 1 commits · merged 2026-11-24 20:31 UTC

Claimed in the coordination issue as: D3D-EXECIND-RANGE-CARRY

Fixes: #504

What and why

d3d12_execute_indirect_validation is red on main on current Windows 11: the layer refuses five ExecuteIndirect calls that live WARP and the hardware driver both accept (#504, reported from seven machines today). #337 by @⁠natterman12 fixed it and was verified independently on six hosts (RTX 5070 Ti, 4060 Ti, 5070, 2060 SUPER, Radeon 660M, and Linux replay on an RTX 3060), but its author closed it on 24 November along with his other open pull requests, so nothing open carries the fix.

This is that one commit, 7f96cff90, cherry-picked onto current main with its author kept. No change of mine is in it; the cherry-pick applied without conflicts.

  • The layer bounds the bytes the commands read, (max_count - 1) * stride + record_size, and checks no range at a zero count, in recording (d3d12_com.cpp) and in replay (vulkan_replay.h).
  • The test marks the five disputed rows as host-dependent (the layer must accept them, a live host may answer either way) and adds two rows that overrun the buffer under either rule.

@⁠natterman12: this is your work. If you reopen #337 or want this branch, say so and I will close this.

The alternative is draft #306 (old PR 10041), which keeps the layer strict and relaxes the test only. Only one of the two should land.

Tested

Windows 11 26200.9974, D3D12Core and d3d10warp.dll 10.0.26100.9818, MSVC 14.44.35207 with Ninja, RelWithDebInfo, Windows SDK 10.0.26100.0, Vulkan 1.4.357. Built and run at base 32950551e; the four commits main gained since do not touch runtime/.

main 32950551e with this commit
ctest -j 6 270 of 271 pass 271 of 271 pass
d3d12_execute_indirect_validation 49 parity cases, 5 failures 51 parity cases, 0 failures
Host-dependent answers (WARP + hardware) n/a 10 accepted, 0 refused
Positive GPU dispatch, Vulkan validation errors ok, 0 ok, 0

On main the five failing rows are the ones in #504, each layer=0 warp=1 hw=1 expected=0: the two aligned offsets past the buffer at max=0, and the three padded-stride exact fits (240+20, 220+40, 244+20 in a 256-byte buffer). The two new overrun rows (244+16>256, 224+20+16>256) are refused by the layer, WARP and the hardware alike.

  • python -I scripts/check_no_game_data.py on the three changed files: no hits.
  • git diff --check: clean.

GPUs tested: NVIDIA GeForce RTX 3060 Ti (Ampere), driver 621.14, Windows 11 26200

AI-assisted: yes (Claude Code; built, run and measured on the machine above)

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 rule).

🤖 Generated with Claude Code

**@⁠klikso** on GitHub · 2026-11-24 17:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1066) `klikso:carry/d3d-execind-range` → `main` · +63 −26 · 3 files · 1 commits · merged 2026-11-24 20:31 UTC Claimed in the coordination issue as: D3D-EXECIND-RANGE-CARRY Fixes: #504 ### What and why `d3d12_execute_indirect_validation` is red on `main` on current Windows 11: the layer refuses five `ExecuteIndirect` calls that live WARP and the hardware driver both accept (#504, reported from seven machines today). #337 by @⁠natterman12 fixed it and was verified independently on six hosts (RTX 5070 Ti, 4060 Ti, 5070, 2060 SUPER, Radeon 660M, and Linux replay on an RTX 3060), but its author closed it on 24 November along with his other open pull requests, so nothing open carries the fix. This is that one commit, `7f96cff90`, cherry-picked onto current `main` with its author kept. No change of mine is in it; the cherry-pick applied without conflicts. - The layer bounds the bytes the commands read, `(max_count - 1) * stride + record_size`, and checks no range at a zero count, in recording (`d3d12_com.cpp`) and in replay (`vulkan_replay.h`). - The test marks the five disputed rows as host-dependent (the layer must accept them, a live host may answer either way) and adds two rows that overrun the buffer under either rule. @⁠natterman12: this is your work. If you reopen #337 or want this branch, say so and I will close this. The alternative is draft #306 (old PR 10041), which keeps the layer strict and relaxes the test only. Only one of the two should land. ### Tested Windows 11 26200.9974, D3D12Core and `d3d10warp.dll` 10.0.26100.9818, MSVC 14.44.35207 with Ninja, `RelWithDebInfo`, Windows SDK 10.0.26100.0, Vulkan 1.4.357. Built and run at base `32950551e`; the four commits `main` gained since do not touch `runtime/`. | | `main` `32950551e` | with this commit | |---|---|---| | `ctest -j 6` | 270 of 271 pass | 271 of 271 pass | | `d3d12_execute_indirect_validation` | 49 parity cases, 5 failures | 51 parity cases, 0 failures | | Host-dependent answers (WARP + hardware) | n/a | 10 accepted, 0 refused | | Positive GPU dispatch, Vulkan validation errors | ok, 0 | ok, 0 | On `main` the five failing rows are the ones in #504, each `layer=0 warp=1 hw=1 expected=0`: the two aligned offsets past the buffer at `max=0`, and the three padded-stride exact fits (`240+20`, `220+40`, `244+20` in a 256-byte buffer). The two new overrun rows (`244+16>256`, `224+20+16>256`) are refused by the layer, WARP and the hardware alike. - `python -I scripts/check_no_game_data.py` on the three changed files: no hits. - `git diff --check`: clean. GPUs tested: NVIDIA GeForce RTX 3060 Ti (Ampere), driver 621.14, Windows 11 26200 AI-assisted: yes (Claude Code; built, run and measured on the machine above) ### 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. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed: n/a (no translator rule). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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. e1ec785b2 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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:36:21 +00:00
github manually merged commit 10f7fc21c7 into gh-pr/1066/base 2026-11-26 09:36:23 +00:00
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-24 17:42 UTC · original · approved these changes

Reviewed the range change on head 10f7fc21c7. The checked formula, (max_count - 1) * stride + record_size, matches the bytes consumed by the final indirect record; zero count performs no Vulkan dispatch iterations. The Vulkan replay uses the same final-record range, with alignment retained for zero-count offsets. The added overrun rows distinguish cases where the record itself exceeds the resource. The PR merges cleanly onto current main; no-game-data and diff checks pass; an independent boundary arithmetic check passed 8/8. This Linux host cannot run the Windows D3D12/WARP/hardware integration test; those results are PR-author-reported and not counted as locally reproduced.

**@⁠KernelSmoker** on GitHub · 2026-11-24 17:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1066#pullrequestreview-6044390163) · **approved these changes** Reviewed the range change on head 10f7fc21c76368414ae14115f6ae04effeb12dc1. The checked formula, (max_count - 1) * stride + record_size, matches the bytes consumed by the final indirect record; zero count performs no Vulkan dispatch iterations. The Vulkan replay uses the same final-record range, with alignment retained for zero-count offsets. The added overrun rows distinguish cases where the record itself exceeds the resource. The PR merges cleanly onto current main; no-game-data and diff checks pass; an independent boundary arithmetic check passed 8/8. This Linux host cannot run the Windows D3D12/WARP/hardware integration test; those results are PR-author-reported and not counted as locally reproduced.
Author
Owner

@⁠Miici0 on GitHub · 2026-11-24 20:04 UTC · original

Tested on a 7th host: NVIDIA GeForce RTX 4070 SUPER (Ada), driver 621.24, Windows 11 build 26300.9974, Windows SDK 10.0.28000.0, Vulkan SDK 1.4.363.1, MSVC 19.42 with Ninja, RelWithDebInfo. Built and ran at 10f7fc21c (this branch).

ctest -R d3d12_execute_indirect_validation: 51 parity cases, 0 failures - matches the numbers in the PR description exactly.

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

**@⁠Miici0** on GitHub · 2026-11-24 20:04 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1066#issuecomment-7143015065) Tested on a 7th host: NVIDIA GeForce RTX 4070 SUPER (Ada), driver 621.24, Windows 11 build 26300.9974, Windows SDK 10.0.28000.0, Vulkan SDK 1.4.363.1, MSVC 19.42 with Ninja, RelWithDebInfo. Built and ran at 10f7fc21c (this branch). `ctest -R d3d12_execute_indirect_validation`: 51 parity cases, 0 failures - matches the numbers in the PR description exactly. No game files needed. AI-assisted (Claude Code).
Author
Owner

@⁠Gefik23 on GitHub · 2026-11-24 20:28 UTC · original

Tested 10f7fc21c on NVIDIA GeForce RTX 4060 (Ada), driver 617.42, Windows 11 Pro build 26200 (d3d12core.dll 10.0.26100.7309), native Windows: pass.

This is a 26100-based d3d12core rather than 26300, and it already has the relaxed behaviour: on main @ 6293c1c the test failed the same five cases (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, dispatch stride=20 off=244 max=1), with WARP and HW both returning S_OK. So the fix is needed on stock Windows 11, not only 26300+.

Built at this head with scripts\build_runtime.ps1 (MSVC 19.44, VS 2022 Build Tools, Ninja, RelWithDebInfo, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0).

  • ctest -R ^d3d12_execute_indirect_validation$ -V: passed, "51 parity cases (WARP=live, HW=NVIDIA GeForce RTX 4060), positive GPU dispatch ok, 0 validation errors, 0 failures".
  • Full ctest -C RelWithDebInfo: 297/297 passed (game-data tests skipped, LEONIDA_GAME_DIR unset).

AI-assisted (Claude Code ran the build and tests). No game files.

**@⁠Gefik23** on GitHub · 2026-11-24 20:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1066#issuecomment-7143603577) Tested 10f7fc21c on NVIDIA GeForce RTX 4060 (Ada), driver 617.42, Windows 11 Pro build 26200 (d3d12core.dll 10.0.26100.7309), native Windows: pass. This is a 26100-based d3d12core rather than 26300, and it already has the relaxed behaviour: on main @ 6293c1c the test failed the same five cases (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, dispatch stride=20 off=244 max=1), with WARP and HW both returning S_OK. So the fix is needed on stock Windows 11, not only 26300+. Built at this head with `scripts\build_runtime.ps1` (MSVC 19.44, VS 2022 Build Tools, Ninja, RelWithDebInfo, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0). - `ctest -R ^d3d12_execute_indirect_validation$ -V`: passed, "51 parity cases (WARP=live, HW=NVIDIA GeForce RTX 4060), positive GPU dispatch ok, 0 validation errors, 0 failures". - Full `ctest -C RelWithDebInfo`: 297/297 passed (game-data tests skipped, LEONIDA_GAME_DIR unset). AI-assisted (Claude Code ran the build and tests). No game files.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-24 20:31 UTC · original

Tested 10f7fc21c applied onto main 23c459644 on an AMD Radeon RX 7900 XT: d3d12_execute_indirect_validation fails on main (5 failures) and passes with this PR, 4/4 runs. No new failures in the full ctest run.

Hardware/software: AMD Radeon RX 7900 XT (RDNA3), AMD driver 32.0.32029.2010 (Adrenalin 26.11.2), Windows 11 build 26300, D3D12Core.dll and d3d10warp.dll 10.0.26100.9818, VS 2022 (x64, RelWithDebInfo), Vulkan SDK 1.4.363.0. No game files.

Build:

cmake -S runtime -B runtime/build/d3d12 -G "Visual Studio 17 2022" -A x64 -DLEONIDA_BUILD_WINDOWS_RUNTIME=ON
cmake --build runtime/build/d3d12 --config RelWithDebInfo --parallel 16

Targeted test:

ctest --test-dir runtime/build/d3d12 -C RelWithDebInfo -R "^d3d12_execute_indirect_validation$" -V
runs result
main 23c459644 3 Failed every time: 49 parity cases, 5 failures
PR 10f7fc21c 3, plus 1 with LEONIDA_VK_VALIDATION=1 Passed every time: 51 parity cases, 0 failures, positive GPU dispatch ok, 0 validation errors

On main the five failures are the five rows this PR marks host_varies, each layer=0 warp=1 hw=1 expected=0. With the PR, the layer accepts them, and this host agrees on all of them:

runtime-dependent cases: the live hosts accepted 10 and refused 0 answers; the layer accepts all of them

The AMD hardware path answers the same as WARP on every row of the table, including the two new overrun rows (244+16>256, 224+20+16>256), which the layer, WARP and the 7900 XT all refuse. So the wider rule is what D3D12Core 10.0.26100.9818 does on AMD too, not only on NVIDIA.

Full ctest, run once on each build:

ctest --test-dir runtime/build/d3d12 -C RelWithDebInfo -j 6 --output-on-failure
  • main: 300/305 passed. Failed: vk_queue_query_sync, d3d12_texture_tiles, d3d12_execute_indirect_validation, d3d12_clear, d3d12_pipeline_library_host.
  • PR: 301/305 passed. Failed: vk_queue_query_sync, d3d12_texture_tiles, d3d12_clear, d3d12_pipeline_library_host.

The only difference is d3d12_execute_indirect_validation going from failed to passed. The other four fail on main on this machine too and are unrelated (d3d12_clear: #787; d3d12_pipeline_library_host: #533, merged after this base; d3d12_texture_tiles: #964).

I also read the change before running it. I found no problem with the range rule itself: recording and replay use the same bound, (max_count - 1) * stride + record_size cannot wrap with 32-bit count and stride widened to 64 bits, and it matches the Vulkan indirect VUIDs. Three comments claim more than the code does. None of them blocks this PR:

  1. Test, new positive GPU dispatch (dispatch20 at 244): the comment says a rule that let Vulkan read past the buffer would show up as a validation error. It cannot here. vkCmdDispatchIndirect takes no stride, so Vulkan only sees 244 + 12 <= size, the same check as the existing dispatch12 call. Also, args is a DEFAULT buffer placed in the arena (d3d12_vulkan_device.cpp, create_buffer: binding.buffer = device_.arena.buffer, binding.buffer_offset = arena_offset_), so validation checks against the whole arena VkBuffer, not the 256-byte resource. Only the layer's own indirect_range check against binding.size guards the resource bounds.
  2. Test, the max=0 call at offset 260: it never reaches replay. CommandList::execute_indirect returns before append when max_count is 0 (command_list.h:878), so it exercises recording only.
  3. vulkan_replay.h, the max_count == 0 branch ("reads nothing and needs no range"): that only holds because the shim never sends a zero count. A zero-count counted dispatch built directly would make prepare_counted_dispatch return false (vulkan_indirect_dispatch_count.h:65, !max_count), and the list would fail as unsupported. Rejecting a zero count in replay, or skipping it at emit, would make the comment true.

Not tested: NVIDIA, Intel, other AMD drivers, Wine/Proton.

**@⁠adrianmjim** on GitHub · 2026-11-24 20:31 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1066#issuecomment-7143669410) Tested 10f7fc21c applied onto main 23c459644 on an AMD Radeon RX 7900 XT: d3d12_execute_indirect_validation fails on main (5 failures) and passes with this PR, 4/4 runs. No new failures in the full ctest run. Hardware/software: AMD Radeon RX 7900 XT (RDNA3), AMD driver 32.0.32029.2010 (Adrenalin 26.11.2), Windows 11 build 26300, D3D12Core.dll and d3d10warp.dll 10.0.26100.9818, VS 2022 (x64, RelWithDebInfo), Vulkan SDK 1.4.363.0. No game files. Build: ``` cmake -S runtime -B runtime/build/d3d12 -G "Visual Studio 17 2022" -A x64 -DLEONIDA_BUILD_WINDOWS_RUNTIME=ON cmake --build runtime/build/d3d12 --config RelWithDebInfo --parallel 16 ``` Targeted test: ``` ctest --test-dir runtime/build/d3d12 -C RelWithDebInfo -R "^d3d12_execute_indirect_validation$" -V ``` | | runs | result | |---|---|---| | main 23c459644 | 3 | Failed every time: 49 parity cases, 5 failures | | PR 10f7fc21c | 3, plus 1 with `LEONIDA_VK_VALIDATION=1` | Passed every time: 51 parity cases, 0 failures, positive GPU dispatch ok, 0 validation errors | On main the five failures are the five rows this PR marks `host_varies`, each `layer=0 warp=1 hw=1 expected=0`. With the PR, the layer accepts them, and this host agrees on all of them: ``` runtime-dependent cases: the live hosts accepted 10 and refused 0 answers; the layer accepts all of them ``` The AMD hardware path answers the same as WARP on every row of the table, including the two new overrun rows (`244+16>256`, `224+20+16>256`), which the layer, WARP and the 7900 XT all refuse. So the wider rule is what D3D12Core 10.0.26100.9818 does on AMD too, not only on NVIDIA. Full ctest, run once on each build: ``` ctest --test-dir runtime/build/d3d12 -C RelWithDebInfo -j 6 --output-on-failure ``` - main: 300/305 passed. Failed: vk_queue_query_sync, d3d12_texture_tiles, d3d12_execute_indirect_validation, d3d12_clear, d3d12_pipeline_library_host. - PR: 301/305 passed. Failed: vk_queue_query_sync, d3d12_texture_tiles, d3d12_clear, d3d12_pipeline_library_host. The only difference is d3d12_execute_indirect_validation going from failed to passed. The other four fail on main on this machine too and are unrelated (d3d12_clear: #787; d3d12_pipeline_library_host: #533, merged after this base; d3d12_texture_tiles: #964). I also read the change before running it. I found no problem with the range rule itself: recording and replay use the same bound, `(max_count - 1) * stride + record_size` cannot wrap with 32-bit count and stride widened to 64 bits, and it matches the Vulkan indirect VUIDs. Three comments claim more than the code does. None of them blocks this PR: 1. Test, new positive GPU dispatch (`dispatch20` at 244): the comment says a rule that let Vulkan read past the buffer would show up as a validation error. It cannot here. `vkCmdDispatchIndirect` takes no stride, so Vulkan only sees `244 + 12 <= size`, the same check as the existing `dispatch12` call. Also, `args` is a DEFAULT buffer placed in the arena (`d3d12_vulkan_device.cpp`, `create_buffer`: `binding.buffer = device_.arena.buffer`, `binding.buffer_offset = arena_offset_`), so validation checks against the whole arena VkBuffer, not the 256-byte resource. Only the layer's own `indirect_range` check against `binding.size` guards the resource bounds. 2. Test, the `max=0` call at offset 260: it never reaches replay. `CommandList::execute_indirect` returns before `append` when `max_count` is 0 (`command_list.h:878`), so it exercises recording only. 3. `vulkan_replay.h`, the `max_count == 0` branch ("reads nothing and needs no range"): that only holds because the shim never sends a zero count. A zero-count counted dispatch built directly would make `prepare_counted_dispatch` return false (`vulkan_indirect_dispatch_count.h:65`, `!max_count`), and the list would fail as unsupported. Rejecting a zero count in replay, or skipping it at emit, would make the comment true. Not tested: NVIDIA, Intel, other AMD drivers, Wine/Proton.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 20:31 UTC · original

Merged. This was compared with the test-only alternative (#306 / #749), and it is the better fix because it changes the layer itself:

  • Recording and replay now accept (max_count-1)*stride + record_size and skip the range check at a zero count. That is the same bound Vulkan's indirect draws use, and what current D3D12 runtimes accept.
  • Relaxing the test instead would leave the layer refusing calls that current Windows runs, which drops the command list.
  • Evidence: seven Windows hosts are reported here, the latest an RTX 4070 SUPER with MSVC at 10f7fc21c (51 parity cases, 0 failures). The portable replay tests pass locally on Linux, and it merges cleanly.
  • The claim is valid. #306 and #749 were closed in favour of this.

AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 20:31 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1066#issuecomment-7143670925) Merged. This was compared with the test-only alternative (#306 / #749), and it is the better fix because it changes the layer itself: - Recording and replay now accept `(max_count-1)*stride + record_size` and skip the range check at a zero count. That is the same bound Vulkan's indirect draws use, and what current D3D12 runtimes accept. - Relaxing the test instead would leave the layer refusing calls that current Windows runs, which drops the command list. - **Evidence:** seven Windows hosts are reported here, the latest an RTX 4070 SUPER with MSVC at `10f7fc21c` (51 parity cases, 0 failures). The portable replay tests pass locally on Linux, and it merges cleanly. - The claim is valid. #306 and #749 were closed in favour of this. AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.