gpu: host shaders fall back to dxcompiler.dll when D3DCompile refuses them (indirect clamp on Wine) #1285

Closed
github-bot wants to merge 1 commit from gh-pr/1285/head into gh-pr/1285/base
Owner

@⁠YaBulochka on GitHub · 2026-11-26 10:31 UTC · original
YaBulochka:dxc-fallback → main · +358 −3 · 4 files · 1 commits · closed without merging

Wine's d3dcompiler_47 is vkd3d-shader's compiler, and it refuses two host shaders we cannot do without. When D3DCompile fails, compile the same source through dxcompiler.dll as <stage>_6_0 instead.

What fails today

Under Wine the indirect clamp never builds:

WARN victory_gpu::indirect: argument clamp: clamp:122:10: E5005: Method 'InterlockedOr' is not defined on type 'RWByteAddressBuffer'
WARN victory_gpu::indirect: no argument clamp: indirect execution dropped error=Call failed. (0x80004005)

With no clamp every indirect execution is dropped — kinds 0/1/2/10, about 2,500+ a frame on the retail title — so the world is black or a flat colour and only menus draw (12 draws a frame). The two-plane composer fails the same way (E5005: GetDimensions is not defined on type 'RWTexture2D<float4>', then two-plane composer not made; showing base plane only), which costs the 2D layer.

The change

  • crates/victory-gpu/src/dxc.rs: DxcCreateInstance + IDxcCompiler3::Compile through LoadLibraryW("dxcompiler.dll"), DXC_OUT_OBJECT for the blob, DXC_OUT_ERRORS logged when the compile fails. The profile is the requested one with _5_1 mapped to _6_0.
  • host::compile: on a D3DCompile failure, try DXC; VICTORY_DXC=1 forces the fallback (for testing and for A/B runs).
  • indirect::make_from: the clamp is compiled by DXC first when the DLL is present, with the FXC path unchanged otherwise. build() takes the bytes, so either compiler's output goes to the same root signature and pipeline code.

On Windows nothing changes: D3DCompile succeeds, the fallback is never reached, and the DLL is not required. On Wine 11.22 and Proton Experimental's wine the shader builds and the world renders. Wine 10.0 cannot compile it either way — it lacks GroupMemoryBarrierWithGroupSync, InterlockedAdd and structured-buffer stores — so the docs should say 11.22+.

Measured

Retail 1.0.2.1, Radeon RX 7600 XT 8 GB, RADV (Mesa 27.0.0), Wine 11.22, vkd3d-proton from master, main f6a09d3 plus this patch only, Series S, VICTORY_TEXTURE_BUDGET_MB=4096, VICTORY_RELAY=2, VICTORY_JOIN_COPIES=1, VICTORY_CARD_STEPS=2, dxcompiler.dll/dxil.dll 1.9.2609 next to the executable:

before with the fallback
clamp builds no (E5005) yes, cs_6_0
indirect draws dropped ~2,500+/frame, kinds 0/1/2/10 0
draws/frame 12 (menus only) 3,385 in the world
frames no world frame 128-129 ms standing (~7.8 fps), median 304 ms over 24 world frames

Seven host shaders were built by DXC in that run. No other local patches were applied.

Not in this PR

The two-plane composer and the Series S stretch exist only in forks; the same one-line call into dxc::compile fixes them, and I can send that as a second PR if wanted. VICTORY_DXC=1 is the only new switch; a path-valued version (a directory holding the two DLLs) is what a similar patch in another tree uses, and is easy to switch to if you prefer it.

No game files, captures or logs are included; numbers only.

