Skip to content

GPU: the depth converter Wine's compiler builds too - #2919

Open
arogan178 wants to merge 1 commit into
Marvisak:mainfrom
arogan178:wine-depth-twin
Open

arogan178 wants to merge 1 commit into
Marvisak:mainfrom
arogan178:wine-depth-twin

Conversation

@arogan178

Copy link
Copy Markdown

Under Wine and Proton, 16-bit depth that the title writes through unordered views never reaches the host's depth texture (#1860). It is moved by a compute converter compiled at run time. Wine's built-in d3dcompiler_47 (vkd3d-shader) refuses it, because it has no Load/Store on byte address buffers, and it ignores the RootSignature attribute. The converter is never made.

#1872 serializes the root signature when the compiler drops it. That is half of it: with Proton-CachyOS 11.0's compiler the shader still fails on buf.Load, and #1872's own test fails there too. This PR does both halves, the way #2913 does for the indirect clamp:

  • The buffer becomes a structured buffer of uint, indexed in words. Every offset and pitch comes from a placed footprint: offsets are 512-byte aligned, row pitches 256.
  • The root signature is serialized beside the shader, in the order the caller sets it.

The conversion itself is unchanged. A new test runs it both ways on a 3-wide surface, with a distinct value per texel and a sentinel in each row's padding. It is adapted from #1872's test.

Fixes #1860. Supersedes #1872.

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

  • Wine's built-in compiler: the new test passes. With main's shader swapped back in, it fails because the converter is never built. With the odd-width tail guard removed, it fails on the padding sentinel.
  • Microsoft's d3dcompiler_47 10.0.26100: the new test passes. The whole suite has the same 3 failures as main. They are vkd3d-proton issues fixed by GPU: the host pipeline library works under Wine (null blob for an empty library) #1722 and GPU: castable formats the host has #2101.
  • Clippy: cargo clippy -p victory-gpu --all-targets --target x86_64-pc-windows-msvc -- -D warnings, with and without --all-features, is clean. CI runs the Windows tests.

Reviewed with sol-loop: 1 round with GPT-6.2 Sol. Sol verdict: approved (its one nit, a stronger test fixture, is in).

16-bit depth written through unordered views reaches the host's depth
texture through a compute converter compiled at run time. Wine's and
Proton's built-in d3dcompiler_47 refuse it (no methods on byte address
buffers) and ignore its RootSignature attribute, so the converter is
never made and that depth stays clear (Marvisak#1860).

The buffer becomes a structured buffer of uint indexed in words (every
offset and pitch is a placed footprint's, a multiple of 4), and the
root signature is serialized beside the shader. A test runs the
conversion both ways, after Marvisak#1872's.

Co-authored-by: BastienRdz <58186763+BastienRodz@users.noreply.github.com>

@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 13f215d5 cleanly on origin/main (63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + D3D12 WARP + VICTORY_D3D12_DEBUG=1).

Code & Equivalence Review

  • Replacing inline [RootSignature(RS)] and RWByteAddressBuffer with explicit D3D12SerializeRootSignature (D3D_ROOT_SIGNATURE_VERSION_1_0: b0 8 constants + u0 UAV table) and RWStructuredBuffer<uint> preserves exact word addressing because placed footprint offsets (at16/at32, 512 B aligned), pitches (256 B aligned), and 2-texel thread pairs (x * 2 = 4 B aligned) are all 4-byte aligned.
  • 16-bit depth (D16_UNORM <-> D32_FLOAT) round-trip encoding (0x37800080 and saturate * 65535.0 + 0.5, plus odd-width high-half zeroing) matches bit-for-bit, and D32/D24S8 continue taking the same == true copy path.

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

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

Looks clean and ready to merge.

@Kajanos

Kajanos commented Nov 26, 2026

Copy link
Copy Markdown

Windows 11 / NVIDIA test run, head 13f215d5a4 merged onto main 63bcca43c6.

Setup: Windows 11 Home build 26300, RTX 5080, NVIDIA 621.40, rustc 1.98.1 MSVC, VS 2022 Build Tools, Windows SDK 10.0.26100 (dxil.dll from the SDK).

  • cargo test --locked -p victory-gpu: 232 passed, 0 failed, 1 ignored (main: 231). On Windows this uses the native d3dcompiler_47, so the Wine-compiler path this PR targets is not exercised here.

Not run: the retail title, clippy, and other crates.

AI-assisted (Claude Code)

@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 same conversion as #2913 applied to the depth converter: byte offsets divided to word indices (/4, b+4 -> b+1), structured uint buffer via root descriptor, root signature built beside the shader. The saturate/round u16 path is untouched. LGTM.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. The 16-bit depth converter in twin.rs now builds with Wine's compiler too: the buffer is a word-indexed RWStructuredBuffer<uint> and the root signature is serialized in code (root_signature). The parameter order (b0 constants at 0, root UAV at 1) matches the caller's SetComputeRoot32BitConstants(0, ...) / SetComputeRootUnorderedAccessView(1, ...), and every offset and pitch is a multiple of 4 so the division is exact. The test runs both directions on an odd width with padding sentinels against independently computed values. If merged, #1872 looks superseded.

CI: passing.


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 RWByteAddressBuffer with RWStructuredBuffer<uint> (using 4-byte-aligned word indices) and serializing the root signature explicitly via D3D12SerializeRootSignature cleanly avoids Wine FXC limitations while preserving exact 16-bit depth conversion semantics.
  • cargo test -p victory-gpu twin::tests -- --test-threads=1 (RTX 5090 & WARP): 3 passed, 0 failed on both (including the_converter_turns_16_bit_depth_into_float_and_back).
  • cargo test -p victory-gpu a_depth_texture_written_through_unordered_views_reads_as_depth -- --test-threads=1 (RTX 5090 & WARP): 1 passed, 0 failed on both.
  • 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).

ntgata1-dotcom added a commit to ntgata1-dotcom/VIctory-Linux that referenced this pull request Nov 26, 2026
…lds too

From Marvisak/VIctory#2919 (opened by arogan178; original commits and authors kept). Not yet merged upstream.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 26, 2026
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: 16-bit depth written through unordered views stays clear, because the converter shader does not compile

6 participants