GPU: implement ClearUnorderedAccessViewUint/Float for buffers and textures #1162

Closed
geiyiliyabumo wants to merge 1 commit from upstream-pr/1162 into main
geiyiliyabumo commented 2026-11-24 16:18:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T16:18:35Z.


Summary

Fixes #771

Full verification details and change notes are documented in #771 (commit 12e9c6a, based on main ffe310e).

 crates/victory-gpu/src/descriptor.rs      |  14 +
 crates/victory-gpu/src/descriptor/host.rs |  23 +-
 crates/victory-gpu/src/host.rs            | 195 +++++-
 crates/victory-gpu/src/list.rs            | 995 +++++++++++++++++++++++++++++-
 crates/victory-gpu/src/shadow.rs          |  36 ++
 5 files changed, 1242 insertions(+), 21 deletions(-)

Verification (Windows 11 x64 MSVC)

  • rustfmt --edition 2024 --check on edited files: PASS
  • cargo xtask policy: PASS (zero game files/data)
  • cargo clippy --all-targets --locked -- -D warnings (default + --features diagnostics where applicable): PASS
  • Targeted & crate unit/GPU tests: PASS

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6586324209 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1162). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T16:18:35Z. --- ### Summary Fixes #771 Full verification details and change notes are documented in #771 (commit `12e9c6a`, based on `main` `ffe310e`). ```text crates/victory-gpu/src/descriptor.rs | 14 + crates/victory-gpu/src/descriptor/host.rs | 23 +- crates/victory-gpu/src/host.rs | 195 +++++- crates/victory-gpu/src/list.rs | 995 +++++++++++++++++++++++++++++- crates/victory-gpu/src/shadow.rs | 36 ++ 5 files changed, 1242 insertions(+), 21 deletions(-) ``` ### Verification (Windows 11 x64 MSVC) - `rustfmt --edition 2024 --check` on edited files: **PASS** - `cargo xtask policy`: **PASS** (zero game files/data) - `cargo clippy --all-targets --locked -- -D warnings` (default + `--features diagnostics` where applicable): **PASS** - Targeted & crate unit/GPU tests: **PASS** *AI-assisted; synthetic tests only, no game files.*
fuzeofficlal commented 2026-11-24 18:05:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T17:24:27Z.


Reviewed 12e9c6a and tested same-command-list buffer clear + compute Dispatch ordering under the D3D12 Debug Layer on NVIDIA GeForce RTX 5090 and D3D12 WARP.

Two architectural notes worth considering for the buffer path:

  1. Native ClearUnorderedAccessView* on the shadow buffer avoids ID3D12GraphicsCommandList7 Enhanced Barrier fallback ordering hazards:
    • Instead of CPU-encoding format texels into staging memory and relying on ID3D12GraphicsCommandList7::Barrier (with a submission-time defer fallback that breaks ordering relative to earlier/later Dispatch calls on the same list), buffer UAV clears can record native ClearUnorderedAccessViewUint / ClearUnorderedAccessViewFloat directly against shadow.buffer:
      • Lazily allocate a 1-slot non-shader-visible CBV_SRV_UAV CPU heap on HostList (CopyDescriptorsSimple into a dynamic shader-visible HostHeap slot).
      • For ClearUnorderedAccessViewUint on DXGI_FORMAT_R32_TYPELESS + D3D12_BUFFER_UAV_FLAG_RAW (RWByteAddressBuffer), rewrite the clear view descriptor to DXGI_FORMAT_R32_UINT (Flags = NONE), then bracket the native clear with shadow.refresh + shadow.gpu_writes + D3D12_RESOURCE_BARRIER_TYPE_UAV.
    • That keeps the entire implementation ~310 lines without CPU format-packing tables and preserves exact intra-list ordering on standard ID3D12GraphicsCommandList.
  2. D3D12 Debug Layer verification:
    • Verified both texture sub-rect clears (R32G32B32A32_UINT, R32G32_FLOAT) and overlapping intra-list raw/typed buffer clears feeding an immediate cs_5_1 Dispatch with VICTORY_D3D12_DEBUG=1 on RTX 5090 and D3D12 WARP (0 debug layer errors) in fuzeofficlal/VIctory@c4c09b2 (fix/uav-clear-771).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7139147400 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1162#issuecomment-7139147400). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-24T17:24:27Z. --- Reviewed `12e9c6a` and tested same-command-list buffer clear + compute `Dispatch` ordering under the D3D12 Debug Layer on **NVIDIA GeForce RTX 5090** and **D3D12 WARP**. Two architectural notes worth considering for the buffer path: 1. **Native `ClearUnorderedAccessView*` on the shadow buffer avoids `ID3D12GraphicsCommandList7` Enhanced Barrier fallback ordering hazards**: - Instead of CPU-encoding format texels into staging memory and relying on `ID3D12GraphicsCommandList7::Barrier` (with a submission-time `defer` fallback that breaks ordering relative to earlier/later `Dispatch` calls on the same list), buffer UAV clears can record native `ClearUnorderedAccessViewUint` / `ClearUnorderedAccessViewFloat` directly against `shadow.buffer`: - Lazily allocate a 1-slot non-shader-visible `CBV_SRV_UAV` CPU heap on `HostList` (`CopyDescriptorsSimple` into a dynamic shader-visible `HostHeap` slot). - For `ClearUnorderedAccessViewUint` on `DXGI_FORMAT_R32_TYPELESS` + `D3D12_BUFFER_UAV_FLAG_RAW` (`RWByteAddressBuffer`), rewrite the clear view descriptor to `DXGI_FORMAT_R32_UINT` (`Flags = NONE`), then bracket the native clear with `shadow.refresh` + `shadow.gpu_writes` + `D3D12_RESOURCE_BARRIER_TYPE_UAV`. - That keeps the entire implementation ~310 lines without CPU format-packing tables and preserves exact intra-list ordering on standard `ID3D12GraphicsCommandList`. 2. **D3D12 Debug Layer verification**: - Verified both texture sub-rect clears (`R32G32B32A32_UINT`, `R32G32_FLOAT`) and overlapping intra-list raw/typed buffer clears feeding an immediate `cs_5_1` `Dispatch` with `VICTORY_D3D12_DEBUG=1` on **RTX 5090** and **D3D12 WARP** (`0` debug layer errors) in [`fuzeofficlal/VIctory@c4c09b2`](https://github.com/fuzeofficlal/VIctory/commit/c4c09b2fe70eed109c62d4658a8938224751f88d) (`fix/uav-clear-771`).
Zipettte commented 2026-11-24 18:06:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T18:01:02Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 12e9c6a: cargo test -p victory-gpu passes, 57 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140035379 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1162#issuecomment-7140035379). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T18:01:02Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 12e9c6a: `cargo test -p victory-gpu` passes, 57 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
upstream-sync closed this pull request 2026-11-25 01:05:45 +00:00
Marvisak commented 2026-11-25 01:08:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:33:12Z.


Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

ClearUnorderedAccessViewUint/Float is already served in main (list.rs 0x1a8/0x1b0 -> draw.rs State::clear_unordered, any view the title made at the CPU handle); nothing left to rebase.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148627884 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1162#issuecomment-7148627884). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:33:12Z. --- Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. ClearUnorderedAccessViewUint/Float is already served in main (list.rs 0x1a8/0x1b0 -> draw.rs State::clear_unordered, any view the title made at the CPU handle); nothing left to rebase. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

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!1162
No description provided.