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

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

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


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

<!-- greyfinch-sync:ivall/xcl:issue:5526755118 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3018). Originally posted by [voiceovarian1-max](https://github.com/voiceovarian1-max) on 2026-11-27T12:37:52Z. --- 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](https://claude.com/claude-code)
ettehn commented 2026-11-27 12:44:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ettehn on 2026-11-27T12:44:24Z.


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).

<!-- greyfinch-sync:ivall/xcl:comment:7218615563 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3018#issuecomment-7218615563). Originally posted by [ettehn](https://github.com/ettehn) on 2026-11-27T12:44:24Z. --- 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 commented 2026-11-27 13:12:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-27T13:12:17Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7219186535 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3018#issuecomment-7219186535). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-27T13:12:17Z. --- **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. ```powershell 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 commented 2026-12-01 09:20:10 +00:00 (Migrated from github.com)

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


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.

<!-- greyfinch-sync:ivall/xcl:comment:7306552107 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3018#issuecomment-7306552107). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:20:10Z. --- **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.
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/3018:upstream-pr/3018'
git switch 'upstream-pr/3018'

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/3018'
git switch 'upstream-pr/3018'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3018'
git switch 'upstream-pr/3018'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3018'
git switch 'main'
git merge --squash 'upstream-pr/3018'
git switch 'main'
git merge --ff-only 'upstream-pr/3018'
git switch 'main'
git merge 'upstream-pr/3018'
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!3018
No description provided.