Add Xbox texture layouts for formats 189–190 #7

Open
github-bot wants to merge 3 commits from github-bot/gh-7 into main AGit
Owner

@⁠Lkxex on GitHub · 2026-11-25 11:25 UTC · original
Lkxex:fix/console-texture-layouts → main · +23 −2 · 1 files · 3 commits · open

Change

Support Xbox texture formats 189 and 190 in victory_formats::texture::format so Texture::new can compute their layouts. Format 189 uses four bytes per texel, and format 190 uses one byte per texel.

Format 191 was removed from this PR after @⁠adrianmjim's Windows/RX 7900 XT review confirmed the host creates format 191 as DXGI_FORMAT_A4B4G4R4_UNORM (2 bytes per texel) with no host remap in pc_format(), so keeping 191 at 4 bytes caused a host/console layout mismatch.

The regression test compares mipmapped array textures in formats 189 and 190 with reference formats of the same texel size, using both linear and 64 KiB swizzled layouts.

Validation

  • cargo test --locked -p victory-formats --lib (25 passed, 0 failed)
  • cargo check --workspace --all-targets --locked
  • git diff --check

Validation used synthetic texture descriptions. In-game rendering and frame rate were not measured. This backport was prepared with AI assistance.

Backported from VItoriaBr #11, with the original commit authors preserved.

**@⁠Lkxex** on GitHub · 2026-11-25 11:25 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/7) `Lkxex:fix/console-texture-layouts` → `main` · +23 −2 · 1 files · 3 commits · open ### Change Support Xbox texture formats 189 and 190 in `victory_formats::texture::format` so `Texture::new` can compute their layouts. Format 189 uses four bytes per texel, and format 190 uses one byte per texel. Format 191 was removed from this PR after @⁠adrianmjim's Windows/RX 7900 XT review confirmed the host creates format 191 as `DXGI_FORMAT_A4B4G4R4_UNORM` (2 bytes per texel) with no host remap in `pc_format()`, so keeping 191 at 4 bytes caused a host/console layout mismatch. The regression test compares mipmapped array textures in formats 189 and 190 with reference formats of the same texel size, using both linear and 64 KiB swizzled layouts. ### Validation - `cargo test --locked -p victory-formats --lib` (25 passed, 0 failed) - `cargo check --workspace --all-targets --locked` - `git diff --check` Validation used synthetic texture descriptions. In-game rendering and frame rate were not measured. This backport was prepared with AI assistance. Backported from [VItoriaBr #11](https://github.com/uiliannn/VItoriaBr/pull/11), with the original commit authors preserved.
(cherry picked from commit 0d1c4e034dde4d3cf2652b57bbbf692404b67bbd)
(cherry picked from commit dcc0305cade25c86aa20159235c5df93713ef1b0)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:33:02 +00:00
Author
Owner

@⁠Ekabusto on GitHub · 2026-11-25 12:47 UTC · original

Checked locally: cargo test -p victory-formats --lib passes (25 passed, 4 ignored), clippy clean, no conflicts.

The sizes agree with the GPU side's own table, victory-gpu/src/resource.rs:118-128 (189 and 191 at 4 bytes, 190 at 1), so the two tables now match. One limit of the test, not a blocker: it compares each format with a reference of the same texel size, so it checks that the layout follows from the size, not that the size is right; resource.rs is the evidence for that. Looks good to me.

Reviewed on Windows 11 (build 26300), Rust 1.98.1, each PR in its own worktree; no game data, not run in the game. AI-assisted (Claude Code).

**@⁠Ekabusto** on GitHub · 2026-11-25 12:47 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/7#issuecomment-7162858821) Checked locally: `cargo test -p victory-formats --lib` passes (25 passed, 4 ignored), clippy clean, no conflicts. The sizes agree with the GPU side's own table, `victory-gpu/src/resource.rs:118-128` (189 and 191 at 4 bytes, 190 at 1), so the two tables now match. One limit of the test, not a blocker: it compares each format with a reference of the same texel size, so it checks that the layout follows from the size, not that the size is right; `resource.rs` is the evidence for that. Looks good to me. Reviewed on Windows 11 (build 26300), Rust 1.98.1, each PR in its own worktree; no game data, not run in the game. AI-assisted (Claude Code).
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-25 17:23 UTC · original

