GPU: an argument clamp Wine's compiler builds too (carries #1279) #2911

Open
arogan178 wants to merge 2 commits from upstream-pr/2913 into main
arogan178 commented 2026-11-25 23:51:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by arogan178 on 2026-11-25T23:51:55Z.


Under Wine and Proton, every indirect draw and dispatch is dropped, so most of the world is never drawn (#170). The indirect-argument clamp is HLSL compiled at run time, and Wine's built-in d3dcompiler_47 (vkd3d-shader) refuses it: it has no Load/Store on byte address buffers and ignores the RootSignature attribute.

This carries #1279, which needs a rebase, onto main's current clamp (the one that charges records in order). The buffers become structured buffers of uint, indexed in words; bound already refuses addresses and strides that are not multiples of 4. The root signature is serialized in code, in the order bound sets it. The bounds, the budget and its order are unchanged.

The clamp tests read back only each record's first word. They now read whole records, and records_arrive_whole checks every word of two records of each kind.

Fixes #170. Supersedes #1279.

Proof

victory-gpu tests cross-built for x86_64-pc-windows-msvc, run under Proton-CachyOS 11.0 with vkd3d-proton 3.2.0 on an RX 9070 XT (RADV):

indirect:: tests main this PR
Wine's built-in d3dcompiler_47 0 of 6 pass 7 of 7 pass
Microsoft's d3dcompiler_47 10.0.26100 6 of 6 pass 7 of 7 pass
  • With Microsoft's compiler the whole victory-gpu suite has the same 3 failures as main. They are vkd3d-proton issues fixed by #1722 and #2101.
  • With one word copy removed from the shader, records_arrive_whole fails.
  • cargo clippy -p victory-gpu --all-targets --target x86_64-pc-windows-msvc -- -D warnings, with and without --all-features: clean. CI runs the Windows tests.

Reviewed with sol-loop: 1 round with GPT-6.2 Sol. Sol verdict: approved.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6616200088 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2913). Originally posted by [arogan178](https://github.com/arogan178) on 2026-11-25T23:51:55Z. --- Under Wine and Proton, every indirect draw and dispatch is dropped, so most of the world is never drawn (#170). The indirect-argument clamp is HLSL compiled at run time, and Wine's built-in `d3dcompiler_47` (vkd3d-shader) refuses it: it has no `Load`/`Store` on byte address buffers and ignores the `RootSignature` attribute. This carries #1279, which needs a rebase, onto `main`'s current clamp (the one that charges records in order). The buffers become structured buffers of `uint`, indexed in words; `bound` already refuses addresses and strides that are not multiples of 4. The root signature is serialized in code, in the order `bound` sets it. The bounds, the budget and its order are unchanged. The clamp tests read back only each record's first word. They now read whole records, and `records_arrive_whole` checks every word of two records of each kind. Fixes #170. Supersedes #1279. ## Proof `victory-gpu` tests cross-built for `x86_64-pc-windows-msvc`, run under Proton-CachyOS 11.0 with vkd3d-proton 3.2.0 on an RX 9070 XT (RADV): | `indirect::` tests | `main` | this PR | |---|---|---| | Wine's built-in `d3dcompiler_47` | 0 of 6 pass | 7 of 7 pass | | Microsoft's `d3dcompiler_47` 10.0.26100 | 6 of 6 pass | 7 of 7 pass | - With Microsoft's compiler the whole `victory-gpu` suite has the same 3 failures as `main`. They are vkd3d-proton issues fixed by #1722 and #2101. - With one word copy removed from the shader, `records_arrive_whole` fails. - `cargo clippy -p victory-gpu --all-targets --target x86_64-pc-windows-msvc -- -D warnings`, with and without `--all-features`: clean. CI runs the Windows tests. Reviewed with sol-loop: 1 round with GPT-6.2 Sol. Sol verdict: approved.
kotekompotek commented 2026-11-26 00:03:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T23:53:20Z.

Review: COMMENTED


Verified the byte-to-word conversion: at = record * (stride/4) and every Load(at+N*4) maps to args[at+N] consistently, including the tail-copies for both draw kinds; the budget/past-budget zeroing keeps the draw layout (zeroed first word, not the whole record). Root descriptors on StructuredBuffer<uint> work — stride comes from the shader decl — so dropping the embedded RootSignature attribute only costs the explicit root_signature() beside it, which matches bound's set order. Wine gets the same clamp through its own compiler. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066647933 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2913#pullrequestreview-6066647933). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T23:53:20Z. **Review:** COMMENTED --- Verified the byte-to-word conversion: `at = record * (stride/4)` and every `Load(at+N*4)` maps to `args[at+N]` consistently, including the tail-copies for both draw kinds; the budget/past-budget zeroing keeps the draw layout (zeroed first word, not the whole record). Root descriptors on `StructuredBuffer<uint>` work — stride comes from the shader decl — so dropping the embedded RootSignature attribute only costs the explicit `root_signature()` beside it, which matches `bound`'s set order. Wine gets the same clamp through its own compiler. LGTM.
fuzeofficlal commented 2026-11-26 00:03:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T23:59:20Z.

Review: COMMENTED


Verified head a9f2eb8c cleanly on origin/main (63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + D3D12 WARP + VICTORY_D3D12_DEBUG=1).

Code & Equivalence Review

  • Replacing #define RS / ByteAddressBuffer with explicit D3D12SerializeVersionedRootSignature (D3D_ROOT_SIGNATURE_VERSION_1_1) and StructuredBuffer<uint> / RWStructuredBuffer<uint> is mathematically equivalent across all four indirect kinds (Draw, DrawIndexed, Dispatch, Mesh), the GROUPS = 1<<20 overflow check, the 64-lane tile loop, and the BUDGET = 1<<27 clamp.
  • bound() (crates/victory-gpu/src/indirect.rs:276) already enforces 4-byte alignment on both gpu and stride, matching Root SRV/UAV requirements for StructuredBuffer<uint> and word-indexed record * (stride / 4).

Local Verification (--features diagnostics, VICTORY_D3D12_DEBUG=1)

  • RTX 5090 & WARP: indirect::tests 7/7 passed on both adapters (including new records_arrive_whole), zero debug-layer errors.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --features diagnostics) & cargo xtask policy (191 files ok): clean.

