victory-gpu: keep depth-twin UAVs in concrete UAV formats and support default views #1931

Open
mgunes1311-lab wants to merge 4 commits from upstream-pr/1933 into main
mgunes1311-lab commented 2026-11-25 01:10:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mgunes1311-lab on 2026-11-25T01:10:20Z.


Summary

Fixes D3D12 UAV format validation and default/1D view handling in victory_gpu::twin::uav when creating unordered access views on writable depth-texture twins:

  1. Prevent D3D12 device removal on depth-typed and typeless UAV descriptions: twin::uav checked family(view) == own, where own is DXGI_FORMAT_R32_TYPELESS (39), DXGI_FORMAT_R16_TYPELESS (53), or DXGI_FORMAT_R8_TYPELESS (60). Because D32_FLOAT (40), D16_UNORM (55), and the *_TYPELESS formats themselves belong to those families, twin::uav passed them directly into ID3D12Device::CreateUnorderedAccessView, which rejects depth and typeless UAV formats and puts the host D3D12 device into DEVICE_REMOVED. uav_format now maps depth, typeless, and DXGI_FORMAT_UNKNOWN (0, inheriting the title resource's format) views to the plane's concrete UAV format (R32_FLOAT, R16_UNORM, or R8_UINT), preserves explicit UAV-capable formats in the plane's family (R32_UINT, R32_SINT, R16_FLOAT, R16_UINT, R8_UNORM, etc.), and classifies planar stencil formats (X32_TYPELESS_G8X24_UINT, X24_TYPELESS_G8_UINT) as integer.
  2. Support null (pDesc == nullptr) and 1D / 1D-array depth UAVs: twin::uav previously bailed out on words = None and rejected TEXTURE1D (2) / TEXTURE1DARRAY (3). It now synthesizes default mip-0 plane-0 view words (covering all slices on array resources) when words is None and handles 1D / 1D-array UAV dimensions on plane 0.

Verification

  • VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --all-features --target x86_64-pc-windows-msvc --locked -- twin (unit tests for format/default-descriptor mapping + end-to-end D3D12 compute dispatch writing through D32_FLOAT, R32_TYPELESS, DXGI_FORMAT_UNKNOWN, 1D D16_UNORM, and null-pDesc 2D-array D16_UNORM depth UAVs and reading back the copied host depth subresources)
  • cargo clippy --workspace --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings (default and --all-features)
  • cargo doc --workspace --no-deps --target x86_64-pc-windows-msvc --locked
  • cargo run -p xtask --target x86_64-pc-windows-msvc --locked -- policy --staged & cargo test -p xtask --target x86_64-pc-windows-msvc --locked
<!-- greyfinch-sync:Marvisak/VIctory:issue:5483156456 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1933). Originally posted by [mgunes1311-lab](https://github.com/mgunes1311-lab) on 2026-11-25T01:10:20Z. --- ## Summary Fixes D3D12 UAV format validation and default/1D view handling in `victory_gpu::twin::uav` when creating unordered access views on writable depth-texture twins: 1. **Prevent D3D12 device removal on depth-typed and typeless UAV descriptions:** `twin::uav` checked `family(view) == own`, where `own` is `DXGI_FORMAT_R32_TYPELESS` (`39`), `DXGI_FORMAT_R16_TYPELESS` (`53`), or `DXGI_FORMAT_R8_TYPELESS` (`60`). Because `D32_FLOAT` (`40`), `D16_UNORM` (`55`), and the `*_TYPELESS` formats themselves belong to those families, `twin::uav` passed them directly into `ID3D12Device::CreateUnorderedAccessView`, which rejects depth and typeless UAV formats and puts the host D3D12 device into `DEVICE_REMOVED`. `uav_format` now maps depth, typeless, and `DXGI_FORMAT_UNKNOWN` (`0`, inheriting the title resource's format) views to the plane's concrete UAV format (`R32_FLOAT`, `R16_UNORM`, or `R8_UINT`), preserves explicit UAV-capable formats in the plane's family (`R32_UINT`, `R32_SINT`, `R16_FLOAT`, `R16_UINT`, `R8_UNORM`, etc.), and classifies planar stencil formats (`X32_TYPELESS_G8X24_UINT`, `X24_TYPELESS_G8_UINT`) as integer. 2. **Support null (`pDesc == nullptr`) and 1D / 1D-array depth UAVs:** `twin::uav` previously bailed out on `words = None` and rejected `TEXTURE1D` (`2`) / `TEXTURE1DARRAY` (`3`). It now synthesizes default mip-0 plane-0 view words (covering all slices on array resources) when `words` is `None` and handles 1D / 1D-array UAV dimensions on plane 0. ## Verification - `VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --all-features --target x86_64-pc-windows-msvc --locked -- twin` (unit tests for format/default-descriptor mapping + end-to-end D3D12 compute dispatch writing through `D32_FLOAT`, `R32_TYPELESS`, `DXGI_FORMAT_UNKNOWN`, 1D `D16_UNORM`, and null-`pDesc` 2D-array `D16_UNORM` depth UAVs and reading back the copied host depth subresources) - `cargo clippy --workspace --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings` (default and `--all-features`) - `cargo doc --workspace --no-deps --target x86_64-pc-windows-msvc --locked` - `cargo run -p xtask --target x86_64-pc-windows-msvc --locked -- policy --staged` & `cargo test -p xtask --target x86_64-pc-windows-msvc --locked`
upipibi commented 2026-11-25 02:06:17 +00:00 (Migrated from github.com)

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


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

AI-assisted (Claude Code).

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

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

Review: COMMENTED


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

Depth-twin UAVs kept in concrete UAV formats: format-concrete UAV fix for depth twins — pairs with #1964's 24-bit depth twins.

<!-- greyfinch-sync:Marvisak/VIctory:review:6050611923 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1933#pullrequestreview-6050611923). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T02:10:23Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Depth-twin UAVs kept in concrete UAV formats: format-concrete UAV fix for depth twins — pairs with #1964's 24-bit depth twins.
Marvisak commented 2026-11-25 09:06:11 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Merge candidate. In twin::uav (crates/victory-gpu/src/twin.rs), main keeps the title's view format whenever family(view) == own. resource::family maps D32_FLOAT (40) to 39 and D16_UNORM (55) to 53, so a depth-typed or typeless format can reach CreateUnorderedAccessView today, and D3D12 does not accept those for UAVs. The new uav_format excludes 39/40/53/55/60 and resolves UNKNOWN through pc_format(console). I checked its fallbacks against the plane formats from plane_formats. default_uav_words fills in the null-description case with the D3D12 UAV layout (1D: mip, then first slice and size for arrays; 2D arrays: size in word 4). 1D views correctly use plane 0.

Small notes, none blocking:

  • The null-description path skips the default_view check that the non-depth path in descriptor/host.rs runs.
  • The GPU test leaks three 1 MiB allocations.
  • Adding 22/47 to integer() turns a stencil-typed view on the depth plane into R32_UINT.

CI: check passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7156874954 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1933#issuecomment-7156874954). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T08:19:01Z. --- <!-- victory-triage v1 head=e5750d906995699a25e5036ca12175c1f9769603 verdict=merge-candidate at=2026-11-25T18:24:55Z --> Automated triage for the maintainers. **Merge candidate.** In `twin::uav` (`crates/victory-gpu/src/twin.rs`), `main` keeps the title's view format whenever `family(view) == own`. `resource::family` maps `D32_FLOAT` (40) to 39 and `D16_UNORM` (55) to 53, so a depth-typed or typeless format can reach `CreateUnorderedAccessView` today, and D3D12 does not accept those for UAVs. The new `uav_format` excludes 39/40/53/55/60 and resolves `UNKNOWN` through `pc_format(console)`. I checked its fallbacks against the plane formats from `plane_formats`. `default_uav_words` fills in the null-description case with the D3D12 UAV layout (1D: mip, then first slice and size for arrays; 2D arrays: size in word 4). 1D views correctly use plane 0. Small notes, none blocking: - The null-description path skips the `default_view` check that the non-depth path in `descriptor/host.rs` runs. - The GPU test leaks three 1 MiB allocations. - Adding 22/47 to `integer()` turns a stencil-typed view on the depth plane into `R32_UINT`. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
mgunes1311-lab commented 2026-11-25 17:05:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mgunes1311-lab on 2026-11-25T16:52:14Z.


Merged main (67e8ae1) to resolve the test conflict in crates/victory-gpu/src/twin.rs alongside 98c654b and 315cea1.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7168656090 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1933#issuecomment-7168656090). Originally posted by [mgunes1311-lab](https://github.com/mgunes1311-lab) on 2026-11-25T16:52:14Z. --- Merged `main` (`67e8ae1`) to resolve the test conflict in `crates/victory-gpu/src/twin.rs` alongside `98c654b` and `315cea1`.
mgunes1311-lab commented 2026-11-25 17:05:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mgunes1311-lab on 2026-11-25T16:55:41Z.


Merged main (67e8ae1) to resolve the test conflict in crates/victory-gpu/src/twin.rs alongside 98c654b and 315cea1.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7168741668 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1933#issuecomment-7168741668). Originally posted by [mgunes1311-lab](https://github.com/mgunes1311-lab) on 2026-11-25T16:55:41Z. --- Merged `main` (`67e8ae1`) to resolve the test conflict in `crates/victory-gpu/src/twin.rs` alongside `98c654b` and `315cea1`.
fuzeofficlal commented 2026-11-26 18:48:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T18:48:39Z.

Review: APPROVED


Reviewed e5750d906995 merged cleanly onto 63bcca43.

The changes in crates/victory-gpu/src/twin.rs cleanly prevent device removal on depth-typed/typeless/default depth-twin UAVs and extend support to 1D/1D-array views:

  • uav_format (twin.rs:306-321) & integer (twin.rs:324-329): Correctly resolves DXGI_FORMAT_UNKNOWN (0) through the resource's console format and pc_format, rejects typeless (39, 53, 60) and depth (40, 55) members even when they match the twin plane's family, and falls back to concrete UAV-capable formats (R16_UNORM/R16_UINT, R32_FLOAT/R32_UINT, R8_UINT), with planar stencil formats (22 | 47) classified as integer.
  • default_uav_words (twin.rs:285-298) & 1D view handling (twin.rs:247-275): Word layout matches D3D12_UNORDERED_ACCESS_VIEW_DESC across Texture1D, Texture1DArray, Texture2D, and Texture2DArray (slices > 1 selects array views with ArraySize at word 4), and leaving plane_word = None for 1D/1D-array views avoids clobbering FirstArraySlice at word 3.

Hardware & D3D12 Debug Layer verification (RTX 5090 + Microsoft WARP, VICTORY_D3D12_DEBUG=1):

  • cargo xtask policy and cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features) pass cleanly.
  • cargo test --locked -p victory-gpu twin::tests:: -- --test-threads=1 passed 4/4 on both RTX 5090 and WARP under VICTORY_D3D12_DEBUG=1.
  • Verified an additional Debug Layer probe creating 25 concrete UAVs across D32_FLOAT_S8X24_UINT (20), R32G8X24_TYPELESS (19), D16S8 (118), and 1D/1D-array D32_FLOAT (40) (default None, explicit plane 0 & plane 1 with typeless/depth/stencil/concrete formats, 1D-array with non-zero FirstArraySlice, plus out-of-range plane 2 cleanly returning None): GetDeviceRemovedReason().is_ok() and host.log_messages() == None on both RTX 5090 and WARP.
  • Also verified a clean co-merge with #1803 (7c609deb480f) on 63bcca43 with twin::tests:: and list::tests:: passing under VICTORY_D3D12_DEBUG=1 on both adapters.

LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6079160573 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1933#pullrequestreview-6079160573). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T18:48:39Z. **Review:** APPROVED --- Reviewed `e5750d906995` merged cleanly onto `63bcca43`. The changes in `crates/victory-gpu/src/twin.rs` cleanly prevent device removal on depth-typed/typeless/default depth-twin UAVs and extend support to 1D/1D-array views: - **`uav_format` (`twin.rs:306-321`) & `integer` (`twin.rs:324-329`)**: Correctly resolves `DXGI_FORMAT_UNKNOWN (0)` through the resource's console format and `pc_format`, rejects typeless (`39`, `53`, `60`) and depth (`40`, `55`) members even when they match the twin plane's family, and falls back to concrete UAV-capable formats (`R16_UNORM`/`R16_UINT`, `R32_FLOAT`/`R32_UINT`, `R8_UINT`), with planar stencil formats (`22 | 47`) classified as integer. - **`default_uav_words` (`twin.rs:285-298`) & 1D view handling (`twin.rs:247-275`)**: Word layout matches `D3D12_UNORDERED_ACCESS_VIEW_DESC` across `Texture1D`, `Texture1DArray`, `Texture2D`, and `Texture2DArray` (`slices > 1` selects array views with `ArraySize` at word 4), and leaving `plane_word = None` for 1D/1D-array views avoids clobbering `FirstArraySlice` at word 3. **Hardware & D3D12 Debug Layer verification** (RTX 5090 + Microsoft WARP, `VICTORY_D3D12_DEBUG=1`): - `cargo xtask policy` and `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`) pass cleanly. - `cargo test --locked -p victory-gpu twin::tests:: -- --test-threads=1` passed 4/4 on both RTX 5090 and WARP under `VICTORY_D3D12_DEBUG=1`. - Verified an additional Debug Layer probe creating 25 concrete UAVs across `D32_FLOAT_S8X24_UINT (20)`, `R32G8X24_TYPELESS (19)`, `D16S8 (118)`, and 1D/1D-array `D32_FLOAT (40)` (default `None`, explicit plane 0 & plane 1 with typeless/depth/stencil/concrete formats, 1D-array with non-zero `FirstArraySlice`, plus out-of-range plane 2 cleanly returning `None`): `GetDeviceRemovedReason().is_ok()` and `host.log_messages() == None` on both RTX 5090 and WARP. - Also verified a clean co-merge with `#1803` (`7c609deb480f`) on `63bcca43` with `twin::tests::` and `list::tests::` passing under `VICTORY_D3D12_DEBUG=1` on both adapters. LGTM.
Dukestar69 commented 2026-11-26 23:29:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T23:29:31Z.

Review: APPROVED


LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).

  • Keeping depth-twin UAVs in concrete UAV formats and supporting default views passes cleanly on discrete NVIDIA hardware.
  • cargo test -p victory-gpu --lib twin:: -- --test-threads=1: all passed.
  • 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:6081465669 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1933#pullrequestreview-6081465669). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T23:29:31Z. **Review:** APPROVED --- LGTM — verified on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). - Keeping depth-twin UAVs in concrete UAV formats and supporting default views passes cleanly on discrete NVIDIA hardware. - `cargo test -p victory-gpu --lib twin:: -- --test-threads=1`: all passed. - `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).
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/1933:upstream-pr/1933'
git switch 'upstream-pr/1933'

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