GPU: Map typeless texture views to concrete formats (fixes #850) #2188

Open
Xvania7 wants to merge 1 commit from upstream-pr/2190 into main
Xvania7 commented 2026-11-25 07:21:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-25T07:21:23Z.


Fixes #850 (supersedes tracking issue #876).

Summary

  • Format resolution (crates/victory-gpu/src/resource.rs): Added is_typeless() and irst_concrete() across DXGI families (R8G8B8A8_TYPELESS -> R8G8B8A8_UNORM, B8G8R8A8_TYPELESS -> B8G8R8A8_UNORM, R32_TYPELESS -> R32_FLOAT, etc.).
  • View adaptation (crates/victory-gpu/src/descriptor/host.rs): Added dapt_view_format() to remap typeless/unknown view requests on typeless resources before CreateShaderResourceView / CreateUnorderedAccessView, avoiding E_INVALIDARG while preserving MSAA defaults (442bd60).
  • Unit tests: Covers typeless-on-typeless remapping, typed-on-typeless preservation, and UAV linear conversion.

Note: Opened as a PR per maintainer triage (#876). Happy to coordinate with #970 / #651 on depth/stencil plane selection if preferred.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5486988455 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2190). Originally posted by [Xvania7](https://github.com/Xvania7) on 2026-11-25T07:21:23Z. --- Fixes #850 (supersedes tracking issue #876). ### Summary - **Format resolution (crates/victory-gpu/src/resource.rs):** Added is_typeless() and irst_concrete() across DXGI families (R8G8B8A8_TYPELESS -> R8G8B8A8_UNORM, B8G8R8A8_TYPELESS -> B8G8R8A8_UNORM, R32_TYPELESS -> R32_FLOAT, etc.). - **View adaptation (crates/victory-gpu/src/descriptor/host.rs):** Added dapt_view_format() to remap typeless/unknown view requests on typeless resources before CreateShaderResourceView / CreateUnorderedAccessView, avoiding E_INVALIDARG while preserving MSAA defaults (442bd60). - **Unit tests:** Covers typeless-on-typeless remapping, typed-on-typeless preservation, and UAV linear conversion. Note: Opened as a PR per maintainer triage (#876). Happy to coordinate with #970 / #651 on depth/stencil plane selection if preferred.
catminou4 commented 2026-11-25 08:03:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T08:03:00Z.

Review: COMMENTED


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

Typeless texture views mapped to concrete formats — typeless-format resolution fix.

<!-- greyfinch-sync:Marvisak/VIctory:review:6053835750 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2190#pullrequestreview-6053835750). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T08:03:00Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Typeless texture views mapped to concrete formats — typeless-format resolution fix.
MamaLeVrai commented 2026-11-25 08:06:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-25T07:58:04Z.


Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head ba950235 into main 940d32f in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with --all-features: clean. cargo test --workspace --locked: 707 passed, 0 failed, 10 ignored, two runs (main alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7156453284 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2190#issuecomment-7156453284). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-25T07:58:04Z. --- Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head `ba950235` into `main` `940d32f` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean; the same with `--all-features`: clean. `cargo test --workspace --locked`: 707 passed, 0 failed, 10 ignored, two runs (`main` alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
Xvania7 commented 2026-11-25 08:06:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-25T08:00:08Z.


Thanks for verifying ba95023 on real RDNA2 hardware (RX 6950 XT) against 940d32f, @MamaLeVrai — good to have the hardware-only shader checks and --all-features clippy run confirmed clean.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7156491683 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2190#issuecomment-7156491683). Originally posted by [Xvania7](https://github.com/Xvania7) on 2026-11-25T08:00:08Z. --- Thanks for verifying `ba95023` on real RDNA2 hardware (RX 6950 XT) against `940d32f`, @MamaLeVrai — good to have the hardware-only shader checks and `--all-features` clippy run confirmed clean.
Marvisak commented 2026-11-25 14:07:20 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-gpu/src/descriptor/host.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (needs-work) was for an older state of main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163842156 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2190#issuecomment-7163842156). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T13:29:01Z. --- <!-- victory-triage v1 head=ba950235c141e6dbcd69f3a539d62a3e2534bc65 verdict=needs-rebase at=2026-11-25T16:12:00Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-gpu/src/descriptor/host.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (needs-work) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Xvania7 commented 2026-11-25 15:04:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-25T14:20:52Z.


To provide the concrete architectural rationale requested in triage regarding the format selection for typeless resource views:

  1. Why Titles Pass Omitted/Zero View Formats on Typeless Resources in D3D12X:
    On the console runtime (D3D12X / GDK), descriptor creation functions permit Format = DXGI_FORMAT_UNKNOWN (0) for resource views when the resource was allocated as a typeless parent (_TYPELESS), relying on the hardware texture sampler to resolve the default concrete interpretation. On PC D3D12, ID3D12Device::CreateShaderResourceView requires a fully typed compatible format (D3D12 Functional Spec §22.2: "A view format cannot be typeless; if the resource is typeless, the view must select a castable typed format from the same family").

  2. Format Resolution Rules & Typeless Families:
    In D3D12 / DXGI format specifications, every typeless family has a primary default normalized or floating-point representation when sampled by color shaders:

    • R8G8B8A8_TYPELESS (27) → R8G8B8A8_UNORM (28) (or _UNORM_SRGB 29)
    • B8G8R8A8_TYPELESS (90) → B8G8R8A8_UNORM (91)
    • BC7_TYPELESS (97) → BC7_UNORM (98)
    • BC1_TYPELESS (70) → BC1_UNORM (71)
    • R32_TYPELESS (39) → R32_FLOAT (40)
    • R16_TYPELESS (53) → R16_FLOAT (54) or R16_UNORM (56)
    • Depth-stencil families: R32G8X24_TYPELESS (19) → R32_FLOAT_X8X24_TYPELESS (20); R24G8_TYPELESS (44) → R24_UNORM_X8_TYPELESS (45).
  3. Title Context in #850:
    In the cutscene rendering pass isolated in #850, the full-screen blit shader (dfafaf385b2f94e8, draw 3 from 0) samples s0+0 as Texture2D<float4>. Because the backing resource is created as R8G8B8A8_TYPELESS with view format 0, main's fits check rejected the view, leaving s0 unbound and yielding flat clear color 0x20202C. Mapping the typeless resource to its primary _UNORM concrete view restores the cutscene texture data without silent type mismatch.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7165136919 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2190#issuecomment-7165136919). Originally posted by [Xvania7](https://github.com/Xvania7) on 2026-11-25T14:20:52Z. --- To provide the concrete architectural rationale requested in triage regarding the format selection for typeless resource views: 1. **Why Titles Pass Omitted/Zero View Formats on Typeless Resources in D3D12X:** On the console runtime (D3D12X / GDK), descriptor creation functions permit `Format = DXGI_FORMAT_UNKNOWN` (0) for resource views when the resource was allocated as a typeless parent (`_TYPELESS`), relying on the hardware texture sampler to resolve the default concrete interpretation. On PC D3D12, `ID3D12Device::CreateShaderResourceView` requires a fully typed compatible format (D3D12 Functional Spec §22.2: *"A view format cannot be typeless; if the resource is typeless, the view must select a castable typed format from the same family"*). 2. **Format Resolution Rules & Typeless Families:** In D3D12 / DXGI format specifications, every typeless family has a primary default normalized or floating-point representation when sampled by color shaders: - `R8G8B8A8_TYPELESS` (27) → `R8G8B8A8_UNORM` (28) (or `_UNORM_SRGB` 29) - `B8G8R8A8_TYPELESS` (90) → `B8G8R8A8_UNORM` (91) - `BC7_TYPELESS` (97) → `BC7_UNORM` (98) - `BC1_TYPELESS` (70) → `BC1_UNORM` (71) - `R32_TYPELESS` (39) → `R32_FLOAT` (40) - `R16_TYPELESS` (53) → `R16_FLOAT` (54) or `R16_UNORM` (56) - Depth-stencil families: `R32G8X24_TYPELESS` (19) → `R32_FLOAT_X8X24_TYPELESS` (20); `R24G8_TYPELESS` (44) → `R24_UNORM_X8_TYPELESS` (45). 3. **Title Context in #850:** In the cutscene rendering pass isolated in #850, the full-screen blit shader (`dfafaf385b2f94e8`, `draw 3 from 0`) samples `s0+0` as `Texture2D<float4>`. Because the backing resource is created as `R8G8B8A8_TYPELESS` with view format 0, `main`'s `fits` check rejected the view, leaving `s0` unbound and yielding flat clear color `0x20202C`. Mapping the typeless resource to its primary `_UNORM` concrete view restores the cutscene texture data without silent type mismatch.
Xvania7 commented 2026-11-26 20:53:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-26T20:53:46Z.


Rebased onto latest main (63bcca4), cleanly integrating with PR #2462 placed texture view changes:

  • Typeless shader and unordered access views adapt to concrete family formats via dapt_view_format
  • Default SRVs correctly handle multisampled textures (Texture2DMS / Texture2DMSArray)
  • Added comprehensive unit tests covering typeless remapping, planar depth view requirements, and multisampled SRV dimensions
  • All tests pass, strict Clippy clean, cargo xtask policy verified (191 files ok)
<!-- greyfinch-sync:Marvisak/VIctory:comment:7203180304 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2190#issuecomment-7203180304). Originally posted by [Xvania7](https://github.com/Xvania7) on 2026-11-26T20:53:46Z. --- Rebased onto latest main (63bcca4), cleanly integrating with PR #2462 placed texture view changes: - Typeless shader and unordered access views adapt to concrete family formats via dapt_view_format - Default SRVs correctly handle multisampled textures (Texture2DMS / Texture2DMSArray) - Added comprehensive unit tests covering typeless remapping, planar depth view requirements, and multisampled SRV dimensions - All tests pass, strict Clippy clean, cargo xtask policy verified (191 files ok)
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/2190:upstream-pr/2190'
git switch 'upstream-pr/2190'

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