Looks clean and ready to merge.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066691839 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2913#pullrequestreview-6066691839). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T23:59:20Z. **Review:** COMMENTED --- Verified head `a9f2eb8c` cleanly on `origin/main` (`63bcca43`) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + D3D12 WARP + `VICTORY_D3D12_DEBUG=1`). ### Code & Equivalence Review - Replacing `#define RS` / `ByteAddressBuffer` with explicit `D3D12SerializeVersionedRootSignature` (`D3D_ROOT_SIGNATURE_VERSION_1_1`) and `StructuredBuffer<uint>` / `RWStructuredBuffer<uint>` is mathematically equivalent across all four indirect kinds (`Draw`, `DrawIndexed`, `Dispatch`, `Mesh`), the `GROUPS = 1<<20` overflow check, the 64-lane tile loop, and the `BUDGET = 1<<27` clamp. - `bound()` (`crates/victory-gpu/src/indirect.rs:276`) already enforces 4-byte alignment on both `gpu` and `stride`, matching Root SRV/UAV requirements for `StructuredBuffer<uint>` and word-indexed `record * (stride / 4)`. ### Local Verification (`--features diagnostics`, `VICTORY_D3D12_DEBUG=1`) - **RTX 5090 & WARP**: `indirect::tests` **7/7 passed** on both adapters (including new `records_arrive_whole`), zero debug-layer errors. - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--features diagnostics`) & `cargo xtask policy` (`191 files ok`): clean. Looks clean and ready to merge.
Marvisak commented 2026-11-26 03:05:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T02:21:42Z.


Automated triage for the maintainers.

Merge candidate (a recommendation to look, not an approval). In indirect.rs, the argument-clamp shader moves from byte address buffers to StructuredBuffer<uint> indexed in words, and its root signature is serialised in code (root_signature, in the order bound sets it). That lets Wine's compiler build it (#170). The clamp bounds and the budget logic are unchanged by my reading. Word indexing is safe because bound already refuses addresses and strides that are not multiples of 4. The new test checks whole records. CI check passes on Windows. This supersedes the older #1279, so only one of the two should land.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180730822 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2913#issuecomment-7180730822). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T02:21:42Z. --- <!-- victory-triage v1 head=a9f2eb8c23227e4610295449ae12ba3b3990a0ef verdict=merge-candidate at=2026-11-26T02:21:36Z --> Automated triage for the maintainers. **Merge candidate** (a recommendation to look, not an approval). In `indirect.rs`, the argument-clamp shader moves from byte address buffers to `StructuredBuffer<uint>` indexed in words, and its root signature is serialised in code (`root_signature`, in the order `bound` sets it). That lets Wine's compiler build it (#170). The clamp bounds and the budget logic are unchanged by my reading. Word indexing is safe because `bound` already refuses addresses and strides that are not multiples of 4. The new test checks whole records. CI `check` passes on Windows. This supersedes the older #1279, so only one of the two should land. --- _Generated by [Claude Code](https://claude.ai/code)_
Dukestar69 commented 2026-11-26 06:02:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T05:46:35Z.

Review: APPROVED


Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):

  • Diff review: Replacing ByteAddressBuffer/RWByteAddressBuffer with StructuredBuffer<uint>/RWStructuredBuffer<uint> (using 4-byte-aligned word strides) and serializing the root signature explicitly via D3D12SerializeRootSignature cleanly avoids Wine FXC limitations while keeping all draw/dispatch clamping and budget checks intact.
  • cargo test -p victory-gpu indirect::tests -- --test-threads=1 (RTX 5090 & WARP): 7 passed, 0 failed on both (including argument_clamp_builds).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6069130698 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2913#pullrequestreview-6069130698). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T05:46:35Z. **Review:** APPROVED --- Tested locally merged onto `origin/main` (`63bcca4`) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP): - Diff review: Replacing `ByteAddressBuffer`/`RWByteAddressBuffer` with `StructuredBuffer<uint>`/`RWStructuredBuffer<uint>` (using 4-byte-aligned word strides) and serializing the root signature explicitly via `D3D12SerializeRootSignature` cleanly avoids Wine FXC limitations while keeping all draw/dispatch clamping and budget checks intact. - `cargo test -p victory-gpu indirect::tests -- --test-threads=1` (RTX 5090 & WARP): 7 passed, 0 failed on both (including `argument_clamp_builds`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2913:upstream-pr/2913'
git switch 'upstream-pr/2913'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2913'
git switch 'upstream-pr/2913'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2913'
git switch 'upstream-pr/2913'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2913'
git switch 'main'
git merge --squash 'upstream-pr/2913'
git switch 'main'
git merge --ff-only 'upstream-pr/2913'
git switch 'main'
git merge 'upstream-pr/2913'
git push origin 'main'
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
Marvisak/VIctory!2911
No description provided.