Skip to content

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

Open
arogan178 wants to merge 2 commits into
Marvisak:mainfrom
arogan178:wine-clamp-carry
Open

arogan178 wants to merge 2 commits into
Marvisak:mainfrom
arogan178:wine-clamp-carry

Conversation

@arogan178

Copy link
Copy Markdown

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

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

arogan178 and others added 2 commits November 26, 2026 00:49
The clamp of indirect arguments is HLSL compiled at run time by the
system's compiler. Under Wine and Proton that is vkd3d-shader's, which
has no methods on byte address buffers and ignores the RootSignature
attribute, so the clamp is never made and every indirect execution is
dropped (Marvisak#170, Marvisak#909, Marvisak#2744).

The buffers become structured buffers of uint, indexed in words (the
caller already refuses addresses and strides that are not multiples of
4), and the root signature is serialized beside the shader, in the
order the caller sets it. The bounds, the budget and its order are
unchanged.

Carries Marvisak#1279, rebased onto the clamp that charges records in order.

Co-authored-by: Mumogg <104529023+Mumogg@users.noreply.github.com>
The clamp tests read back only each record's first word. They now
read whole records, and one test checks every word of two records of
each kind.

@kotekompotek kotekompotek 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.

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 fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Owner

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

@Dukestar69 Dukestar69 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.

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

BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
Both were HLSL compiled at first use with D3DCompile. Under Wine that is
vkd3d-shader's compiler, which refuses them (no methods on
RWByteAddressBuffer, [RootSignature] ignored), so indirect execution was
dropped and 16-bit depth written through unordered views never reached
the depth texture. The rewrites in Marvisak#2913, Marvisak#2919 and Marvisak#2969 still need a
Wine of 11.22 or later.

victory-shader now writes both programs itself with its DXIL builder
(emit::argument_clamp, emit::depth_conversion), the same algorithm and
clamps as the HLSL, and victory-gpu makes their root signatures in code
(own.rs). No shader compiler runs, whatever the Wine version.

Tests: every_word_of_each_kind checks each word the clamp writes for
every record kind; depth_converts_both_ways runs the conversion both ways
on a buffer, with no compiler for the test either; our_programs_validate
runs both through the DXIL validator where the SDK has one. Under Wine 10
and vkd3d-proton 3.1 the 7 indirect tests and the new depth test pass
(6 indirect tests failed before), and the two draw tests that read
converted depth pass with a native compiler for their own shaders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wine/vkd3d: indirect execution is dropped because the argument clamp cannot be compiled there; rewriting its HLSL does not help

5 participants