GPU: our compute shaders compiled by the build on Windows #2093
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2093
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2093"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Deilach on GitHub · 2026-11-25 04:41 UTC · original
Deilach:linux-prebuilt-shaders→main· +408 −199 · 7 files · 1 commits · openWhat
Two of VIctory's own compute shaders run in the game: the indirect-argument clamp (
indirect.rs) and the 16-bit depth conversion (twin.rs). Both are compiled at first use withD3DCompile. Under Wine and Proton that call goes to Wine's own HLSL compiler (vkd3d-shader), which compiles neither:clamp,depth:E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'[RootSignature]attribute is ignored (W5302), so even a shader it does compile has no root signature forCreateRootSignatureThe result on Linux is a silent black world. Indirect execution is dropped ("no argument clamp"), and 16-bit depth written through unordered views never reaches the depth texture. The only workaround is installing Microsoft's
d3dcompiler_47into the prefix.Change
crates/victory-gpu/src/shaders/{clamp,depth}.hlsl.crates/victory-gpu/build.rscompiles everysrc/shaders/*.hlslwhen the build runs on Windows for Windows. It uses the system'sd3dcompiler_47.dllthroughraw-dylib, with no new dependencies, and the same entry point, profile (cs_5_1) and flags as at runtime.OUT_DIRand is embedded withinclude_bytes!. Nothing compiled enters the repository, andcargo xtask policypasses.cargo build, instead of failing at first use in the game.crate::hlslmodule makes both pipelines. It uses the embedded bytecode when there is some, and otherwise compiles at first use as before. That covers cross builds, where a build script can't run Microsoft's compiler.d3dcompiler_47.bindless,memory,draw,pipeline::library) are untouched.On Windows the runtime behaviour is unchanged: the same bytecode, made at build time instead of first use.
When the shaders are embedded
cfg(all(windows, target_env = "msvc"))inbuild.rs), and the target OS is Windows. That's the documented build. The bytecode comes from that machine'sd3dcompiler_47.dll.windows-gnuhost. These compile at first use, as before.d3dcompiler_47.dll. The binary still importsD3DCompilefor the first-use path. Windows ships that DLL, and Wine and Proton always provide their own, so the import always resolves. What changes is that a non-working compiler (Wine's) no longer costs the two pipelines.Tests
hlsl::tests::our_shaders_make_pipelines: both shaders make a pipeline.hlsl::tests::prebuilt_shaders_are_what_the_system_compiler_makes: the build's bytecode is byte-identical to whatD3DCompilemakes at runtime. I checked locally thatd3dcompiler_47output is deterministic and doesn't depend on the source name.I ran these on Linux: Wine 11.22 with vkd3d-proton master on RADV, an RX 9070 XT. A Linux build can't run the Windows build-script path, so I compiled
build.rsitself for Windows and ran it under Wine with Microsoft'sd3dcompiler_47. It wrote both.dxbcfiles, 3,096 and 3,656 bytes, the same as a runtime compile. With Wine's compiler swapped in, it fails the build, as intended. Results:our_shaders_make_pipelinesprebuilt_…_compiler_makesd3dcompiler_47cargo clippy --workspace --all-targets [--all-features] -- -D warningsis clean, and the new files are rustfmt-clean. Thevictory-gpuandvictory-shadertests under Wine matchmainplus the new tests. CI onwindows-latestexercises the build-script path.🤖 Generated with Claude Code
@jeremygold02 on GitHub · 2026-11-25 04:45 UTC · original
Triage verdict — Keep the Windows prebuild, preserve the cross-build fallback work (
e4e1af2)Evidence
Checks and limits
Next step
This verification was AI-assisted.
@upipibi on GitHub · 2026-11-25 04:48 UTC · original
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
e4e1af2.victory-gpu: 143 passed, 2 failed, 2 ignored. The newour_shaders_make_pipelinesandprebuilt_shaders_are_what_the_system_compiler_makespass. The 2 failures are #1744's heap-cap failures onmain. Same asmainon this hardware.AI-assisted (Claude Code).
@Dathinel on GitHub · 2026-11-25 04:56 UTC · original
I checked the production executable requested above at
e4e1af2on Windows x64 MSVC (cargo build --release --frozen -p victory, default features).victory.exe: clamp 3,096 bytes, depth 3,656 bytes.D3DCompilefromd3dcompiler_47.dllin its ordinary PE import table. This can be reproduced withdumpbin /imports target\release\victory.exe. The loader must resolve the symbol even if neither shader is compiled at first use.hlsl.rsfor the prebuilt, non-test configuration. That removed the DLL from both the executable's ordinary and delay imports. Both embedded blobs remained identical and the separate build helper still imported the compiler.If the distribution goal includes removing that direct DLL dependency, the existing
victory_hlsl_prebuiltcfg can select the embedded-only path at compile time while retaining compilation for cross builds and the comparison test. This was binary inspection; I did not test startup under Wine with a DLL removed. AI-assisted.@Deilach on GitHub · 2026-11-25 04:59 UTC · original
Thanks for the triage. On the next steps:
Build condition. The shaders are embedded only when the build script runs on a Windows host with the MSVC toolchain (
cfg(all(windows, target_env = "msvc"))) and the target OS is Windows. Every other build compiles them at first use, as before: Linux cross builds, and awindows-gnuhost. I've added this to the description.Compiler DLL at startup. That isn't part of the claim. A built
victory.exestill importsD3DCompilefromd3dcompiler_47.dll(checked withllvm-readobj --coff-imports), because the first-use path needs it. The claim is that it needs no working HLSL compiler. Windows ships the DLL and Wine and Proton always provide their own, so the import resolves wherever VIctory runs; Wine's compiler just can no longer break the two pipelines. In-game check on Linux: an exe with the embedded bytecode, running on Wine's ownd3dcompiler_47, loaded into the world (up to ~4,600 draws a frame) with neither the "no argument clamp" nor the "no depth conversion" warning. A lazily loaded compiler would only matter on a system with no DLL at all. Happy to add it if wanted.#1279. I agree it's complementary. It makes the clamp's source build with Wine's compiler, which also covers cross builds at first use. This PR embeds the clamp and the depth conversion in Windows-built binaries. Both change
indirect.rs::make, so whichever lands second needs a rebase. With #1279 the clamp's root signature is serialized beside the shader, socrate::hlslwould take that instead of reading it from the blob. I can rebase onto #1279 if it goes first.@Marvisak on GitHub · 2026-11-25 10:34 UTC · original · edited 2026-11-25 15:57 UTC
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/victory-gpu/src/indirect.rs,crates/victory-gpu/src/twin.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (needs-work) was for an older state ofmain.Generated by Claude Code
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.