GPU: support 24-bit depth twins and per-plane active UAV tracking #1962

Open
nathanbzrr wants to merge 1 commit from upstream-pr/1964 into main
nathanbzrr commented 2026-11-25 01:49:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by nathanbzrr on 2026-11-25T01:49:57Z.


Summary

  • Add 24-bit depth twin support for console formats 44..=47 (R24G8_TYPELESS / D24_UNORM_S8_UINT / R24_UNORM_X8_TYPELESS / X24_TYPELESS_G8_UINT) in crates/victory-gpu/src/twin.rs using an R32_TYPELESS plane-0 twin (R32_FLOAT / R32_UINT UAVs) and in-place Conversion::F32ToD24 scratch conversion (mode = 1).
  • Implement f32_to_d24 and d24_to_f32 in SOURCE using bit-exact pure-integer IEEE-754 arithmetic instead of round(f * 16777215.0) / d / 16777215.0, avoiding f32 double-rounding, dropped [precise] flags under D3DCompile, and ~1 ULP DXBC div inaccuracies across all 2^{24} D24 values on both RX 7600 and WARP.
  • Track per-plane active UAVs (uav_planes, plane_newer, pending_to_depth, pending_to_twin, Use::{first, last}: [_; 2]) so inactive stencil/depth planes skip barriers and copies and unseeded planes never clobber the depth texture when a UAV is created later.
  • Add unit and GPU/WARP tests in twin::tests (f32_d24_round_trips_every_24bit_value, f32_d24_converter_is_bit_exact_on_gpu, per_plane_tracking_never_clobbers_inactive_or_unseeded_planes, r24g8_depth_twin_round_trips_depth_and_stencil_on_gpu, active_planes_skip_inactive_stencil_and_preserve_depth_stencil_on_late_uav).

Verification

All checks passed after the final edit to crates/victory-gpu/src/twin.rs:

  • cargo clippy --workspace --all-targets -- -D warnings: passed (0 warnings)
  • cargo clippy --workspace --all-targets --all-features -- -D warnings: passed (0 warnings)
  • cargo test -p victory-gpu twin --locked: 6 passed, 0 failed (137 filtered out)
  • cargo test -p victory-gpu --all-features twin --locked: 6 passed, 0 failed (140 filtered out)
  • VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --all-features twin --locked: 6 passed, 0 failed (140 filtered out, 0 debug layer errors)
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --all-features twin --locked: 6 passed, 0 failed (140 filtered out)
  • VICTORY_WARP=1 cargo test -p victory-gpu twin --locked: 6 passed, 0 failed (137 filtered out)
  • cargo test --workspace --locked: all workspace unit/integration/doc-test suites passed (0 failed; 10 ignored benchmark/external-asset/defect tests across victory-formats, victory-gpu, and victory-shader)
  • cargo run -p xtask -- policy --staged: asset policy: 1 files ok (crates/victory-gpu/src/twin.rs)
