D3D12.X: the count check's buffer stays INDIRECT_ARGUMENT between checks #3009

Open
voiceovarian1-max wants to merge 1 commit from upstream-pr/3009 into main
voiceovarian1-max commented 2026-11-27 12:09:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by voiceovarian1-max on 2026-11-27T12:09:24Z.


For nvidia-dev. The indirect count check (indirect_guard) moved its buffer to INDIRECT_ARGUMENT before each checked ExecuteIndirect and back to COMMON after it. That is two transitions per check, each a barrier the GPU waits at. A retail title's world makes ~1,640 checked ExecuteIndirects a frame. The buffer now stays INDIRECT_ARGUMENT from one check to the next on a list (check_in, run_keeping, guard_out_ia). It goes back in the same call as the next check's UAV barrier, so a checked ExecuteIndirect takes 2 barriers instead of 3.

What is in it

  • hle/d3d12x/indirect_guard.rs: check_in, run_keeping, guard_out_ia. New GPU test checked_execute_indirects_in_one_list_keep_the_buffer_between_them: three checks on one list (in range, garbage, in range) each run their own checked counts (7 + 60 groups).
  • hle/d3d12x/bind.rs: the ExecuteIndirect path uses them.

Tested

  • Linux (CachyOS, kernel 7.3), Proton Experimental (Wine 11.0) with vkd3d-proton 3.1, RTX 4070 Ti 12 GB, NVIDIA 620.73.04, i7-14700K. Rust 1.100.0, x86_64-pc-windows-gnu, release. Head d6f30c18 on nvidia-dev 3f39671d.
  • Whole lib suite under Wine (cargo test -p xcl --lib -- --test-threads=4):
    • this head: 1691 passed, 9 failed, 28 ignored
    • nvidia-dev 3f39671d: 1691 passed, 8 failed, 28 ignored
    • The 8 fail the same way on both. The 9th is the new test: under Wine, D3DCompile is Wine's own HLSL compiler and refuses its program (E5005 Load3 on RWByteAddressBuffer). The existing an_execute_indirect_with_garbage_counts_runs_no_groups fails on nvidia-dev for the same reason. #3018 (DXC when D3DCompile refuses a program) fixes both.
  • indirect_guard tests with Microsoft's d3dcompiler_47.dll (WINEDLLOVERRIDES=d3dcompiler_47=n): 5 passed, 0 failed, including the new test and both garbage-count tests.
  • Measured in a retail title on our Linux tree, not on this branch: the whole count check costs ~3 % of world fps unprofiled (~18 % profiled). This change's own share of that was not measured.

Regression run

  • None: scripts/smoke.ps1 needs Windows, and we only have Linux. A Windows smoke run on nvidia-dev and on this head would be welcome.

Not tested

  • Windows, AMD, a retail title on this branch. It was not checked that the new test fails without the change: it calls the new functions.

