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

Open
github-bot wants to merge 1 commit from github-bot/gh-1964 into main AGit
Owner

@⁠nathanbzrr on GitHub · 2026-11-25 01:49 UTC · original
nathanbzrr:gpu/depth-twin-24bit-and-active-planes → main · +1121 −80 · 2 files · 1 commits · open

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)
**@⁠nathanbzrr** on GitHub · 2026-11-25 01:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/1964) `nathanbzrr:gpu/depth-twin-24bit-and-active-planes` → `main` · +1121 −80 · 2 files · 1 commits · open ## 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`)
Add `R32_TYPELESS` plane-0 writable twins and bit-exact IEEE-754 integer `F32ToD24`/`d24_to_f32` scratch conversion for console formats `44..=47`, track active UAV planes (`uav_planes`) and per-plane newer states (`plane_newer`) so inactive/unseeded planes are skipped, and pass plane copy masks explicitly from `Use::again`/`HostList::twin_use` and `at_submission` to `Twin::copy` without thread-local or pending atomics.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:50:17 +00:00
github-bot force-pushed github-bot/gh-1964 from 7c601376f3 to 8cf20a6378 2026-11-26 06:28:30 +00:00 Compare
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 01:54 UTC · original

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

**@⁠upipibi** on GitHub · 2026-11-25 01:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/1964#issuecomment-7150096859) 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).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 08:23 UTC · original · edited 2026-11-26 04:22 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 08:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/1964#issuecomment-7156969437) · edited 2026-11-26 04:22 UTC <!-- 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)_
Author
Owner

@⁠nathanbzrr on GitHub · 2026-11-25 22:07 UTC · original

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
**@⁠nathanbzrr** on GitHub · 2026-11-25 22:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/1964#issuecomment-7175956353) 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 can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1964/head:github-bot/gh-1964'
git switch 'github-bot/gh-1964'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1964'
git switch 'github-bot/gh-1964'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1964'
git switch 'github-bot/gh-1964'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1964'
git switch 'main'
git merge --squash 'github-bot/gh-1964'
git switch 'main'
git merge --ff-only 'github-bot/gh-1964'
git switch 'main'
git merge 'github-bot/gh-1964'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1964
No description provided.