<!-- greyfinch-sync:Marvisak/VIctory:issue:6595281488 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1964). Originally posted by [nathanbzrr](https://github.com/nathanbzrr) on 2026-11-25T01:49:57Z. --- ## Summary - Add 24-bit depth twin support for console formats `44..=47` (`R24G8_TYPELESS` / `D24_UNORM_S8_UINT` / `R24_UNORM_X8_TYPELESS` / `X24_TYPELESS_G8_UINT`) in `crates/victory-gpu/src/twin.rs` using an `R32_TYPELESS` plane-0 twin (`R32_FLOAT` / `R32_UINT` UAVs) and in-place `Conversion::F32ToD24` scratch conversion (`mode = 1`). - Implement `f32_to_d24` and `d24_to_f32` in `SOURCE` using bit-exact pure-integer IEEE-754 arithmetic instead of `round(f * 16777215.0)` / `d / 16777215.0`, avoiding `f32` double-rounding, dropped `[precise]` flags under `D3DCompile`, and ~1 ULP DXBC `div` inaccuracies across all $2^{24}$ `D24` values on both RX 7600 and WARP. - Track per-plane active UAVs (`uav_planes`, `plane_newer`, `pending_to_depth`, `pending_to_twin`, `Use::{first, last}: [_; 2]`) so inactive stencil/depth planes skip barriers and copies and unseeded planes never clobber the depth texture when a UAV is created later. - Add unit and GPU/WARP tests in `twin::tests` (`f32_d24_round_trips_every_24bit_value`, `f32_d24_converter_is_bit_exact_on_gpu`, `per_plane_tracking_never_clobbers_inactive_or_unseeded_planes`, `r24g8_depth_twin_round_trips_depth_and_stencil_on_gpu`, `active_planes_skip_inactive_stencil_and_preserve_depth_stencil_on_late_uav`). ## Verification All checks passed after the final edit to `crates/victory-gpu/src/twin.rs`: - `cargo clippy --workspace --all-targets -- -D warnings`: passed (0 warnings) - `cargo clippy --workspace --all-targets --all-features -- -D warnings`: passed (0 warnings) - `cargo test -p victory-gpu twin --locked`: 6 passed, 0 failed (`137 filtered out`) - `cargo test -p victory-gpu --all-features twin --locked`: 6 passed, 0 failed (`140 filtered out`) - `VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --all-features twin --locked`: 6 passed, 0 failed (`140 filtered out`, 0 debug layer errors) - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --all-features twin --locked`: 6 passed, 0 failed (`140 filtered out`) - `VICTORY_WARP=1 cargo test -p victory-gpu twin --locked`: 6 passed, 0 failed (`137 filtered out`) - `cargo test --workspace --locked`: all workspace unit/integration/doc-test suites passed (0 failed; 10 ignored benchmark/external-asset/defect tests across `victory-formats`, `victory-gpu`, and `victory-shader`) - `cargo run -p xtask -- policy --staged`: `asset policy: 1 files ok` (`crates/victory-gpu/src/twin.rs`)
upipibi commented 2026-11-25 02:06:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T01:54:25Z.


Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at 74e4668. victory-shader: 226 passed, with only #1744's 3 NVIDIA failures. victory-gpu: 139 passed, 2 failed, with only the two NVIDIA heap-cap failures main also has (dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views). Same as main on this hardware. Not run: a title.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150096859 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1964#issuecomment-7150096859). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T01:54:25Z. --- Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at `74e4668`. `victory-shader`: 226 passed, with only #1744's 3 NVIDIA failures. `victory-gpu`: 139 passed, 2 failed, with only the two NVIDIA heap-cap failures `main` also has (`dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views`). Same as `main` on this hardware. Not run: a title. AI-assisted (Claude Code).
catminou4 commented 2026-11-25 03:03:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T02:10:32Z.

Review: COMMENTED


Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

24-bit depth twins + per-plane active UAV tracking: depth-twin format extension — pairs with #1933.

<!-- greyfinch-sync:Marvisak/VIctory:review:6050613784 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1964#pullrequestreview-6050613784). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T02:10:32Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. 24-bit depth twins + per-plane active UAV tracking: depth-twin format extension — pairs with #1933.
Marvisak commented 2026-11-25 09:06:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T08:23:36Z.


Automated triage for the maintainers.

Needs work. Since 7c60137 the only change is a small refactor (route reads twin.active_planes() once; depth_planes became depth_plane_count in twin.rs/host.rs), which reads correctly. The main point from the last review is still open: nothing shows that the title writes a 24-bit depth texture (console formats 44..=47) through an unordered view, or that copying whole twins including an untouched stencil plane costs or breaks anything, and the change is still about 1,100 lines in twin.rs. A run on main showing such a UAV write, or frame-report copy counts with and without per-plane tracking, would move it forward; splitting the 24-bit twin support from per-plane tracking would help too.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7156969437 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1964#issuecomment-7156969437). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T08:23:36Z. --- <!-- victory-triage v1 head=8cf20a63789d50a0c025cddeae303af0bdfd6277 verdict=needs-work at=2026-11-26T04:21:52Z --> Automated triage for the maintainers. **Needs work.** Since `7c60137` the only change is a small refactor (`route` reads `twin.active_planes()` once; `depth_planes` became `depth_plane_count` in `twin.rs`/`host.rs`), which reads correctly. The main point from the last review is still open: nothing shows that the title writes a 24-bit depth texture (console formats 44..=47) through an unordered view, or that copying whole twins including an untouched stencil plane costs or breaks anything, and the change is still about 1,100 lines in `twin.rs`. A run on `main` showing such a UAV write, or frame-report copy counts with and without per-plane tracking, would move it forward; splitting the 24-bit twin support from per-plane tracking would help too. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
nathanbzrr commented 2026-11-25 23:05:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by nathanbzrr on 2026-11-25T22:07:01Z.


Rebased onto origin/main (f3578e3, new head eb888a3), resolving the merge conflicts in crates/victory-gpu/src/twin.rs:

  • Preserved origin/main (98c654b) for 118..=120 16-bit depth conversion to/from 32-bit float depth (Conversion::U16ToF32, mode == 0 with 0x37800080 and u16) alongside #1964's Conversion::F32ToD24 (mode != 0) for 44..=47 24-bit depth twins and per-plane active UAV tracking.
  • Preserved #2162's shared scratch buffer pool (shared_scratch) and #1273/315cea1's prelude_copies_start_from_the_real_states test alongside all five #1964 tests.
  • Adapted transition_title_barrier to borrow &tex for the owned ID3D12Resource returned by HostList::transition (69d1e8e).

Verification (eb888a3)

  • cargo run -p xtask -- policy -> 186 files ok
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings & --all-features -> clean
  • cargo test -p victory-gpu --lib --locked -- twin::tests --test-threads=1 -> 7 passed; 0 failed
  • cargo test -p victory-gpu --lib --locked -- a_depth_texture_written_through_unordered_views_reads_as_depth --test-threads=1 -> 1 passed; 0 failed
  • VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked -- twin::tests --test-threads=1 -> 7 passed; 0 failed
  • VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked -- a_depth_texture_written_through_unordered_views_reads_as_depth --test-threads=1 -> 1 passed; 0 failed
<!-- greyfinch-sync:Marvisak/VIctory:comment:7175956353 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1964#issuecomment-7175956353). Originally posted by [nathanbzrr](https://github.com/nathanbzrr) on 2026-11-25T22:07:01Z. --- Rebased onto `origin/main` (`f3578e3`, new head `eb888a3`), resolving the merge conflicts in `crates/victory-gpu/src/twin.rs`: - Preserved `origin/main` (`98c654b`) for `118..=120` 16-bit depth conversion to/from 32-bit float depth (`Conversion::U16ToF32`, `mode == 0` with `0x37800080` and `u16`) alongside `#1964`'s `Conversion::F32ToD24` (`mode != 0`) for `44..=47` 24-bit depth twins and per-plane active UAV tracking. - Preserved `#2162`'s shared scratch buffer pool (`shared_scratch`) and `#1273`/`315cea1`'s `prelude_copies_start_from_the_real_states` test alongside all five `#1964` tests. - Adapted `transition_title_barrier` to borrow `&tex` for the owned `ID3D12Resource` returned by `HostList::transition` (`69d1e8e`). ### Verification (`eb888a3`) - `cargo run -p xtask -- policy` -> `186 files ok` - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` & `--all-features` -> clean - `cargo test -p victory-gpu --lib --locked -- twin::tests --test-threads=1` -> `7 passed; 0 failed` - `cargo test -p victory-gpu --lib --locked -- a_depth_texture_written_through_unordered_views_reads_as_depth --test-threads=1` -> `1 passed; 0 failed` - `VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked -- twin::tests --test-threads=1` -> `7 passed; 0 failed` - `VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked -- a_depth_texture_written_through_unordered_views_reads_as_depth --test-threads=1` -> `1 passed; 0 failed`
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/1964:upstream-pr/1964'
git switch 'upstream-pr/1964'

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