Skip to content

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

Merged
aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
klikso:carry/d3d-execind-range
Nov 24, 2026
Merged

aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
klikso:carry/d3d-execind-range

Conversation

@klikso

@klikso klikso commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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

…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>

@KernelSmoker KernelSmoker 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.

Reviewed the range change on head 10f7fc2. 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.

@Miici0

Miici0 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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 10f7fc2 (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).

@Gefik23

Gefik23 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Tested 10f7fc2 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.

@adrianmjim

Copy link
Copy Markdown

Tested 10f7fc2 applied onto main 23c4596 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 23c4596 3 Failed every time: 49 parity cases, 5 failures
PR 10f7fc2 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.

@aslan2142
aslan2142 merged commit e0f1719 into ProjectLeonida:main Nov 24, 2026
1 check failed
@aslan2142

Copy link
Copy Markdown
Collaborator

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

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

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.

d3d12_execute_indirect_validation: 5 rows where the layer rejects and live WARP and hardware accept (over-strict, not permissive)

7 participants