**@⁠YaBulochka** on GitHub · 2026-11-26 10:31 UTC · [original](https://github.com/fxceless/victory-fork/pull/1285) `YaBulochka:dxc-fallback` → `main` · +358 −3 · 4 files · 1 commits · closed without merging Wine's `d3dcompiler_47` is vkd3d-shader's compiler, and it refuses two host shaders we cannot do without. When `D3DCompile` fails, compile the same source through `dxcompiler.dll` as `<stage>_6_0` instead. ## What fails today Under Wine the indirect clamp never builds: ``` WARN victory_gpu::indirect: argument clamp: clamp:122:10: E5005: Method 'InterlockedOr' is not defined on type 'RWByteAddressBuffer' WARN victory_gpu::indirect: no argument clamp: indirect execution dropped error=Call failed. (0x80004005) ``` With no clamp every indirect execution is dropped — kinds 0/1/2/10, about 2,500+ a frame on the retail title — so the world is black or a flat colour and only menus draw (12 draws a frame). The two-plane composer fails the same way (`E5005: GetDimensions is not defined on type 'RWTexture2D<float4>'`, then `two-plane composer not made; showing base plane only`), which costs the 2D layer. ## The change - `crates/victory-gpu/src/dxc.rs`: `DxcCreateInstance` + `IDxcCompiler3::Compile` through `LoadLibraryW("dxcompiler.dll")`, `DXC_OUT_OBJECT` for the blob, `DXC_OUT_ERRORS` logged when the compile fails. The profile is the requested one with `_5_1` mapped to `_6_0`. - `host::compile`: on a `D3DCompile` failure, try DXC; `VICTORY_DXC=1` forces the fallback (for testing and for A/B runs). - `indirect::make_from`: the clamp is compiled by DXC first when the DLL is present, with the FXC path unchanged otherwise. `build()` takes the bytes, so either compiler's output goes to the same root signature and pipeline code. On Windows nothing changes: `D3DCompile` succeeds, the fallback is never reached, and the DLL is not required. On Wine 11.22 and Proton Experimental's wine the shader builds and the world renders. Wine 10.0 cannot compile it either way — it lacks `GroupMemoryBarrierWithGroupSync`, `InterlockedAdd` and structured-buffer stores — so the docs should say 11.22+. ## Measured Retail 1.0.2.1, Radeon RX 7600 XT 8 GB, RADV (Mesa 27.0.0), Wine 11.22, vkd3d-proton from master, `main` `f6a09d3` **plus this patch only**, Series S, `VICTORY_TEXTURE_BUDGET_MB=4096`, `VICTORY_RELAY=2`, `VICTORY_JOIN_COPIES=1`, `VICTORY_CARD_STEPS=2`, `dxcompiler.dll`/`dxil.dll` 1.9.2609 next to the executable: | | before | with the fallback | |---|---|---| | clamp builds | no (`E5005`) | yes, `cs_6_0` | | indirect draws dropped | ~2,500+/frame, kinds 0/1/2/10 | 0 | | draws/frame | 12 (menus only) | 3,385 in the world | | frames | no world frame | 128-129 ms standing (~7.8 fps), median 304 ms over 24 world frames | Seven host shaders were built by DXC in that run. No other local patches were applied. ## Not in this PR The two-plane composer and the Series S stretch exist only in forks; the same one-line call into `dxc::compile` fixes them, and I can send that as a second PR if wanted. `VICTORY_DXC=1` is the only new switch; a path-valued version (a directory holding the two DLLs) is what a similar patch in another tree uses, and is easy to switch to if you prefer it. No game files, captures or logs are included; numbers only.
Wine's d3dcompiler_47 is vkd3d-shader's compiler: it refuses the indirect
clamp (Interlocked*/Load on a raw buffer) and GetDimensions on a RWTexture2D.
On a Wine host the clamp then never builds, every indirect execution is
dropped, and the world stays black or flat.

When D3DCompile fails, compile the same source through dxcompiler.dll as
<stage>_6_0 (DxcCreateInstance + IDxcCompiler3::Compile). Microsoft's
compiler still runs first on Windows, and VICTORY_DXC=1 forces the fallback
for testing.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:19:49 +00:00
github-bot closed this pull request 2026-11-26 11:19:49 +00:00
Author
Owner

@⁠YaBulochka on GitHub · 2026-11-26 11:02 UTC · original

Closing this: the fallback compiles, and the picture it gives is wrong.

What the DXC-built clamp does to the image

With the fallback in place the world draws at the rate reported above, but characters come out with axis-aligned rectangles of another surface over their skin, hair and clothes (a decoration-bake atlas, blurred frame content). They stay put while the camera holds still and only change when new content streams in, i.e. the arguments the clamp resolves are wrong for part of the indirect clusters, not a texture that has not arrived yet.

Ruled out over several runs: placed-texture keys (#502), placed-alias sources (#1150), remap coherence (#1156), VICTORY_BAKE_SOURCES=1, VICTORY_LEVELS_ON_DEMAND=0, a 12 GB texture budget, and a bare environment with none of the local switches.

What works instead

Microsoft's own d3dcompiler_47.dll, x64 and x86, copied into the prefix over Wine's vkd3d-shader build, with d3dcompiler_47=n in WINEDLLOVERRIDES and no dxcompiler.dll next to the executable:

  • 0 shaders built by DXC; the clamp and the two-plane composer build through D3DCompile as on Windows;
  • no E5005, no dropped indirect execution;
  • the rectangles are gone.

Retail 1.0.2.1, RX 7600 XT 8 GB, RADV (Mesa 27.0.0), Wine 11.22, vkd3d-proton from master, a fork of f6a09d3 with local switches (VICTORY_TEXTURE_BUDGET_MB=4608, VICTORY_CARD_BUFFERS_MB=1024): 1,794 draws a frame, 6.6 of 8.2 GB of VRAM, median 294 ms over 7 world frames while the scene was still streaming.

So the Wine story belongs in the README rather than in the tree: on a host without Microsoft's compiler the clamp cannot be built, and building it with DXC yields a wrong image. The same DLL swap is what Impre-visible/victory-gtx1660 documents for its Linux configuration.

No game files, captures or logs are included; numbers only.

**@⁠YaBulochka** on GitHub · 2026-11-26 11:02 UTC · [original](https://github.com/fxceless/victory-fork/pull/1285#issuecomment-7190193428) Closing this: the fallback compiles, and the picture it gives is wrong. ## What the DXC-built clamp does to the image With the fallback in place the world draws at the rate reported above, but characters come out with axis-aligned rectangles of another surface over their skin, hair and clothes (a decoration-bake atlas, blurred frame content). They stay put while the camera holds still and only change when new content streams in, i.e. the arguments the clamp resolves are wrong for part of the indirect clusters, not a texture that has not arrived yet. Ruled out over several runs: placed-texture keys (#502), placed-alias sources (#1150), remap coherence (#1156), `VICTORY_BAKE_SOURCES=1`, `VICTORY_LEVELS_ON_DEMAND=0`, a 12 GB texture budget, and a bare environment with none of the local switches. ## What works instead Microsoft's own `d3dcompiler_47.dll`, x64 and x86, copied into the prefix over Wine's vkd3d-shader build, with `d3dcompiler_47=n` in `WINEDLLOVERRIDES` and no `dxcompiler.dll` next to the executable: - 0 shaders built by DXC; the clamp and the two-plane composer build through `D3DCompile` as on Windows; - no `E5005`, no dropped indirect execution; - the rectangles are gone. Retail 1.0.2.1, RX 7600 XT 8 GB, RADV (Mesa 27.0.0), Wine 11.22, vkd3d-proton from master, a fork of `f6a09d3` with local switches (`VICTORY_TEXTURE_BUDGET_MB=4608`, `VICTORY_CARD_BUFFERS_MB=1024`): 1,794 draws a frame, 6.6 of 8.2 GB of VRAM, median 294 ms over 7 world frames while the scene was still streaming. So the Wine story belongs in the README rather than in the tree: on a host without Microsoft's compiler the clamp cannot be built, and building it with DXC yields a wrong image. The same DLL swap is what `Impre-visible/victory-gtx1660` documents for its Linux configuration. No game files, captures or logs are included; numbers only.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.