Skip to content

D3D12.X: skip direct draws and unmatched ExecuteIndirect on two-pass MS/GS PSOs - #2028

Open
raylitebull wants to merge 1 commit into
xcl-dev:mainfrom
raylitebull:fix/bind-twopass-close-invalidarg-v2
Open

raylitebull wants to merge 1 commit into
xcl-dev:mainfrom
raylitebull:fix/bind-twopass-close-invalidarg-v2

Conversation

@raylitebull

Copy link
Copy Markdown
Member

Prevents bind.rs from falling through to raw PC DrawInstanced, DrawIndexedInstanced, and non-DispatchMesh ExecuteIndirect calls against finished two-pass MS/GS mesh-shader pipelines, eliminating ID3D12GraphicsCommandList::Close() E_INVALIDARG (0x80070057) failures.

Part of #1833.

What is in it

  • crates/xcl/src/hle/d3d12x/bind.rs (+128 / -1): guard graphics_bound and the execute_indirect non-DispatchMesh fallthrough on two_pass_of(...) so finished two-pass pipelines registered in TWO_PASS are never bound with the title's graphics root signature for incompatible direct/indirect draw calls, plus CPU regression unit tests (hle::d3d12x::bind::).
  • crates/xcl/src/hle/d3d12x/real.rs (+17): add #[cfg(test)] helper register_two_pass_for_test for the unit tests.

Tested

  • Toolchain: Windows 11 x64, rustc 1.99.1 (58cf8f9c3 2026-10-13), base 279d3ea (a7b478b).
  • cargo check --workspace --tests: passed (0 new warnings).
  • cargo test -p xcl --lib hle::d3d12x::bind::: 7 passed, 0 failed.

Regression run

  • Standalone scripts/smoke.ps1 pair on a7b478b vs 279d3ea has not been run locally. AMD and NVIDIA reviewers are invited to test on a7b478b vs 279d3ea (including scripts/smoke.ps1 and two-pass MS/GS titles) and post results in the comments.

Not tested

  • 60 s scripts/smoke.ps1 pair on a7b478b, full cargo test --workspace suite, runtime GPU execution across AMD / NVIDIA / Intel hardware, and Linux/Wine/vkd3d-proton.

AI use

  • Antigravity assisted with implementation and unit tests; the author reviewed the diff and test output.

…MS/GS PSOs

Finished two-pass MS and GS pipelines are PC mesh shader (MS+PS) pipelines registered in TWO_PASS rather than TRANSLATED_GRAPHICS. Previously, once async compilation completed, graphics_bound and the non-DispatchMesh fallthrough in execute_indirect treated them as untranslated PC pipelines, bound the title's graphics root signature, and issued DrawInstanced/DrawIndexedInstanced/ExecuteIndirect against the bound mesh PSO, causing D3D12 Close() to fail with E_INVALIDARG (0x80070057). Guard both paths on two_pass_of(...) so finished two-pass pipelines never fall through to incompatible direct/indirect draw calls, and add a CPU regression test.
@Anon64

Anon64 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run for this PR: head a7b478b, based on main 0be6ce8. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, XCL_NETWORK=0, A pressed every 4 s from 20 s, scripts/smoke.ps1 on a retail title for 60 s, back to back with the main run.

main 0be6ce8:

xcl-smoke v1
commit: 0be6ce8cc20a9de06e6f0f443113af42a6c21248
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1584 (PresentX 1585)
presents per 2 s (last 3): 53 53 46
device removals: 0
crashes: 0
peak commit: 20052 MB

this PR:

xcl-smoke v1
commit: a7b478ba50c2afabb6421ada995af029cd9bef5a
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1504 (PresentX 1504)
presents per 2 s (last 3): 44 10 3
device removals: 0
crashes: 0
peak commit: 24046 MB

No device removals or crashes; 94 % of main's frames, 119 % of its peak commit.

Not tested: the whole suite; world loading; whether the title reaches the changed code in these 60 s.

Written with Claude Code (Claude Opus 5.5) from runs on this machine.

@JoaoPauluu

Copy link
Copy Markdown

A regression run under Wine on Linux on the retail title: no device removal, no crash, frames level with main (1398 here, 1357 and 1365 on the two main runs). Neither of the PR's new warnings appears in the log, so the two-pass MS/GS path is not reached in this 60 s run; this is a regression run only.

Tested

Regression run

main (first run):

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1357 (PresentX 1357)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

this PR:

xcl-smoke v1
commit: a7b478ba50c2afabb6421ada995af029cd9bef5a
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1398 (PresentX 1398)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

The second main run: 1365 frames, exit: 0x0, no device removal, no crash. Under Wine, peak commit reads 0 MB, so these blocks do not check memory.

Not tested

  • the test suite on this head, a scene that uses the two-pass MS/GS pipelines, native Windows.

AI use

  • Claude Code (Claude Opus 5.5) built both commits, ran the runs and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@JJAutoCompare

Copy link
Copy Markdown

Empirical verification — PR #2028 (a7b478ba50c2afabb6421ada995af029cd9bef5a)

Tested clean detached PR head a7b478ba50c2afabb6421ada995af029cd9bef5a on STOR-WINLAB.

Environment

  • Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB (driver 32.0.101.9175, wave range 8–32, DoublePrecisionFloatShaderOps=0, d3d12SDKLayers.dll absent).
  • rustc 1.100.0 (0ef1bc386 2026-11-09) (CARGO_INCREMENTAL=0, debug info 0). Standalone DXC/DXIL 1.9.2609.5 was on PATH; the test title logged Windows SDK DXC 1.9.2602.17 (21d28f72).

Tested

  • cargo build --workspace and cargo test --workspace --no-run exited 0 outside the GPU lock.
  • cargo test -p xcl --lib two_pass_pso_skips_direct_draw_and_unmatched_execute_indirect -- --nocapture: 1 passed, 0 failed, 0 ignored, 0 skipped (also passed in workspace suite; verified both direct-draw guard and unmatched ExecuteIndirect skip without binding graphics root signature or calling fake native ExecuteIndirect).
  • cargo test --workspace --no-fail-fast -- --test-threads=4 (under Invoke-ArcTest.ps1, exited 101): 1,054 passed, 27 failed, 46 ignored across 20 test binaries, with 23 SKIPPED lines across 13 tests (excluded from coverage; libtest pass counts include early returns).
    • Failures (27): 26 in xcl --lib shader/DXIL tests (22 CreateComputePipelineState 0x80070057, 4 shader output assertions: gpu_nonfused_mad_and_mac_prevent_fma_contraction, gpu_ps_image_sample_offset_implicit_lod_between_mips, gpu_valu_16_and_64_bit, gpu_wave64_ps_whole_wave_reductions) plus e2e::test_title_runs_and_game_folder_is_untouched (RSSetDepthBiasX Split wave64: masks read only lane by lane stay in their half #94 blue vs green). Unrelated to two-pass MS/GS guards (no same-run main baseline).
    • Skips (23 visible lines): 18 wave64 unavailable, 3 refused wave32 per-lane lowerings, 1 driver-cache disable unavailable, 1 heap-window fallback unavailable; missing debug-layer early return captured separately (0x887A002D).

Not tested

  • Retail Xbox title runs, real-title two-pass MS/GS command lists, scripts/smoke.ps1, matched main baseline, and D3D12 debug-layer validation.

AI use

  • T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr2028-suite.log and published this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

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.

5 participants