Skip to content

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

Draft
voiceovarian1-max wants to merge 1 commit into
xcl-dev:mainfrom
voiceovarian1-max:pr/nv-count-check-ia
Draft

voiceovarian1-max wants to merge 1 commit into
xcl-dev:mainfrom
voiceovarian1-max:pr/nv-count-check-ia

Conversation

@voiceovarian1-max

@voiceovarian1-max voiceovarian1-max commented Nov 27, 2026 •

Copy link
Copy Markdown

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. D3D12.X: DXC compiles XCL's own HLSL when D3DCompile refuses it #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

The indirect count check (`indirect_guard`) moved its count buffer to
INDIRECT_ARGUMENT for each ExecuteIndirect and back to COMMON after it: two
transitions per check, each a barrier the GPU waits at. The buffer now stays
INDIRECT_ARGUMENT from one check to the next on a list (`check_in`,
`run_keeping`, `guard_out_ia`) and goes back only when something else needs
it. GPU test included.

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

Lum7nt commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

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.

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.

4 participants