Formats: lay out packed RGB textures as horizontal texel pairs #1113

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

@⁠Razdva122 on GitHub · 2026-11-24 15:49 UTC · original
Razdva122:formats/texture-transfer → main · +133 −17 · 2 files · 3 commits · open

VIctory's XG texture computer currently rejects R8G8_B8G8_UNORM and G8R8_G8B8_UNORM because the console layout table has no entries for them. Both formats store two horizontal texels in each four-byte word. A 10×6 texture therefore has a 5×3 mip whose rows each contain three words.

This adds 2×1 elements to the console layout, tile/detile and XG tiling paths. It preserves texel units for the public tile shape and pitch and reports the mip's storage width in pairs. Synthetic tests check 12 bytes on each of the three rows, explicit offsets in linear, 4 KiB and 64 KiB standard layouts, row padding and an adjacent array slice.

The odd-width example and native D3D12 row measurement come from #386. The title-facing GetCopyableFootprints API was discussed separately in #409. This PR changes the XG layout and tile conversion paths. The GPU staging uploader queries the host D3D12 device for its destination footprints.

An independent RTX 5070 test measured three 12-byte rows for both formats at mip 1 of a 10×6 texture. Upload and readback preserved the synthetic patterns. A separate XG fixture exercised both copy methods and checked offsets, row padding and an adjacent slice in linear and 4 KiB layouts. Native D3D12 measurement · XG fixture

I compared the PR with AMD PAL AddrLib configured for Navi22 (family 0x8f, revision 0x32, GB_ADDR_CONFIG 0x43). For GB_GR and BG_RG, Addr2ComputeSurfaceInfo produced a 32-bit element spanning two horizontal texels. All 747,328 element addresses checked for DXGI 68/69 matched AMD under the standard non-XOR 4 KiB and 64 KiB swizzles. The cases covered 10×6, 130×66 and 510×258 textures, two array slices and up to five mip levels. The regression test pins six AMD byte offsets for the last pair in the odd 5×3 mip. AMD format definitions · Regression and probe parameters

AddrLib supplies a vendor software reference. A physical console measurement and a title log exercising DXGI 68/69 are still outstanding. On main, XG logs refused descriptors as no texture layout. The branch's diagnostics build also logs successful calls with their format and layout under VICTORY_LOG=info,victory_hle::modules::xg=debug. Packed 4:2:2 video remains unsupported.

AI-assisted with Codex.

Windows CI passed both workspace Clippy configurations and the full workspace test suite at 2358c53. Windows job