Tested on an RX 7900 XT (Windows 11 26300, driver's D3D12) with this PR applied to 71652a2.

Format 191 is 4 bytes per texel in the new layout, but the host texture made for it has 2.

pc_format() (resource.rs:231) remaps only 118-120, so a console format-191 texture is created on the host as DXGI_FORMAT(191), which in the Windows headers is DXGI_FORMAT_A4B4G4R4_UNORM (16 bpp). A local check that compares the two for a 256-texel-wide 2D texture:

host format 191 support true Support1 0xe4d3f0: row of 256 texels 512 bytes (pitch 512), console element 4 bytes
assertion `left == right` failed: bytes per texel, host vs console layout
  left: 512
 right: 1024

(GetCopyableFootprints on the host description vs texture_layout(..).planes[0].layout.desc.element_bytes.)

On main, texture_layout() returns None for 191, so texture::staging() logs "texture contents without a console layout not uploaded" and leaves it alone. With this PR the upload goes ahead with the wrong texel size:

  • widths up to 64: Layout::detile's row_pitch < bytes check passes (host pitch 256 >= 64 * 4), so each host row is filled with 64 four-byte texels into a 128-byte row: scrambled contents;
  • wider textures: the check fails and "texture not detiled" is logged on every refresh.

The same applies to XG: XGCreateTextureComputer now succeeds for 191 with a 4-byte layout, where it returned E_INVALIDARG before.

189 (R10G10B10_SNORM_A2_UNORM, 4 bytes) and 190 (R4G4_UNORM, 1 byte) look right. For 191, either the console format really is 4 bytes and then it needs a host remap in pc_format() (like 118-120), or it is A4B4G4R4 and belongs in the 2-byte arm. The "191 (24/8 color)" note on element() (resource.rs:119), which the PR follows, gives no source; and the new test cannot tell, because it compares 191 with RGBA8 (28), picked to have the assumed size.

Unless someone has a source for 191, I would keep 189 and 190 and leave 191 out of this PR.

**@⁠adrianmjim** on GitHub · 2026-11-25 17:23 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/7#issuecomment-7169440676) Tested on an RX 7900 XT (Windows 11 26300, driver's D3D12) with this PR applied to `71652a2`. **Format 191 is 4 bytes per texel in the new layout, but the host texture made for it has 2.** `pc_format()` (`resource.rs:231`) remaps only 118-120, so a console format-191 texture is created on the host as `DXGI_FORMAT(191)`, which in the Windows headers is `DXGI_FORMAT_A4B4G4R4_UNORM` (16 bpp). A local check that compares the two for a 256-texel-wide 2D texture: ``` host format 191 support true Support1 0xe4d3f0: row of 256 texels 512 bytes (pitch 512), console element 4 bytes assertion `left == right` failed: bytes per texel, host vs console layout left: 512 right: 1024 ``` (`GetCopyableFootprints` on the host description vs `texture_layout(..).planes[0].layout.desc.element_bytes`.) On `main`, `texture_layout()` returns `None` for 191, so `texture::staging()` logs "texture contents without a console layout not uploaded" and leaves it alone. With this PR the upload goes ahead with the wrong texel size: - widths up to 64: `Layout::detile`'s `row_pitch < bytes` check passes (host pitch 256 >= 64 * 4), so each host row is filled with 64 four-byte texels into a 128-byte row: scrambled contents; - wider textures: the check fails and "texture not detiled" is logged on every refresh. The same applies to XG: `XGCreateTextureComputer` now succeeds for 191 with a 4-byte layout, where it returned `E_INVALIDARG` before. 189 (R10G10B10_SNORM_A2_UNORM, 4 bytes) and 190 (R4G4_UNORM, 1 byte) look right. For 191, either the console format really is 4 bytes and then it needs a host remap in `pc_format()` (like 118-120), or it is A4B4G4R4 and belongs in the 2-byte arm. The "191 (24/8 color)" note on `element()` (`resource.rs:119`), which the PR follows, gives no source; and the new test cannot tell, because it compares 191 with RGBA8 (28), picked to have the assumed size. Unless someone has a source for 191, I would keep 189 and 190 and leave 191 out of this PR.
Author
Owner

@⁠lcg007xd-c on GitHub · 2026-11-25 21:23 UTC · original · reviewed

Verified on Linux (Rust 1.98.1)

  • cargo test -p victory-formats --lib on 821d31c: 25 passed, 0 failed, 4 ignored. The same with the PR merged into current main (--no-commit).
  • Fail-without-fix: with 189 and 190 removed from the format() arms, console_formats_use_the_expected_color_layouts fails with format 189, Swizzle(0), left: Err(Invalid).
  • cargo clippy -p victory-formats --target x86_64-pc-windows-msvc: 0 warnings, same as main.
  • git merge --no-commit --no-ff into main: merges cleanly.

Finding: 189 and 190 have the same host-side gap as 191

@⁠adrianmjim's point about 191 seems to apply to 189 and 190 as well, in a different way:

  • pc_format() (crates/victory-gpu/src/resource.rs:231-238) remaps only 118-120. Every other format number reaches the host D3D12 resource unchanged, through resource.rs:295/346/1233, descriptor/host.rs:2006/2017 and list.rs:778.
  • In the Windows headers, 189 and 190 are not color formats. In windows 0.62.2 (the version in Cargo.lock), Win32/Graphics/Dxgi/Common/mod.rs:157-158 defines DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE = 189 and DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE = 190. These are opaque sampler-feedback formats with no texel layout an upload could write.

So on the host side, this PR changes texture_layout() from None (contents left alone, with the existing log line) to a 4- or 1-byte layout. The host texture it uploads into is either refused at creation or is an opaque feedback map. The new test can't show this, because it compares each format with a reference of the assumed size, as @⁠Ekabusto noted.

A suggestion, depending on what the PR is for:

  • If it targets XG (XGCreateTextureComputer) only, the console-side layout is all that's needed and this is fine. A note in the description would help, plus perhaps a pc_format follow-up issue.
  • If host uploads are meant to work, 189 and 190 need host stand-ins in pc_format(), the way 118-120 have them. 189 has no exact PC equivalent (signed 10-bit RGB with unsigned A2), and 190 (R4G4) has no 8-bit PC format, so both would probably need a stand-in plus a conversion. Until then, leaving them out of the host path may be safer than uploading with a layout the host resource doesn't share.

I have not run this on Windows, so I can't say which of the two failure modes happens there: creation refused, or an opaque resource.

Not verified

  • Host texture creation for 189/190 on a D3D12 device, XG behaviour, and in-game rendering.

Reviewed with Claude Code.

**@⁠lcg007xd-c** on GitHub · 2026-11-25 21:23 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/7#pullrequestreview-6065169449) · **reviewed** ### Verified on Linux (Rust 1.98.1) - `cargo test -p victory-formats --lib` on 821d31c: 25 passed, 0 failed, 4 ignored. The same with the PR merged into current main (`--no-commit`). - Fail-without-fix: with `189` and `190` removed from the `format()` arms, `console_formats_use_the_expected_color_layouts` fails with `format 189, Swizzle(0)`, `left: Err(Invalid)`. - `cargo clippy -p victory-formats --target x86_64-pc-windows-msvc`: 0 warnings, same as main. - `git merge --no-commit --no-ff` into main: merges cleanly. ### Finding: 189 and 190 have the same host-side gap as 191 @⁠adrianmjim's point about 191 seems to apply to 189 and 190 as well, in a different way: - `pc_format()` (`crates/victory-gpu/src/resource.rs:231-238`) remaps only 118-120. Every other format number reaches the host D3D12 resource unchanged, through `resource.rs:295/346/1233`, `descriptor/host.rs:2006/2017` and `list.rs:778`. - In the Windows headers, 189 and 190 are not color formats. In `windows` 0.62.2 (the version in `Cargo.lock`), `Win32/Graphics/Dxgi/Common/mod.rs:157-158` defines `DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE = 189` and `DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE = 190`. These are opaque sampler-feedback formats with no texel layout an upload could write. So on the host side, this PR changes `texture_layout()` from `None` (contents left alone, with the existing log line) to a 4- or 1-byte layout. The host texture it uploads into is either refused at creation or is an opaque feedback map. The new test can't show this, because it compares each format with a reference of the assumed size, as @⁠Ekabusto noted. A suggestion, depending on what the PR is for: - If it targets XG (`XGCreateTextureComputer`) only, the console-side layout is all that's needed and this is fine. A note in the description would help, plus perhaps a `pc_format` follow-up issue. - If host uploads are meant to work, 189 and 190 need host stand-ins in `pc_format()`, the way 118-120 have them. 189 has no exact PC equivalent (signed 10-bit RGB with unsigned A2), and 190 (R4G4) has no 8-bit PC format, so both would probably need a stand-in plus a conversion. Until then, leaving them out of the host path may be safer than uploading with a layout the host resource doesn't share. I have not run this on Windows, so I can't say which of the two failure modes happens there: creation refused, or an opaque resource. ### Not verified - Host texture creation for 189/190 on a D3D12 device, XG behaviour, and in-game rendering. Reviewed with Claude Code.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/7/head:github-bot/gh-7'
git switch 'github-bot/gh-7'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-7'
git switch 'github-bot/gh-7'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-7'
git switch 'github-bot/gh-7'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-7'
git switch 'main'
git merge --squash 'github-bot/gh-7'
git switch 'main'
git merge --ff-only 'github-bot/gh-7'
git switch 'main'
git merge 'github-bot/gh-7'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.