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

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

@⁠BitWuehler on GitHub · 2026-11-24 21:42 UTC · original
BitWuehler:wine-hlsl-compat → main · +248 −61 · 3 files · 1 commits · closed without merging

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 #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** on GitHub · 2026-11-24 21:42 UTC · [original](https://github.com/fxceless/victory-fork/pull/127) `BitWuehler:wine-hlsl-compat` → `main` · +248 −61 · 3 files · 1 commits · closed without merging ## 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 #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.)*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:36:36 +00:00
github-bot closed this pull request 2026-11-26 03:36:36 +00:00
Author
Owner

@⁠BitWuehler on GitHub · 2026-11-24 22:39 UTC · original

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

**@⁠BitWuehler** on GitHub · 2026-11-24 22:39 UTC · [original](https://github.com/fxceless/victory-fork/pull/127#issuecomment-7146500739) 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).
Author
Owner

@⁠Filip722 on GitHub · 2026-11-25 00:17 UTC · original

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.

**@⁠Filip722** on GitHub · 2026-11-25 00:17 UTC · [original](https://github.com/fxceless/victory-fork/pull/127#issuecomment-7148362324) 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.
Author
Owner

@⁠BitWuehler on GitHub · 2026-11-25 21:41 UTC · original

Closing this PR as superseded by #20 (dxc::compile fallback).

Thanks @⁠ErRusso for the review and @⁠Filip722 for confirming the make_card_work and six-shader compiler verification on Proton Experimental.

With main (c36971b) now adding more internal compute shaders (CARD_FETCH, tiles.rs, queue2.rs), maintaining manual structured-word-buffer rewrites and Rust-serialized root signatures alongside #20 would create unnecessary ongoing churn. Centralized dxc::compile fallback in #20 keeps the upstream HLSL readable as shaders evolve. (One small integration note for #20 when rebasing onto c36971b: Host::make_card_inflight and queue2::tests::Warp::new also invoke D3DCompile directly and will benefit from routing through crate::dxc::compile as well.)

(AI-assisted note.)

**@⁠BitWuehler** on GitHub · 2026-11-25 21:41 UTC · [original](https://github.com/fxceless/victory-fork/pull/127#issuecomment-7175407834) Closing this PR as superseded by #20 (`dxc::compile` fallback). Thanks @⁠ErRusso for the review and @⁠Filip722 for confirming the `make_card_work` and six-shader compiler verification on Proton Experimental. With `main` (`c36971b`) now adding more internal compute shaders (`CARD_FETCH`, `tiles.rs`, `queue2.rs`), maintaining manual structured-word-buffer rewrites and Rust-serialized root signatures alongside #20 would create unnecessary ongoing churn. Centralized `dxc::compile` fallback in #20 keeps the upstream HLSL readable as shaders evolve. (One small integration note for #20 when rebasing onto `c36971b`: `Host::make_card_inflight` and `queue2::tests::Warp::new` also invoke `D3DCompile` directly and will benefit from routing through `crate::dxc::compile` as well.) (AI-assisted note.)

Pull request closed

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