**@⁠Razdva122** on GitHub · 2026-11-24 15:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/1113) `Razdva122:formats/texture-transfer` → `main` · +133 −17 · 2 files · 3 commits · open VIctory's XG texture computer currently rejects R8G8_B8G8_UNORM and G8R8_G8B8_UNORM because the console layout table has no entries for them. Both formats store two horizontal texels in each four-byte word. A 10×6 texture therefore has a 5×3 mip whose rows each contain three words. This adds 2×1 elements to the console layout, tile/detile and XG tiling paths. It preserves texel units for the public tile shape and pitch and reports the mip's storage width in pairs. Synthetic tests check 12 bytes on each of the three rows, explicit offsets in linear, 4 KiB and 64 KiB standard layouts, row padding and an adjacent array slice. The odd-width example and native D3D12 row measurement come from #386. The title-facing GetCopyableFootprints API was discussed separately in #409. This PR changes the XG layout and tile conversion paths. The GPU staging uploader queries the host D3D12 device for its destination footprints. An independent RTX 5070 test measured three 12-byte rows for both formats at mip 1 of a 10×6 texture. Upload and readback preserved the synthetic patterns. A separate XG fixture exercised both copy methods and checked offsets, row padding and an adjacent slice in linear and 4 KiB layouts. [Native D3D12 measurement](https://git.gtahub.st/github/Marvisak--VIctory/pulls/409) · [XG fixture](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1113) I compared the PR with AMD PAL AddrLib configured for Navi22 (family 0x8f, revision 0x32, GB_ADDR_CONFIG 0x43). For GB_GR and BG_RG, Addr2ComputeSurfaceInfo produced a 32-bit element spanning two horizontal texels. All 747,328 element addresses checked for DXGI 68/69 matched AMD under the standard non-XOR 4 KiB and 64 KiB swizzles. The cases covered 10×6, 130×66 and 510×258 textures, two array slices and up to five mip levels. The regression test pins six AMD byte offsets for the last pair in the odd 5×3 mip. [AMD format definitions](https://github.com/GPUOpen-Drivers/pal/blob/c5e800072a32f68b6ccc4422936d96167c6e0728/src/core/imported/addrlib/src/core/addrelemlib.cpp#L1350-L1359) · [Regression and probe parameters](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1113/commits/2358c53ba4a7c8ba273a2205f1c7998fb3accd68) AddrLib supplies a vendor software reference. A physical console measurement and a title log exercising DXGI 68/69 are still outstanding. On main, XG logs refused descriptors as `no texture layout`. The branch's diagnostics build also logs successful calls with their format and layout under `VICTORY_LOG=info,victory_hle::modules::xg=debug`. Packed 4:2:2 video remains unsupported. AI-assisted with Codex. Windows CI passed both workspace Clippy configurations and the full workspace test suite at `2358c53`. [Windows job](https://github.com/Marvisak/VIctory/actions/runs/45819518734/job/139907824291)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:20:24 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 15:57 UTC · original

We tested this together with #409 and the existing fixed-run tile/detile optimization on our integration branch (a0c2db1). A guest fixture called the XG layout and both copy methods through the texture computer’s vtable. For formats 68 and 69, mip 1 of a 10×6 two-slice array reported 5×3 texels and 3×3 stored elements in both linear and 4 KiB layouts.

With a 16-byte caller row pitch, each copy moved exactly the 12 payload bytes per row. We checked the full tiled buffer against the expected offsets before copying back, then checked the linear output. The padding and all of slice 0 retained their sentinel bytes. All six XG tests and the separate #409 copyable-footprint control passed under Wine. Eleven texture layout tests passed on Linux. This verifies the two guest APIs together on synthetic data. Title use remains open.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 15:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/1113#issuecomment-7136894240) We tested this together with #409 and the existing fixed-run tile/detile optimization on our integration branch (`a0c2db1`). A guest fixture called the XG layout and both copy methods through the texture computer’s vtable. For formats 68 and 69, mip 1 of a 10×6 two-slice array reported 5×3 texels and 3×3 stored elements in both linear and 4 KiB layouts. With a 16-byte caller row pitch, each copy moved exactly the 12 payload bytes per row. We checked the full tiled buffer against the expected offsets before copying back, then checked the linear output. The padding and all of slice 0 retained their sentinel bytes. All six XG tests and the separate #409 copyable-footprint control passed under Wine. Eleven texture layout tests passed on Linux. This verifies the two guest APIs together on synthetic data. Title use remains open.
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 16:50 UTC · original

Reviewed on Windows 11 / Rust 1.98.1, f437483 on current main (ffe310e, merges as it stands), isolated target dir. Verified: cargo test -p victory-formats 25 passed / 4 ignored, including both new packed_rgb_* tests (layout, pitch, tile/detile round-trip for LINEAR and 4 KiB-S, and the invalid-descriptor rejections); cargo test -p victory-hle xg 16 passed including packed_rgb_reports_texels_and_pairs_separately; cargo clippy --workspace --all-targets --all-features --locked -- -D warnings clean; cargo build --release -p victory builds.

