Formats: lay out packed RGB textures as horizontal texel pairs #1113
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1113
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1113"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Razdva122 on GitHub · 2026-11-24 15:49 UTC · original
Razdva122:formats/texture-transfer→main· +133 −17 · 2 files · 3 commits · openVIctory'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 underVICTORY_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@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.
@adamdotpy on GitHub · 2026-11-24 16:50 UTC · original
Reviewed on Windows 11 / Rust 1.98.1,
f437483on currentmain(ffe310e, merges as it stands), isolated target dir. Verified:cargo test -p victory-formats25 passed / 4 ignored, including both newpacked_rgb_*tests (layout, pitch, tile/detile round-trip for LINEAR and 4 KiB-S, and the invalid-descriptor rejections);cargo test -p victory-hle xg16 passed includingpacked_rgb_reports_texels_and_pairs_separately;cargo clippy --workspace --all-targets --all-features --locked -- -D warningsclean;cargo build --release -p victorybuilds.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 asblock = 2width withblock_height() == 1— a pair never spans rows, which is the whole subtlety of these formats.dimalready 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 (widtheven,samples == 1, no z-order swizzle) matches the cases where the pair model would break, and the new test asserts all three are rejected withError::Invalid. The only other place in the tree that matchedblockagainst1 | 4was theLayout::newcheck itself; the xgtilingshape now multiplies width byblockbut height byblock_height(), which is correct for both packed pairs and 4x4 blocks, and its test pinstexels [510,129]vselements [255,129]vsshape [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 stillNone, 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.SW_4KB_Sonly. Packed RGB with the console's other swizzles (64 KiB Z, etc.) goes through the sametile/detilecode 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_UNORMis exactly what this removes, and the layout math is pinned by round-trip tests rather than by inspection.@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-hlepasses, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@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 theformat()doc incrates/victory-formats/src/texture.rs, so the small note is resolved. The layout change itself is unchanged and still internally consistent:Layout::newlimits it to even widths, a single sample and no Z-order swizzle.tilinginvictory-hle/src/modules/xg.rsscales 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 layoutline 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
@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 ignoredcargo clippy -p victory-formats --all-targets: 0 warningscargo xtask policy: okClean packed-RGB horizontal texel-pair layout handling with passing round-trip tests. Approving.
AI-assisted (Gemini 4 Neon).
@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!
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.