Skip to content

D3D12.X: DXC compiles XCL's own HLSL when D3DCompile refuses it - #3018

Draft
voiceovarian1-max wants to merge 1 commit into
xcl-dev:mainfrom
voiceovarian1-max:pr/nv-dxc-fallback
Draft

voiceovarian1-max wants to merge 1 commit into
xcl-dev:mainfrom
voiceovarian1-max:pr/nv-dxc-fallback

Conversation

@voiceovarian1-max

Copy link
Copy Markdown

For nvidia-dev. real::compile builds XCL's own small programs with D3DCompile: the indirect count check's (indirect_guard), the scatter program and the stand-ins. Under Wine, D3DCompile is Wine's own HLSL compiler, and it refuses the count check's program:

E5005: Method 'Load3' is not defined on type 'RWByteAddressBuffer'

compile returned nothing and the count check was off (ExecuteIndirect: the counts are not checked (its program does not compile)). In a retail title, an indirect dispatch whose group counts came from GPU-written floats (0x3f800000 x 0x3eafef26 x 0x3d146851) then never ended, and the device was removed. With this change, DXC compiles the program as cs_6_0, the check works, and a 300 s run of the same title had no GPU-wait timeout and no device removal (41 out-of-range dispatches were not run). Where D3DCompile takes the program, as on Windows, nothing changes. compile's refusal message is now logged.

This is also why #3009's new test and nvidia-dev's an_execute_indirect_with_garbage_counts_* tests fail under Wine.

What is in it

  • hle/d3d12x/real.rs: compile reads D3DCompile's errors and falls back to dxc::compile for the 6.0 profile. Test a_program_d3dcompile_refuses_still_compiles.

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. DXC 1.9.2609.5 (XCL_DXC_DIR). Head 25656f87 on nvidia-dev 3f39671d.
  • Whole lib suite under Wine (cargo test -p xcl --lib -- --test-threads=4):
    • this head: 1693 passed, 7 failed, 28 ignored
    • nvidia-dev 3f39671d: 1691 passed, 8 failed, 28 ignored
    • Fixed here: an_execute_indirect_with_garbage_counts_draws_nothing and an_execute_indirect_with_garbage_counts_runs_no_groups.
    • Failing here and not on nvidia-dev: watch::tests::a_thread_in_the_driver_is_seen_until_it_returns. It is timing-dependent under the full parallel suite: watch:: alone passed 5 of 5 runs (9 passed each) on this head.
  • The retail-title runs above are from our Linux tree, which carries the same change, not from this branch.

Regression run

  • None: scripts/smoke.ps1 needs Windows, and we only have Linux. On Windows, D3DCompile compiles these programs, so the new path is not taken.

Not tested

  • Windows, AMD, a retail title on this branch.

AI use

  • Claude Code with Claude Opus 5.5: found the refused program in a run's log, wrote the change, the test and this description, and ran the tests.

🤖 Generated with Claude Code

`real::compile` builds XCL's own small programs with D3DCompile: the
indirect count check's (`indirect_guard`), the scatter program and the
stand-ins. Under Wine, D3DCompile is Wine's own HLSL compiler, which refuses
the count check's program (`E5005: Method 'Load3' is not defined on type
'RWByteAddressBuffer'`). The check was then off, and in a retail title an
indirect dispatch with group counts read from GPU-written floats
(0x3f800000 x ...) never ended and the device was removed. The compiler's
error is now read and logged, and DXC compiles the program for the matching
6.0 profile. Where D3DCompile takes the program, as on Windows, nothing
changes. Test `a_program_d3dcompile_refuses_still_compiles`.

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

ettehn commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

On native Windows x64 (RTX 5070 Ti Laptop, DXC 1.8.2502.11), Load3 takes the existing D3DCompile path. A one-thread compute shader using WaveActiveSum also gives you a way to exercise the fallback on Windows. I copied real::compile unchanged from 25656f87 into a small harness linked to my existing XCL DXC wrapper and GPU runner.

  • Load3 on [2, 3, 7] produced an SM5 SHEX chunk and wrote the expected sum 12.
  • WaveActiveSum(b.Load(0)) + b.Load(4) with one active lane got X3004 from D3DCompile, produced a DXIL chunk through the cs_6_0 retry, and wrote the expected 5 on the GPU.
  • An undefined function produced diagnostics from both compilers and returned empty bytecode.

This covers the compiler selection and GPU execution in isolation. The full PR build, indirect count guard and retail smoke were outside this run. AI-assisted verification with OpenAI Codex (GPT-6).

@JJAutoCompare

Copy link
Copy Markdown

Tested

Clean detached PR head 25656f87fcf2da20d7a36d420b2fd588b029cd0d on native Windows 11 x64 build 26200.9974, AMD Ryzen 7 3800X, Rust/Cargo 1.100.0 MSVC, and Windows SDK DXC/DXIL 1.9.2602.17. CPU only, using the debug test profile.

cargo test --locked -j 2 -p xcl --lib hle::d3d12x::real::compile_tests::a_program_d3dcompile_refuses_still_compiles -- --exact --nocapture --test-threads=1

1 passed, 0 failed, 0 ignored, 0 skipped, with 1,727 filtered out and Cargo exit 0. Cargo reused the pinned exact-head libtest binary. DXC initialized and the stock Load3 fixture returned nonempty bytecode. The run emitted no fallback diagnostic.

Not tested

Forced D3DCompile refusal and DXC retry, GPU execution, indirect count guard, full workspace suite, and retail smoke.

AI use

T3 Code / Codex (gpt-6.2-sol) independently reran the stock test and wrote this report.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 25656f8

#3536 fixes the same failure (Wine's d3dcompiler refusing the indirect guard's Load3 on a RWByteAddressBuffer) by compiling the guard itself with DXC, with a D3DCompile fallback; this PR instead makes every real::compile caller fall back to DXC.
In real::compile: when only one of a VS/PS pair is refused, the caller gets DXBC for one stage and DXIL for the other, which one PSO cannot mix (the dummy pipelines compile vs_5_0/ps_5_0 separately).
a_program_d3dcompile_refuses_still_compiles passes on Windows without the fix, since Windows' D3DCompile accepts Load3; it only exercises the fallback under Wine.
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