victory-gpu: compile card compare shaders as cs_5_0 with explicit root signatures #388

Closed
kwaadrat wants to merge 0 commits from upstream-pr/388 into main
kwaadrat commented 2026-12-01 21:27:29 +00:00 (Migrated from github.com)

Imported from readmet3xt-lab/foxhound. Originally posted by kwaadrat on 2026-12-01T21:27:29Z.


Summary

  • Compile CARD_COMPARE and CARD_COMPARE_BATCH as cs_5_0 via crate::host::compile instead of cs_5_1 with inline [RootSignature(RS)].
  • Build both compute root signatures explicitly in Rust via D3D12SerializeVersionedRootSignature (card_compare_root_signature), keeping the exact same bindings (b0 root constants, t0/t1 SRVs, u0/u1 UAVs).
  • Use RWStructuredBuffer<uint4> hashes (hashes[piece]) instead of RWByteAddressBuffer (hashes.Load4), since Wine's d3dcompiler_47 does not support .Load()/.Load4() on RWByteAddressBuffer in cs_5_0.
  • Update the compile_cs test helper in crates/victory-gpu/src/indirect.rs so existing CARD_COMPARE / CARD_COMPARE_BATCH tests (and VICTORY_BENCH_CS custom shaders that may still use [RootSignature(...)]) continue to work.

Why

Neither CARD_COMPARE nor CARD_COMPARE_BATCH uses Shader Model 5.1 features — cs_5_1 was only needed for [RootSignature(RS)] and RWByteAddressBuffer.Load4. Under Wine/Proton (d3dcompiler_47), compiling cs_5_1 with [RootSignature(...)] fails with E_FAIL (0x80004005):

WARN victory_gpu::host: no host copies in the card's memory: the compare could not be made error=Call failed. (0x80004005)

When make_card_work() fails, Host::card_ready() stays false for the entire session, disabling all card-resident title buffer copies (shadow::card_for) and forcing all buffer comparisons onto the CPU.

Using crate::host::compile also ensures any D3DCompile error blob is logged rather than discarded.

Verification

Built victory.exe on windows-latest (cargo build --release --locked -p victory) and tested on RTX 3060 12 GB (i5-9600KF) under Proton Experimental (vkd3d-proton):

  • no host copies in the card's memory and D3DCompile warnings are completely gone; title buffer copies are now placed in VRAM (a buffer's host copy is in the card's memory).
  • CPU buffer comparison (victory_gpu::shadow) dropped from 559.5 MB (501.3 MB snapshotted) per frame to 0.6 MB (0.8 MB snapshotted).
  • Submitting thread preparing per frame dropped from 311.1 ms (write watch 125.3 ms, snapshots 74.7 ms) to 56.4 ms (write watch 15.0 ms, snapshots 0.1 ms).