AI use

  • Claude Code with Claude Opus 5.5: wrote the change, the test and this description, and ran the tests.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5526372067 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3009). Originally posted by [voiceovarian1-max](https://github.com/voiceovarian1-max) on 2026-11-27T12:09:24Z. --- For nvidia-dev. The indirect count check (`indirect_guard`) moved its buffer to INDIRECT_ARGUMENT before each checked ExecuteIndirect and back to COMMON after it. That is two transitions per check, each a barrier the GPU waits at. A retail title's world makes ~1,640 checked ExecuteIndirects a frame. The buffer now stays INDIRECT_ARGUMENT from one check to the next on a list (`check_in`, `run_keeping`, `guard_out_ia`). It goes back in the same call as the next check's UAV barrier, so a checked ExecuteIndirect takes 2 barriers instead of 3. **What is in it** - `hle/d3d12x/indirect_guard.rs`: `check_in`, `run_keeping`, `guard_out_ia`. New GPU test `checked_execute_indirects_in_one_list_keep_the_buffer_between_them`: three checks on one list (in range, garbage, in range) each run their own checked counts (7 + 60 groups). - `hle/d3d12x/bind.rs`: the ExecuteIndirect path uses them. **Tested** - Linux (CachyOS, kernel 7.3), Proton Experimental (Wine 11.0) with vkd3d-proton 3.1, RTX 4070 Ti 12 GB, NVIDIA 620.73.04, i7-14700K. Rust 1.100.0, `x86_64-pc-windows-gnu`, release. Head `d6f30c18` on nvidia-dev `3f39671d`. - Whole lib suite under Wine (`cargo test -p xcl --lib -- --test-threads=4`): - this head: 1691 passed, 9 failed, 28 ignored - nvidia-dev `3f39671d`: 1691 passed, 8 failed, 28 ignored - The 8 fail the same way on both. The 9th is the new test: under Wine, `D3DCompile` is Wine's own HLSL compiler and refuses its program (`E5005 Load3 on RWByteAddressBuffer`). The existing `an_execute_indirect_with_garbage_counts_runs_no_groups` fails on nvidia-dev for the same reason. #3018 (DXC when `D3DCompile` refuses a program) fixes both. - `indirect_guard` tests with Microsoft's `d3dcompiler_47.dll` (`WINEDLLOVERRIDES=d3dcompiler_47=n`): 5 passed, 0 failed, including the new test and both garbage-count tests. - Measured in a retail title on our Linux tree, not on this branch: the whole count check costs ~3 % of world fps unprofiled (~18 % profiled). This change's own share of that was not measured. **Regression run** - None: `scripts/smoke.ps1` needs Windows, and we only have Linux. A Windows smoke run on nvidia-dev and on this head would be welcome. **Not tested** - Windows, AMD, a retail title on this branch. It was not checked that the new test fails without the change: it calls the new functions. **AI use** - Claude Code with Claude Opus 5.5: wrote the change, the test and this description, and ran the tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Lum7nt commented 2026-11-27 14:50:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Lum7nt on 2026-11-27T14:50:37Z.


Native Windows 11 + NVIDIA RTX 3060 verification of PR #3009

Tested PR #3009 head \d6f30c1809\ on native Windows 11 with native D3D12 hardware execution on Ampere (RTX 3060 12 GB, native wave32).

Environment

  • GPU: NVIDIA GeForce RTX 3060 (12 GB / 12,115 MiB VRAM), driver \32.0.15.8142\ (WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-10400 CPU @ 2.90GHz (6C / 12T), 32 GB RAM, Windows 11 Build 22631 (NT 10.0.22631.0)
  • Toolchain:
    ustc 1.100.0 (0ef1bc386 2026-11-09)\ x86_64-pc-windows-msvc, Windows SDK DXC \1.8.2502.11\ / dxil \1.8.2502.11\

Test Results (\hle::d3d12x::indirect_guard::tests)

Ran targeted \indirect_guard\ tests on the physical NVIDIA D3D12 device:
\\powershell
cargo test -p xcl --lib hle::d3d12x::indirect_guard::tests -- --nocapture
\\

  • \_counter_is_logged_at_its_first_values_and_at_each_doubling_however_it_jumps\ ? PASS
  • \rguments_across_a_window_end_are_not_read_through_the_window\ ? PASS
  • \n_execute_indirect_with_garbage_counts_runs_no_groups\ ? PASS
  • \n_execute_indirect_with_garbage_counts_draws_nothing\ ? PASS
  • \checked_execute_indirects_in_one_list_keep_the_buffer_between_them\ ? PASS

Result: 5 passed; 0 failed; 0 ignored; 0 skipped (0.32s).

Observations

  1. On native Windows D3D12, the new test \checked_execute_indirects_in_one_list_keep_the_buffer_between_them\ compiles cleanly with the Microsoft compiler and executes as expected: the 3 sequential checks on one command list keeping \INDIRECT_ARGUMENT\ between checks executed only the valid groups (\7 + 60 = 67) while discarding the out-of-range dispatch.
  2. The transitions back to \UNORDERED_ACCESS\ in the batch barrier executed cleanly on the hardware queue without any resource barrier validation errors, hazard warnings, or device removals.

AI disclosure: Testing executed independently on physical hardware; report drafted with agent assistance.

<!-- greyfinch-sync:ivall/xcl:comment:7221298276 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3009#issuecomment-7221298276). Originally posted by [Lum7nt](https://github.com/Lum7nt) on 2026-11-27T14:50:37Z. --- ### Native Windows 11 + NVIDIA RTX 3060 verification of PR #3009 Tested PR #3009 head \d6f30c1809b5350f09c492cc97ffb29088c56cc3\ on native Windows 11 with native D3D12 hardware execution on Ampere (RTX 3060 12 GB, native wave32). ### Environment - **GPU:** NVIDIA GeForce RTX 3060 (12 GB / 12,115 MiB VRAM), driver \32.0.15.8142\ (WDDM 3.2) - **CPU / RAM / OS:** Intel Core i5-10400 CPU @ 2.90GHz (6C / 12T), 32 GB RAM, Windows 11 Build 22631 (NT 10.0.22631.0) - **Toolchain:** \ ustc 1.100.0 (0ef1bc386 2026-11-09)\ x86_64-pc-windows-msvc, Windows SDK DXC \1.8.2502.11\ / dxil \1.8.2502.11\ ### Test Results (\hle::d3d12x::indirect_guard::tests\) Ran targeted \indirect_guard\ tests on the physical NVIDIA D3D12 device: \\\powershell cargo test -p xcl --lib hle::d3d12x::indirect_guard::tests -- --nocapture \\\ - \_counter_is_logged_at_its_first_values_and_at_each_doubling_however_it_jumps\ ? **PASS** - \rguments_across_a_window_end_are_not_read_through_the_window\ ? **PASS** - \n_execute_indirect_with_garbage_counts_runs_no_groups\ ? **PASS** - \n_execute_indirect_with_garbage_counts_draws_nothing\ ? **PASS** - \checked_execute_indirects_in_one_list_keep_the_buffer_between_them\ ? **PASS** **Result:** **5 passed; 0 failed; 0 ignored; 0 skipped** (0.32s). ### Observations 1. On native Windows D3D12, the new test \checked_execute_indirects_in_one_list_keep_the_buffer_between_them\ compiles cleanly with the Microsoft compiler and executes as expected: the 3 sequential checks on one command list keeping \INDIRECT_ARGUMENT\ between checks executed only the valid groups (\7 + 60 = 67\) while discarding the out-of-range dispatch. 2. The transitions back to \UNORDERED_ACCESS\ in the batch barrier executed cleanly on the hardware queue without any resource barrier validation errors, hazard warnings, or device removals. *AI disclosure: Testing executed independently on physical hardware; report drafted with agent assistance.*
andrewDoing commented 2026-11-28 02:56:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T02:56:35Z.


I checked a two-command-list boundary on exact head d6f30c1809b5350f09c492cc97ffb29088c56cc3 using native Windows D3D12 WARP with the SDK debug layer. A test-only extension of the existing compute fixture records two independent adopted lists, each starting with its own out_ia=false, and exercises the production guard's shared output buffer.

  • Submitting the two lists in one ExecuteCommandLists call emitted debug-layer error 527: the second list declared UNORDERED_ACCESS (0x8) while the previous tracked state was INDIRECT_ARGUMENT (0x200).
  • Submitting the same lists in separate calls produced no such error.
  • Submitting them in one call with a test-only cross-list INDIRECT_ARGUMENT → UNORDERED_ACCESS transition at the second entry also produced no such error.

All three runs signaled completion and produced the expected 67 groups. The output therefore does not demonstrate visible corruption; the debug-layer result identifies a state-tracking issue for a batched submission. XCL can submit multiple command lists in one driver call. I did not test a physical GPU, retail incidence, performance, or an author fix.

AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report.

<!-- greyfinch-sync:ivall/xcl:comment:7232692946 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3009#issuecomment-7232692946). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-28T02:56:35Z. --- I checked a two-command-list boundary on exact head `d6f30c1809b5350f09c492cc97ffb29088c56cc3` using native Windows D3D12 WARP with the SDK debug layer. A test-only extension of the existing compute fixture records two independent adopted lists, each starting with its own `out_ia=false`, and exercises the production guard's shared output buffer. - Submitting the two lists in **one** `ExecuteCommandLists` call emitted debug-layer error **527**: the second list declared `UNORDERED_ACCESS` (`0x8`) while the previous tracked state was `INDIRECT_ARGUMENT` (`0x200`). - Submitting the same lists in **separate calls** produced no such error. - Submitting them in one call with a test-only cross-list `INDIRECT_ARGUMENT → UNORDERED_ACCESS` transition at the second entry also produced no such error. All three runs signaled completion and produced the expected 67 groups. The output therefore does not demonstrate visible corruption; the debug-layer result identifies a state-tracking issue for a batched submission. XCL can submit multiple command lists in one driver call. I did not test a physical GPU, retail incidence, performance, or an author fix. AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report.
andrewDoing commented 2026-11-28 03:11:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T03:11:03Z.


Follow-up to the cross-list state error: I tested a fixture-only mitigation on head d6f30c18 using Windows WARP and the D3D12 debug layer. Each physical command list transitions the shared guard output from INDIRECT_ARGUMENT back to COMMON immediately before close, while keeping it in INDIRECT_ARGUMENT between checks inside that recording.

The stock batch control emitted two state errors. The close-time transition emitted none for forward and reversed list submission, replay after fence completion, or lists discarded and reset before submission. Each run executed the expected 134 groups.

This is not a complete production fix. Deferred segments, mid-list splits, and KickoffX have paths that call the original PC Close directly and would need equivalent handling. Cross-queue concurrency, physical GPU behavior, and retail performance were not tested. The explicit transition is a useful control for the recorded-list ordering tested here, not proof that every close path is covered.

AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report.

<!-- greyfinch-sync:ivall/xcl:comment:7232861015 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3009#issuecomment-7232861015). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-28T03:11:03Z. --- Follow-up to the cross-list state error: I tested a **fixture-only mitigation** on head `d6f30c18` using Windows WARP and the D3D12 debug layer. Each physical command list transitions the shared guard output from `INDIRECT_ARGUMENT` back to `COMMON` immediately before close, while keeping it in `INDIRECT_ARGUMENT` between checks inside that recording. The stock batch control emitted two state errors. The close-time transition emitted none for forward and reversed list submission, replay after fence completion, or lists discarded and reset before submission. Each run executed the expected 134 groups. This is not a complete production fix. Deferred segments, mid-list splits, and `KickoffX` have paths that call the original PC `Close` directly and would need equivalent handling. Cross-queue concurrency, physical GPU behavior, and retail performance were not tested. The explicit transition is a useful control for the recorded-list ordering tested here, not proof that every close path is covered. AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report.
Foniass commented 2026-12-01 09:18:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:18:50Z.


Triage (#1607) – head d6f30c1

No open or merged PR makes this change. The 27 lines shared with #3099, #3111, #3112, #3335 and #3361 are the root-signature boilerplate of an indirect_guard GPU test, not this change.
Concern in bind.rs::execute_indirect / indirect_guard::run_keeping: the guard's out buffer is one per device (guard_of), shared by every list. A list now ends with it in INDIRECT_ARGUMENT, and guard_out_ia starts false for the next recording. That relies on buffer state decay to COMMON. Decay happens when an ExecuteCommandLists completes, not between lists of the same call or across queues. A second list in the same ExecuteCommandLists call, or a list on another queue, then writes the buffer as a UAV with no transition out of INDIRECT_ARGUMENT. The new test records a single list, so it does not cover this. A Windows run with the debug layer would show whether this is a state mismatch there.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7306520591 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3009#issuecomment-7306520591). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:18:50Z. --- **Triage (#1607)** – head d6f30c1 No open or merged PR makes this change. The 27 lines shared with #3099, #3111, #3112, #3335 and #3361 are the root-signature boilerplate of an `indirect_guard` GPU test, not this change. Concern in `bind.rs::execute_indirect` / `indirect_guard::run_keeping`: the guard's `out` buffer is one per device (`guard_of`), shared by every list. A list now ends with it in INDIRECT_ARGUMENT, and `guard_out_ia` starts false for the next recording. That relies on buffer state decay to COMMON. Decay happens when an ExecuteCommandLists completes, not between lists of the same call or across queues. A second list in the same ExecuteCommandLists call, or a list on another queue, then writes the buffer as a UAV with no transition out of INDIRECT_ARGUMENT. The new test records a single list, so it does not cover this. A Windows run with the debug layer would show whether this is a state mismatch there. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3009:upstream-pr/3009'
git switch 'upstream-pr/3009'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3009'
git switch 'upstream-pr/3009'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3009'
git switch 'upstream-pr/3009'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3009'
git switch 'main'
git merge --squash 'upstream-pr/3009'
git switch 'main'
git merge --ff-only 'upstream-pr/3009'
git switch 'main'
git merge 'upstream-pr/3009'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3009
No description provided.