What it gets right, checked against the format definitions. DXGI 68/69 (R8G8_B8G8_UNORM, G8R8_G8B8_UNORM) are 4 bytes per two horizontal texels, and the PR models that as block = 2 width with block_height() == 1 — a pair never spans rows, which is the whole subtlety of these formats. dim already rounds texels down then up to whole elements, so an odd mip width rounds up to a whole pair rather than half a pair. The validation gate (width even, samples == 1, no z-order swizzle) matches the cases where the pair model would break, and the new test asserts all three are rejected with Error::Invalid. The only other place in the tree that matched block against 1 | 4 was the Layout::new check itself; the xg tiling shape now multiplies width by block but height by block_height(), which is correct for both packed pairs and 4x4 blocks, and its test pins texels [510,129] vs elements [255,129] vs shape [256,128,1] — the three views of the same mip, separately and consistently.

Two things worth noting, neither blocking.

  • format()'s doc comment no longer lists "packed 4:2:2" among the formats with no layout — 4:2:2 (DXGI 107-114 area) is still None, only the packed RGB pair formats were added, so the comment is now accurate but a reader might think 4:2:2 landed too. One word ("packed 4:2:2 video") would keep it exact.
  • The tile/detile test covers LINEAR and SW_4KB_S only. Packed RGB with the console's other swizzles (64 KiB Z, etc.) goes through the same tile/detile code as every other format, so this is coverage, not risk — but if the title uses packed RGB under a Z swizzle, that combination is the one to measure on hardware first, since the pair's two texels sit in adjacent bits of one word and a Z-order layout interleaves them differently than a 4x4 block.

This closes the gap I flagged in the #953 review: the XG texture computer rejecting R8G8_B8G8_UNORM/G8R8_G8B8_UNORM is exactly what this removes, and the layout math is pinned by round-trip tests rather than by inspection.

**@⁠adamdotpy** on GitHub · 2026-11-24 16:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/1113#issuecomment-7138294320) Reviewed on Windows 11 / Rust 1.98.1, `f437483` on current `main` (`ffe310e`, merges as it stands), isolated target dir. Verified: `cargo test -p victory-formats` 25 passed / 4 ignored, including both new `packed_rgb_*` tests (layout, pitch, tile/detile round-trip for LINEAR and 4 KiB-S, and the invalid-descriptor rejections); `cargo test -p victory-hle xg` 16 passed including `packed_rgb_reports_texels_and_pairs_separately`; `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` clean; `cargo build --release -p victory` builds. **What it gets right, checked against the format definitions.** DXGI 68/69 (`R8G8_B8G8_UNORM`, `G8R8_G8B8_UNORM`) are 4 bytes per *two horizontal texels*, and the PR models that as `block = 2` width with `block_height() == 1` — a pair never spans rows, which is the whole subtlety of these formats. `dim` already rounds texels down then up to whole elements, so an odd mip width rounds up to a whole pair rather than half a pair. The validation gate (`width` even, `samples == 1`, no z-order swizzle) matches the cases where the pair model would break, and the new test asserts all three are rejected with `Error::Invalid`. The only other place in the tree that matched `block` against `1 | 4` was the `Layout::new` check itself; the xg `tiling` shape now multiplies width by `block` but height by `block_height()`, which is correct for both packed pairs and 4x4 blocks, and its test pins `texels [510,129]` vs `elements [255,129]` vs `shape [256,128,1]` — the three views of the same mip, separately and consistently. **Two things worth noting, neither blocking.** - `format()`'s doc comment no longer lists "packed 4:2:2" among the formats with no layout — 4:2:2 (DXGI 107-114 area) is still `None`, only the packed RGB pair formats were added, so the comment is now accurate but a reader might think 4:2:2 landed too. One word ("packed 4:2:2 *video*") would keep it exact. - The tile/detile test covers LINEAR and `SW_4KB_S` only. Packed RGB with the console's other swizzles (64 KiB Z, etc.) goes through the same `tile`/`detile` code as every other format, so this is coverage, not risk — but if the title uses packed RGB under a Z swizzle, that combination is the one to measure on hardware first, since the pair's two texels sit in adjacent bits of one word and a Z-order layout interleaves them differently than a 4x4 block. This closes the gap I flagged in the #953 review: the XG texture computer rejecting `R8G8_B8G8_UNORM`/`G8R8_G8B8_UNORM` is exactly what this removes, and the layout math is pinned by round-trip tests rather than by inspection.
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 18:01 UTC · original

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

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 18:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/1113#issuecomment-7140052526) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at f437483: `cargo test -p victory-formats -p victory-hle` passes, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:17 UTC · original · edited 2026-11-25 07:24 UTC