<!-- greyfinch-sync:readmet3xt-lab/foxhound:issue:5594862510 --> Imported from [readmet3xt-lab/foxhound](https://github.com/readmet3xt-lab/foxhound/pull/388). Originally posted by [kwaadrat](https://github.com/kwaadrat) on 2026-12-01T21:27:29Z. --- ## Summary - Compile `CARD_COMPARE` and `CARD_COMPARE_BATCH` as `cs_5_0` via `crate::host::compile` instead of `cs_5_1` with inline `[RootSignature(RS)]`. - Build both compute root signatures explicitly in Rust via `D3D12SerializeVersionedRootSignature` (`card_compare_root_signature`), keeping the exact same bindings (`b0` root constants, `t0`/`t1` SRVs, `u0`/`u1` UAVs). - Use `RWStructuredBuffer<uint4> hashes` (`hashes[piece]`) instead of `RWByteAddressBuffer` (`hashes.Load4`), since Wine's `d3dcompiler_47` does not support `.Load()`/`.Load4()` on `RWByteAddressBuffer` in `cs_5_0`. - Update the `compile_cs` test helper in `crates/victory-gpu/src/indirect.rs` so existing `CARD_COMPARE` / `CARD_COMPARE_BATCH` tests (and `VICTORY_BENCH_CS` custom shaders that may still use `[RootSignature(...)]`) continue to work. ## Why Neither `CARD_COMPARE` nor `CARD_COMPARE_BATCH` uses Shader Model 5.1 features — `cs_5_1` was only needed for `[RootSignature(RS)]` and `RWByteAddressBuffer.Load4`. Under Wine/Proton (`d3dcompiler_47`), compiling `cs_5_1` with `[RootSignature(...)]` fails with `E_FAIL (0x80004005)`: ```text WARN victory_gpu::host: no host copies in the card's memory: the compare could not be made error=Call failed. (0x80004005) ``` When `make_card_work()` fails, `Host::card_ready()` stays `false` for the entire session, disabling all card-resident title buffer copies (`shadow::card_for`) and forcing all buffer comparisons onto the CPU. Using `crate::host::compile` also ensures any `D3DCompile` error blob is logged rather than discarded. ## Verification Built `victory.exe` on `windows-latest` (`cargo build --release --locked -p victory`) and tested on RTX 3060 12 GB (i5-9600KF) under Proton Experimental (`vkd3d-proton`): - `no host copies in the card's memory` and `D3DCompile` warnings are completely gone; title buffer copies are now placed in VRAM (`a buffer's host copy is in the card's memory`). - CPU buffer comparison (`victory_gpu::shadow`) dropped from **559.5 MB** (`501.3 MB` snapshotted) per frame to **0.6 MB** (`0.8 MB` snapshotted). - Submitting thread `preparing per frame` dropped from **311.1 ms** (`write watch` 125.3 ms, `snapshots` 74.7 ms) to **56.4 ms** (`write watch` 15.0 ms, `snapshots` 0.1 ms).
readmet3xt-lab commented 2026-12-02 01:48:47 +00:00 (Migrated from github.com)

Imported from readmet3xt-lab/foxhound. Originally posted by readmet3xt-lab on 2026-12-02T01:48:47Z.


Thank you. These pin down exactly which of our own shaders fail under Proton's built-in compiler and what it costs when the card-side compare is missing, which is the clearest data we have on #407. We're going to solve it one level lower: our shaders will ship already compiled, so no shader compiler is asked at run time on any system, and Windows keeps exactly the bytecode it has today. Because of that we won't merge these three as they are (they change the shader model and two buffer types on Windows too). Your findings and measurements go into that change, with credit. When the build is out, a run under Proton with Full logs from you would be the best test we could get.

<!-- greyfinch-sync:readmet3xt-lab/foxhound:comment:7332136231 --> Imported from [readmet3xt-lab/foxhound](https://github.com/readmet3xt-lab/foxhound/pull/388#issuecomment-7332136231). Originally posted by [readmet3xt-lab](https://github.com/readmet3xt-lab) on 2026-12-02T01:48:47Z. --- Thank you. These pin down exactly which of our own shaders fail under Proton's built-in compiler and what it costs when the card-side compare is missing, which is the clearest data we have on #407. We're going to solve it one level lower: our shaders will ship already compiled, so no shader compiler is asked at run time on any system, and Windows keeps exactly the bytecode it has today. Because of that we won't merge these three as they are (they change the shader model and two buffer types on Windows too). Your findings and measurements go into that change, with credit. When the build is out, a run under Proton with Full logs from you would be the best test we could get.
kwaadrat commented 2026-12-02 06:51:10 +00:00 (Migrated from github.com)

Imported from readmet3xt-lab/foxhound. Originally posted by kwaadrat on 2026-12-02T06:51:10Z.


Thanks for the clear feedback and for the credit! Shipping those internal shaders precompiled so no runtime D3DCompile is needed anywhere (while keeping the exact Windows bytecode untouched) is a much cleaner solution.

As soon as that build is out, I'll test it under Proton Experimental with Full logs and report back (here / on #407).

<!-- greyfinch-sync:readmet3xt-lab/foxhound:comment:7337481731 --> Imported from [readmet3xt-lab/foxhound](https://github.com/readmet3xt-lab/foxhound/pull/388#issuecomment-7337481731). Originally posted by [kwaadrat](https://github.com/kwaadrat) on 2026-12-02T06:51:10Z. --- Thanks for the clear feedback and for the credit! Shipping those internal shaders precompiled so no runtime `D3DCompile` is needed anywhere (while keeping the exact Windows bytecode untouched) is a much cleaner solution. As soon as that build is out, I'll test it under Proton Experimental with `Full logs` and report back (here / on #407).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
readmet3xt-lab/foxhound!388
No description provided.