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

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

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


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 odd-width test runs the converter 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.

This PR also includes #3064's exact UNORM16 midpoint rounding and its exhaustive GPU test, with the original commit author preserved. The combined shader omits [RootSignature(RS)] because the root signature is serialized in Rust. That avoids the undeclared RS error @neonbyte1 found when integrating the two PRs.

Fixes #1860. Supersedes #1872.

Proof

On the combined head, both converter tests passed on an RX 9070 XT (RADV) using Proton-CachyOS 11.0 and Wine's built-in d3dcompiler_47. The midpoint test found zero mismatches across 393,216 inputs. Strict victory-gpu Clippy passed with default and all features for x86_64-pc-windows-msvc.

The Wine compatibility change was also tested before integrating the rounding commit.

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 #1722 and #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).

<!-- greyfinch-sync:Marvisak/VIctory:issue:5501312671 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2919). Originally posted by [arogan178](https://github.com/arogan178) on 2026-11-25T23:58:29Z. --- 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 odd-width test runs the converter 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. This PR also includes #3064's exact UNORM16 midpoint rounding and its exhaustive GPU test, with the original commit author preserved. The combined shader omits `[RootSignature(RS)]` because the root signature is serialized in Rust. That avoids the undeclared `RS` error @neonbyte1 found when integrating the two PRs. Fixes #1860. Supersedes #1872. ## Proof On the combined head, both converter tests passed on an RX 9070 XT (RADV) using Proton-CachyOS 11.0 and Wine's built-in `d3dcompiler_47`. The midpoint test found zero mismatches across 393,216 inputs. Strict `victory-gpu` Clippy passed with default and all features for `x86_64-pc-windows-msvc`. The Wine compatibility change was also tested before integrating the rounding commit. `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 #1722 and #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).
fuzeofficlal commented 2026-11-26 00:06:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T00:06:12Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066745809 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2919#pullrequestreview-6066745809). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T00:06:12Z. **Review:** COMMENTED --- 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.
kotekompotek commented 2026-11-26 00:27:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T00:27:19Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066903339 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2919#pullrequestreview-6066903339). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T00:27:19Z. **Review:** COMMENTED --- 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.
Kajanos commented 2026-11-26 01:03:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Kajanos on 2026-11-26T00:07:09Z.


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)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7178414579 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2919#issuecomment-7178414579). Originally posted by [Kajanos](https://github.com/Kajanos) on 2026-11-26T00:07:09Z. --- **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)
Marvisak commented 2026-11-26 05:04:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T04:29:49Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7182645550 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2919#issuecomment-7182645550). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T04:29:49Z. --- <!-- victory-triage v1 head=13f215d5a491e18717c25f6ce6c9de16872fd2ad verdict=merge-candidate at=2026-11-26T04:29:44Z --> 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](https://claude.ai/code)_
Dukestar69 commented 2026-11-26 05:45:58 +00:00 (Migrated from github.com)

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

Review: APPROVED


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

<!-- greyfinch-sync:Marvisak/VIctory:review:6069126044 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2919#pullrequestreview-6069126044). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T05:45:58Z. **Review:** APPROVED --- 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).
neonbyte1 commented 2026-11-28 10:53:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-28T10:53:29Z.


