GPU: keep A8_UNORM out of the R8 typeless family #1390

Merged
AnoHunted merged 1 commit from upstream-pr/1390 into main 2026-11-25 00:14:00 +00:00
AnoHunted commented 2026-11-24 17:41:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AnoHunted on 2026-11-24T17:41:15Z.


What

family() returns the typeless format at the head of a format's family (or the
format itself when it has none). Its table folded DXGI_FORMAT 65 (A8_UNORM)
into the R8 typeless family (60) via the range 60..=65. DXGI's R8 typeless
family is only R8_UNORM/UINT/SNORM/SINT (61..=64); A8_UNORM has no
typeless family and is not a cast target of R8_TYPELESS. This narrows the
range to 60..=64, so family(65) now maps to itself.

Why

When a view's format and its host resource's format fall in the same family,
the view is treated as a compatible typeless cast and its format is taken from
the resource. With A8_UNORM folded into the R8 family, an R8_* view of an
A8_UNORM host texture counted as same-family and was silently reinterpreted
rather than refused. D3D12 does not allow casting A8_UNORM to the R8 group
(they are different typeless families), so such a view should be rejected.
Dropping 65 from the range restores that: family(view) != family(own), and
the view is refused instead of quietly changing what is read.

Tested

Windows 11, NVIDIA GeForce RTX 5080, Rust 1.98.1.
cargo test -p victory-gpu -- --test-threads=1, main vs this branch:

passed failed ignored
main 50 0 1
branch 51 0 1

The one extra test is a8_unorm_is_not_in_the_r8_typeless_family, a pure table
test (no device needed) asserting family(60)==60, family(61..=64)==60,
family(65)==65, and the 59/66 boundaries. The rest of the victory-gpu suite,
including its live D3D12 tests, ran on the RTX 5080 with no regression.

Not tested

No in-game reproduction: I do not have a title case that aliases an A8_UNORM
texture through an R8_* view, so this is a defensive fix pinned to the DXGI
typeless-family table rather than an observed crash. Not tested on AMD.

No game files were used.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6587837446 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1390). Originally posted by [AnoHunted](https://github.com/AnoHunted) on 2026-11-24T17:41:15Z. --- ## What `family()` returns the typeless format at the head of a format's family (or the format itself when it has none). Its table folded `DXGI_FORMAT` 65 (`A8_UNORM`) into the R8 typeless family (60) via the range `60..=65`. DXGI's R8 typeless family is only `R8_UNORM`/`UINT`/`SNORM`/`SINT` (61..=64); `A8_UNORM` has no typeless family and is not a cast target of `R8_TYPELESS`. This narrows the range to `60..=64`, so `family(65)` now maps to itself. ## Why When a view's format and its host resource's format fall in the same family, the view is treated as a compatible typeless cast and its format is taken from the resource. With `A8_UNORM` folded into the R8 family, an `R8_*` view of an `A8_UNORM` host texture counted as same-family and was silently reinterpreted rather than refused. D3D12 does not allow casting `A8_UNORM` to the R8 group (they are different typeless families), so such a view should be rejected. Dropping 65 from the range restores that: `family(view) != family(own)`, and the view is refused instead of quietly changing what is read. ## Tested Windows 11, NVIDIA GeForce RTX 5080, Rust 1.98.1. `cargo test -p victory-gpu -- --test-threads=1`, `main` vs this branch: | | passed | failed | ignored | |---|---|---|---| | main | 50 | 0 | 1 | | branch | 51 | 0 | 1 | The one extra test is `a8_unorm_is_not_in_the_r8_typeless_family`, a pure table test (no device needed) asserting `family(60)==60`, `family(61..=64)==60`, `family(65)==65`, and the 59/66 boundaries. The rest of the `victory-gpu` suite, including its live D3D12 tests, ran on the RTX 5080 with no regression. ## Not tested No in-game reproduction: I do not have a title case that aliases an `A8_UNORM` texture through an `R8_*` view, so this is a defensive fix pinned to the DXGI typeless-family table rather than an observed crash. Not tested on AMD. No game files were used.
catminou4 commented 2026-11-24 21:02:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:49:15Z.

Review: COMMENTED


Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; this is source review plus the PR's own Windows tests.

A8_UNORM (DXGI 65) no longer folds into the R8 typeless family: family range corrected from 60..=65 to 60..=64, so an A8 texture is not treated as R8_TYPELESS-castable. The test pins the exact DXGI numbering (60-64 R8 family, 65 A8_UNORM standalone, 59/66 boundaries). Small, correct, well-tested.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047162867 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1390#pullrequestreview-6047162867). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T20:49:15Z. **Review:** COMMENTED --- Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; this is source review plus the PR's own Windows tests. A8_UNORM (DXGI 65) no longer folds into the R8 typeless family: family range corrected from 60..=65 to 60..=64, so an A8 texture is not treated as R8_TYPELESS-castable. The test pins the exact DXGI numbering (60-64 R8 family, 65 A8_UNORM standalone, 59/66 boundaries). Small, correct, well-tested.
upstream-sync closed this pull request 2026-11-25 01:06:27 +00:00
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!1390
No description provided.