Skip to content

Wine/Proton: build the title's helper shaders with dxc when available - #7

Open
DaemonSimon wants to merge 1 commit into
JoshuuDev:victory-amdfrom
DaemonSimon:pr-a-dxc
Open

DaemonSimon wants to merge 1 commit into
JoshuuDev:victory-amdfrom
DaemonSimon:pr-a-dxc

Conversation

@DaemonSimon

@DaemonSimon DaemonSimon commented Nov 25, 2026 •

Copy link
Copy Markdown

What

The title's helper shaders (argument clamp in indirect.rs, card compare and depth plane pass in host.rs) move to crates/victory-gpu/src/shaders/*.hlsl, embedded with include_str! (unchanged, except that the plane entry points are now main). A new crates/victory-gpu/build.rs compiles them with dxc (DXC environment variable, else dxc on the PATH) to DXIL in OUT_DIR (cs_6_0 / vs_6_0 / ps_6_0, entry main, -rootsig-define RS where the source defines RS) and embeds the result with include_bytes!. Without dxc the embedded files are empty and behaviour is as before (D3DCompile at first use). A README paragraph (Wine / Proton / Linux) explains the step.

At run time the embedded DXIL is used when D3DCompile fails, or, for the plane shaders, when it gives no usable root signature.

Why

Wine's D3DCompile (vkd3d-shader) does not build these shaders: E5005: Method 'InterlockedMax' / 'Load' is not defined on type 'RWByteAddressBuffer' for the compute shaders, and the plane pixel shaders come out without a root signature. Consequence on Wine: about 5,000 indirect draws per frame are dropped ("no argument clamp"), the depth planes stay unchanged, and the world is black and empty.

Same idea as Marvisak/VIctory#2093 (shaders compiled by the build, nothing compiled in the repository), but with dxc, so it also works for the Linux cross build, where Microsoft's d3dcompiler_47 is not available to a build script.

No compiled file is committed (cargo xtask policy passes: 177 files ok).

Tested (one machine; no Windows test)

RX 9070 XT, Wine 11, Linux, cross build (x86_64-pc-windows-msvc, xwin SDK, dxc 1.10 from nixpkgs):

  • cargo check -p victory-gpu --target x86_64-pc-windows-msvc: ok with and without dxc.
  • The DXIL dxc builds has the sizes of the DXIL I had been testing with by hand (clamp 5,360, plane-steps 3,612, plane-floats 3,552 bytes).
  • Diag build of this change (with the follow-up PR "Card compare: one 64-thread group per 64 KiB piece" on top), 150 s run, Enter pressed every 8 s from 20 s: the log shows all three fallbacks used ("argument clamp ... using the DXIL built with dxc", "card compare ...", "depth plane pass ..."), the world is reached: 6,000+ draws/frame, ~3.4 fps. One run only.

Not tested: Windows (the D3DCompile path is unchanged there; the DXIL is only a fallback), a build on Windows with dxc installed, the unit tests under Wine, a run of this branch without the follow-up. That the world is empty without this change is what I see on this machine, not a measured comparison in this PR.

Note: with the card compare working under Wine, card buffers (on by default) are really used there; before they fell back, because the shader did not compile. See the follow-up PR for the cost of that pass.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

The argument clamp, the card compare and the depth plane pass compile
their HLSL at first use with D3DCompile. Wine's D3DCompile (vkd3d-shader)
builds none of them: E5005 "Method 'InterlockedMax'/'Load' not defined on
RWByteAddressBuffer" for the compute shaders, and the plane pixel shaders
come out without a root signature. Indirect execution is then dropped and
the depth planes stay unchanged, so the world is black and empty.

The sources move to crates/victory-gpu/src/shaders/*.hlsl (embedded with
include_str!, unchanged apart from the plane entry points, now `main`).
A new build.rs compiles them with dxc to DXIL in OUT_DIR when dxc is
available (DXC environment variable, else PATH) and embeds the result.
At run time the embedded DXIL is used when D3DCompile fails or, for the
plane shaders, gives no usable root signature. Without dxc nothing
changes. No compiled file enters the repository.

AI-assisted (Claude Code).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

1 participant