Skip to content

GPU: compile internal HLSL and serialize root signatures natively under Wine/Proton - #127

Open
BitWuehler wants to merge 1 commit into
fxceless:mainfrom
BitWuehler:wine-hlsl-compat
Open

BitWuehler wants to merge 1 commit into
fxceless:mainfrom
BitWuehler:wine-hlsl-compat

Conversation

@BitWuehler

Copy link
Copy Markdown

What & Why

Under Wine/Proton, built-in d3dcompiler_47 (vkd3d-shader) refuses victory-gpu's internal HLSL in two ways (see #20, #28):

  1. ByteAddressBuffer / RWByteAddressBuffer methods (E5005) and [allow_uav_condition] (E5017) fail compilation in the indirect-argument clamp (indirect.rs) and CARD_COMPARE (host.rs).
  2. [RootSignature(RS)] annotations are stripped (no RTS0 chunk), causing ID3D12Device::CreateRootSignature over the shader bytecode to fail with E_FAIL (0x80004005) in CARD_COMPARE, PlanePass (no pipeline to draw a depth plane from its twin), and unit tests (resource::tests::a_depth_planes_twin_is_drawn_into_the_plane, indirect::tests::WORKER_CS).

Rather than requiring an external DXC/DXIL SDK fallback at runtime, this change adjusts the four small internal shaders and serializes their root signatures in Rust so Wine's built-in d3dcompiler_47 (vkd3d-shader) compiles everything natively with zero external DLLs:

  • Structured word buffers + Wine-safe HLSL (host.rs, indirect.rs):
    • Replaced ByteAddressBuffer / RWByteAddressBuffer (Load/Store/atomic methods) with 32-bit word-indexed StructuredBuffer<uint> / RWStructuredBuffer<uint> in CARD_COMPARE, indirect.rs's clamp shader SOURCE, and test WORKER_CS. Since D3D12 root SRVs/UAVs bind raw buffer GPU VAs with identical descriptors for 4-byte-aligned word buffers, no pipeline binding changes are needed (>> 2 / * 4 preserves exact byte offsets).
    • Removed [allow_uav_condition] in indirect.rs.
    • Added compiler error-blob warning logging to make_card_work in host.rs (matching host::compile).
  • Rust-serialized root signatures (host.rs, indirect.rs, resource.rs):
    • Added shared crate::host::root_signature_from_params (plus root_param_constants and root_param_descriptor) using D3D12SerializeRootSignature, and removed #define RS / [RootSignature(RS)] across CARD_COMPARE, PlanePass (PLANE_STEPS / PLANE_FLOATS), indirect.rs (SOURCE, WORKER_CS), and resource.rs (a_depth_planes_twin_is_drawn_into_the_plane).
  • Test coverage (indirect.rs):
    • Added indirect::tests::system_d3dcompile_builds_internal_hlsl compiling all 6 internal HLSL entrypoints (clamp, card_compare, plane_corners, plane_steps, plane_floats, worker_cs) through crate::host::compile.

Verification

Tested on CachyOS Linux (GE-Proton11-14, vkd3d-proton, NVIDIA RTX 5080, driver 620.73.4, VKD3D_DISABLE_EXTENSIONS=VK_NV_raw_access_chains):

  • cargo xtask policy: 169 files ok
  • cargo clippy -p victory-gpu --all-targets --target x86_64-pc-windows-msvc -- -D warnings: passed (0 warnings)
  • cargo build --release -p victory --target x86_64-pc-windows-msvc: passed
  • Full victory-gpu test suite under Proton (GE-Proton11-14): 110 passed, 1 ignored, 1 failed
    • All HLSL, indirect, card-compare, and depth/stencil twin tests pass (indirect::tests::system_d3dcompile_builds_internal_hlsl, indirect::tests::argument_clamp_builds, indirect::tests::warp_card_compare_stores_the_hash_it_made_when_told, resource::tests::a_depth_planes_twin_is_drawn_into_the_plane, etc.).
    • The 1 failure is pipeline::library::tests::a_rejected_blob_gives_an_empty_library (ID3D12Device1::CreatePipelineLibrary unimplemented stub in vkd3d-proton, same unrelated failure noted in GPU: compile our run-time HLSL with DXC when the system compiler refuses it (Wine/Proton) #20).
  • World runtime check (prior commit with CARD_COMPARE + indirect fixes active on 4e17478 + VICTORY_RELAY=2 + upstream #454): reached playable lit world for 464s / 3,815 frames with zero device losses and zero no argument clamp / no host copies in the card warnings. Logging no pipeline to draw a depth plane from its twin (0x80004005) in that run led to including PlanePass in this PR as well.

(Prepared and tested with AI assistance.)

@BitWuehler

Copy link
Copy Markdown
Author

Additional in-world confirmation from 232121.log (GE-Proton11-14, RTX 5080 620.73.04, 353 s, 0 crashes/Xids): PlanePass not only compiles without 0x80004005 warnings now (0 vs 2 previously), it actively executes on vkd3d-proton (depth planes: 2.0 drawn from their twins per frame in the final 5,426-draw interval vs 0.0 before).

@ErRusso ErRusso left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at cc79860 against 2119b0e.

The no-DLL approach is interesting, but it is a competing implementation of #20 and is not complete:

  • It rewrites the internal shaders to structured word buffers and serializes root signatures, but it does not touch inplace.rs, so the in-place probe still uses RWByteAddressBuffer/Load/Store and still fails under Wine.
  • It replaces the shaders rather than falling back, so every shader change has to preserve byte/word offsets and root layouts manually; #20 keeps the existing HLSL and is validated on Proton Experimental and GE-Proton11-14.
  • The world run is from a prior commit on 4e17478 with extra switches, not this head.

Please close/coordinate with #20, or add the in-place probe and a current-head integration run. As a duplicate, it should not merge alongside #20.

@Filip722

Copy link
Copy Markdown

Confirmed the card-compare fix on an RTX 5060 Laptop GPU (8 GB), Bazzite 44, NVIDIA 615.78.08, Proton Experimental 11.0-20261112 and vkd3d-proton ec20719. With the same Series S display changes in both builds, an asset-free call to Host::make_card_work failed with E_FAIL before cc79860 and passed afterward. The PR’s six-shader compiler test also passed using Wine’s built-in compiler.

In the running Series S account picker, the control reported zero GPU-side buffer copies and logged the card-compare initialization failure. With this PR applied it reported one 174 MiB GPU-side copy. Gameplay performance was outside this comparison. OpenAI Codex assisted with testing and this report.

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.

3 participants