Automated triage for the maintainers.

Needs work. Re-reviewed at 87c7892, which merges cleanly. The new commit restores "packed 4:2:2 video" in the format() doc in crates/victory-formats/src/texture.rs, so the small note is resolved. The layout change itself is unchanged and still internally consistent:

  • DXGI 68/69 get a 4-byte element two texels wide.
  • Layout::new limits it to even widths, a single sample and no Z-order swizzle.
  • tiling in victory-hle/src/modules/xg.rs scales the tile shape by width and height separately.

What still holds it back is evidence, as the description says. The RTX 5070 measurement covers host D3D12 row sizes, not the console's swizzled layout, and nothing shows the title creates a texture in format 68 or 69. One no texture layout line for format 68/69 from a title run would change the verdict to merge candidate. So would a console or hardware reference for the 2x1 element under a 4 KiB or 64 KiB swizzle.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/1113#issuecomment-7149396594) · edited 2026-11-25 07:24 UTC <!-- victory-triage v1 head=87c7892ca3312018195d316e7a155cf291efdbca verdict=needs-work at=2026-11-25T07:24:58Z --> Automated triage for the maintainers. **Needs work.** Re-reviewed at `87c7892`, which merges cleanly. The new commit restores "packed 4:2:2 video" in the `format()` doc in `crates/victory-formats/src/texture.rs`, so the small note is resolved. The layout change itself is unchanged and still internally consistent: - DXGI 68/69 get a 4-byte element two texels wide. - `Layout::new` limits it to even widths, a single sample and no Z-order swizzle. - `tiling` in `victory-hle/src/modules/xg.rs` scales the tile shape by width and height separately. What still holds it back is evidence, as the description says. The RTX 5070 measurement covers host D3D12 row sizes, not the console's swizzled layout, and nothing shows the title creates a texture in format 68 or 69. One `no texture layout` line for format 68/69 from a title run would change the verdict to merge candidate. So would a console or hardware reference for the 2x1 element under a 4 KiB or 64 KiB swizzle. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-24 16:01 UTC · original · approved these changes

Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):

  • cargo test -p victory-formats: 25 passed, 0 failed, 4 ignored
  • cargo clippy -p victory-formats --all-targets: 0 warnings
  • cargo xtask policy: ok

Clean packed-RGB horizontal texel-pair layout handling with passing round-trip tests. Approving.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-24 16:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/1113#pullrequestreview-6042811759) · **approved these changes** Tested merged cleanly onto `main` (`ffe310e`) on Windows 11 x64 (Rust 1.98.1 MSVC): - `cargo test -p victory-formats`: **25 passed, 0 failed, 4 ignored** - `cargo clippy -p victory-formats --all-targets`: **0 warnings** - `cargo xtask policy`: ok Clean packed-RGB horizontal texel-pair layout handling with passing round-trip tests. Approving. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠yuniskh on GitHub · 2026-11-25 00:35 UTC · original · approved these changes

Thanks for linking my report in #386. Keep up the great work!

**@⁠yuniskh** on GitHub · 2026-11-25 00:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1113#pullrequestreview-6049722891) · **approved these changes** Thanks for linking my report in #386. Keep up the great work!
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/1113/head:github-bot/gh-1113'
git switch 'github-bot/gh-1113'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1113'
git switch 'github-bot/gh-1113'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1113'
git switch 'github-bot/gh-1113'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1113'
git switch 'main'
git merge --squash 'github-bot/gh-1113'
git switch 'main'
git merge --ff-only 'github-bot/gh-1113'
git switch 'main'
git merge 'github-bot/gh-1113'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1113
No description provided.