A merge note for @andrewpozdnakov7-jpg and @arogan178 (#2919): these two PRs conflict without git noticing. #2919 removes both #define RS and [RootSignature(RS)] from the depth converter, because Wine's compiler builds it and the code makes the root signature beside the shader. #3064 keeps the [RootSignature(RS)] line. When both are merged, the attribute stays with no define. Wine's D3DCompile (vkd3d-shader) then rejects the converter with E5005: Identifier "RS" is not declared, and no depth converter exists: the log says no depth conversion: 16-bit depth written through unordered views does not reach the depth texture. In game on my fork's integration (RTX 5090, Wine 11.22 + vkd3d-proton), character close-ups get soft, skin-coloured blocks over the hair and back, and the PR's own float_depth_rounds_at_each_u16_threshold fails with depth converter.

The fix is to drop the attribute in whichever PR lands second and keep #3064's u16() as is: github.com/neonbyte1/VIctory@634bcce5 (adds a CPU test that the converter source compiles without it). With that on the same tree:

  • float_depth_rounds_at_each_u16_threshold passes under Wine/vkd3d-shader, with 0 of 393 216 values misrounded. The previous (x * 65535 + 0.5) rounding misrounds 32 768 of them, the first at 0x37000080 (expected 0, got 1). So #3064's rounding is worth having on this compiler too.
  • In game, the blocks are gone at frames 1700 and 2048.

One unrelated note: depth_typed_and_default_uavs_write_through_the_twin fails under Wine with 0x80004005 both with and without these changes.

AI-assisted (Claude); measured on my machine, no game data shared.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7238188866 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2919#issuecomment-7238188866). Originally posted by [neonbyte1](https://github.com/neonbyte1) on 2026-11-28T10:53:29Z. --- A merge note for @andrewpozdnakov7-jpg and @arogan178 (#2919): these two PRs conflict without git noticing. #2919 removes both `#define RS` and `[RootSignature(RS)]` from the depth converter, because Wine's compiler builds it and the code makes the root signature beside the shader. #3064 keeps the `[RootSignature(RS)]` line. When both are merged, the attribute stays with no define. Wine's `D3DCompile` (vkd3d-shader) then rejects the converter with `E5005: Identifier "RS" is not declared`, and no depth converter exists: the log says `no depth conversion: 16-bit depth written through unordered views does not reach the depth texture`. In game on my fork's integration (RTX 5090, Wine 11.22 + vkd3d-proton), character close-ups get soft, skin-coloured blocks over the hair and back, and the PR's own `float_depth_rounds_at_each_u16_threshold` fails with `depth converter`. The fix is to drop the attribute in whichever PR lands second and keep #3064's `u16()` as is: https://github.com/neonbyte1/VIctory/commit/634bcce5 (adds a CPU test that the converter source compiles without it). With that on the same tree: - `float_depth_rounds_at_each_u16_threshold` passes under Wine/vkd3d-shader, with **0 of 393 216** values misrounded. The previous `(x * 65535 + 0.5)` rounding misrounds 32 768 of them, the first at `0x37000080` (expected 0, got 1). So #3064's rounding is worth having on this compiler too. - In game, the blocks are gone at frames 1700 and 2048. One unrelated note: `depth_typed_and_default_uavs_write_through_the_twin` fails under Wine with 0x80004005 both with and without these changes. _AI-assisted (Claude); measured on my machine, no game data shared._
andrewpozdnakov7-jpg commented 2026-11-28 11:15:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T11:15:15Z.


Thanks @neonbyte1 for the integration check and @arogan178 for carrying the midpoint change into da0eca1 with the Git author preserved.

I checked that exact #2919 head. The converter source has no inline root-signature attribute, and the host creates its signature separately. Two focused tests executed on Windows WARP with graphics debug requested. The depth-to-UNORM16 test matched all 393,216 values. The 3×4 round trip passed in both directions and preserved the row padding. I repeated both with WARP availability required to rule out a silent skip. Both GPU Clippy configurations, the asset policy, and Windows CI passed.

This is Windows coverage of your current combined head. The Wine and title results in this thread are from @neonbyte1. The next step is maintainer review of #2919, which now includes the exact-midpoint conversion from #3064.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7238428592 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2919#issuecomment-7238428592). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T11:15:15Z. --- Thanks @neonbyte1 for the integration check and @arogan178 for carrying the midpoint change into `da0eca1` with the Git author preserved. I checked that exact #2919 head. The converter source has no inline root-signature attribute, and the host creates its signature separately. Two focused tests executed on Windows WARP with graphics debug requested. The depth-to-UNORM16 test matched all 393,216 values. The 3×4 round trip passed in both directions and preserved the row padding. I repeated both with WARP availability required to rule out a silent skip. Both GPU Clippy configurations, the asset policy, and [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46138652936/job/140959494379) passed. This is Windows coverage of your current combined head. The Wine and title results in this thread are from @neonbyte1. The next step is maintainer review of #2919, which now includes the exact-midpoint conversion from #3064. AI-assisted with OpenAI Codex.
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/2919:upstream-pr/2919'
git switch 'upstream-pr/2919'

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/2919'
git switch 'upstream-pr/2919'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2919'
git switch 'upstream-pr/2919'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2919'
git switch 'main'
git merge --squash 'upstream-pr/2919'
git switch 'main'
git merge --ff-only 'upstream-pr/2919'
git switch 'main'
git merge 'upstream-pr/2919'
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!2917
No description provided.