Skip to content

Texture layouts: every pipe and bank XOR mode is addressed, on both consoles (builds on #892) - #932

Merged
trustno1-coder merged 4 commits into
trustno1-coder:mainfrom
wildheathen:xg-xor-modes
Nov 28, 2026
Merged

trustno1-coder merged 4 commits into
trustno1-coder:mainfrom
wildheathen:xg-xor-modes

Conversation

@wildheathen

Copy link
Copy Markdown
Contributor

Builds on #892 (its two commits, up to 7f6e2aa, come first here; this replaces its single-layout case with the general one). Merge after #892, or instead of it.

What happens

#880 and #892 found the ocean's height map, a 256x256 R32_FLOAT texture in SW_64KB_R_X, failing to tile on read-back (a texture copied back could not be tiled e=Unsupported). #892 addresses that one layout. Every other pipe and bank XOR mode (_X, _T) still had no addresses at all, in texback and in the texture computer the title calls (its element offset and copy methods return an error for them). The height map's equation also depends on coordinate bits above 255, so it does not carry over to larger textures of the same mode.

The change

victory-formats (texture.rs):

  • XOR_PATTERNS: addrlib's RB+ single-sample swizzle patterns for the two consoles' pipes and packers (Series S 8 and 4, Series X 32 and 8, the configurations Texture read-back: the ocean's height map in SW_64KB_R_X is tiled for each console (port of DoubleGhosty/cool_fox d9f3ea6f8) #892 uses), for every XOR mode and element size (1 to 16 bytes): SW_4K_S_X, SW_4K_D_X, SW_64K_S_T, SW_64K_D_T, SW_64K_Z_X_1xaa, SW_64K_S_X, SW_64K_D_X, SW_64K_R_X_1xaa, and the 3D SW_4K_S3_X, SW_64K_S3_T, SW_64K_S3_X, SW_64K_D3_X. Each row is the ADDR_SW_PATINFO labelled "8 pipes (4 PKRs)" or "32 pipes (8 PKRs)" in gfx10SwizzlePattern.h, expanded from GFX10_SW_PATTERN_NIBBLE01..NIBBLE4 as GetSwizzlePatternFromPatternInfo does. They were extracted with a small script; I can add it to the repository if wanted.
  • Layout::configure_xor(PipeConfig) (was configure_render_xor(RenderPipeConfig)) picks the row as GetSwizzlePatternInfo does: thick 3D layouts use the S3/D3 patterns, 3D Z_X and R_X the 2D ones. MSAA stays unaddressed.
  • offset and tile/detile follow ComputeSurfaceAddrFromCoordMacroTiled: the block's place from the coordinates, plus the pattern applied to the whole coordinates and slice (shifted into the tail for a tail mip), whose bits above the block still pick the pipe. The copies move runs of elements whose x bits land on consecutive address bits, the rest one element at a time.

victory-gpu:

victory-hle (xg.rs): the texture computer configures its layouts the same way, so its element offset and copy methods work for XOR modes.

Tests

  • New texture::tests::xor_modes_tile_where_offset_points: 13 layouts (every XOR mode, 3D S_T included; 2D, arrays, thick and thin 3D; full mip chains with tails; 1 to 16-byte elements), on both consoles. Each element gets its own value; after tile, every element is where offset says (so no two elements share an address), and detile gives the rows back.
  • New modules::xg::tests::xor_modes_have_element_offsets: the texture computer gives element offsets for a 256x256 R32 SW_64KB_R_X texture, including the pipe bit x bit 7 flips.
  • Texture read-back: the ocean's height map in SW_64KB_R_X is tiled for each console (port of DoubleGhosty/cool_fox d9f3ea6f8) #892's render_xor_water_matches_both_consoles_with_padded_rows passes unchanged except for the renamed API: the general code gives the same bytes as the XCL digests for both consoles.
  • Texture read-back: the ocean's height map in SW_64KB_R_X is tiled for each console (port of DoubleGhosty/cool_fox d9f3ea6f8) #892's resource test, renamed xor_layouts_are_addressed_at_a_block_boundary: SW_64KB_S_X at a 64 KiB boundary is now addressed (was not); a new row checks it is not 4 KiB off one.
  • cargo test -p victory-formats --lib: 48 passed, 5 ignored.
  • cargo test -p victory-gpu --lib: 454 passed, 36 ignored.
  • cargo test -p victory-hle --lib: 189 passed, 3 ignored.
  • Clippy on the three crates: nothing in the changed lines (the existing manual_is_multiple_of in shadow.rs and gameinput.rs remain).

Not run with the game. On a boat or in the water, a log with this change should no longer have could not be tiled for an XOR mode.

No game files, dumps or extracted data are included.

kibagami-nc and others added 4 commits November 28, 2026 19:38
… each console (port of DoubleGhosty/cool_fox d9f3ea6f8)

The title's CPU code reads the ocean's 256x256 R32_FLOAT height map,
which its wave passes write, and texback copies it into title memory in
the console's layout. That texture is in SW_64KB_R_X, a pipe and bank
XOR mode the tiler had no addressing for, so the copy back could not be
tiled and the CPU read what was in that memory before. The logs of
trustno1-coder#788, trustno1-coder#853 and trustno1-coder#859 each have "a texture copied back could not be tiled
e=Unsupported"; the warning does not say for which texture.

victory-formats: Layout::configure_render_xor addresses that one layout
(a 256x256 plane of 4-byte elements, one mip, a 64 KiB-aligned
allocation) with addrlib's GFX10_SW_64K_R_X_1xaa_RBPLUS equations for
the console's pipes and packers: Series S 8 and 4, Series X 32 and 8.

victory-gpu: title_texture sets it for an R32_FLOAT texture at a
64 KiB-aligned address, by the console the title runs as. A texture
whose layout still cannot be addressed is left alone before any copy is
recorded, with one warning that names its size, format and swizzle.

From DoubleGhosty/cool_fox d9f3ea6f8 ("Support the aligned water height
texture readback for boat missions"). The test's digests come from
XCL's independent GFX10 tiler.
…o1-coder#881

trustno1-coder#881 skips the copy back of a texture whose layout the tiler cannot
address, at the list, with a test on WARP. This change also returned no
target for such a texture: the same skip twice, and trustno1-coder#881 came first. So
title_texture only sets the XOR addressing now, and its test checks what
it gives: the layout addressed or not, at the right place and size.
…onsoles

Builds on the one SW_64KB_R_X layout the ocean's height map uses. The XOR
modes (_X, _T) now have addresses for every element size, 2D, arrays and
3D, mips and mip tails, from addrlib's RB+ swizzle patterns for the
console's pipes and packers (Series S 8 and 4, Series X 32 and 8):

- XOR_PATTERNS holds the single-sample PATINFO rows of
  gfx10SwizzlePattern.h for those two configurations, expanded from the
  NIBBLE01..NIBBLE4 tables as GetSwizzlePatternFromPatternInfo does.
- Layout::configure_xor(PipeConfig) picks the row as
  GetSwizzlePatternInfo does; offset and the copies follow
  ComputeSurfaceAddrFromCoordMacroTiled: block place, then the pattern on
  the whole coordinates and slice.
- title_texture configures any texture at a block-aligned address, and
  the xg texture computer configures its layouts, by the console the
  title runs as (Console::pipes).
…; the texture computer's XOR offsets are tested

Review notes: the doc names the nibble tables used, says SW_4KB_R_X has no
pattern, and the element sizes the test covers.

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally merged onto main (63b902f).

  • Merge & Policy: Clean merge across victory-formats, victory-gpu, and victory-hle; cargo xtask policy passed (294 files ok).
  • Tests:
    • cargo test -p victory-formats --lib texture:: passed (24 passed; 0 failed, including render_xor_water_matches_both_consoles_with_padded_rows and xor_modes_tile_where_offset_points).
    • cargo test -p victory-hle --lib xg:: passed (5 passed; 0 failed, including xor_modes_have_element_offsets).
  • Lint: cargo clippy -p victory-formats --lib -- -D warnings passed with 0 warnings.

Comprehensive pipe/bank XOR swizzle addressing coverage for both console profiles. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

@cxy0072019-sketch

Copy link
Copy Markdown

Confirmed the 256×256 R32_FLOAT ocean read-back on an RTX 5070 Ti (621.24), Windows 11 build 28000, Series S profile, and 1920×1080 output. Both runs used the same 1b1ad18 diagnostic executable, Gambit Bay save, and input sequence. A local test switch disabled only the new XOR layout configuration in the control.

  • New layout enabled — 256x256 ocean-layout readback landed format=Some(DXGI_FORMAT(41)) bytes=262144.
  • Old layout path — 256x256 ocean-layout readback rejected e=Unsupported format=DXGI_FORMAT(41).

The surface and seabed were visible in both runs. The dark underwater waterline remained, and the live camera positions differed. The comparison confirms the read-back fix.

@jptorres96

Copy link
Copy Markdown

I compared this PR's Layout::offset at 1b1ad18 with AMD's PAL addrlib (c5e800072a32f68b6ccc4422936d96167c6e0728, the same commit Yoshi-233 used for #892), for every XOR mode here, not only SW_64KB_R_X.

Setup. addrlib was built from source with ADDR_GFX10_BUILD, family FAMILY_NV, revision 0x28 (Navi21, RB+), and GB_ADDR_CONFIG set to 8 pipes / 4 packers (Series S) and 32 pipes / 8 packers (Series X), 256-byte pipe interleave. The surfaces were flags.texture = 1, one sample, pipeBankXor = 0. A small example in victory-formats wrote offset(mip, x, y, z) for every element of every mip and slice. For each of those coordinates the harness called Addr2ComputeSurfaceAddrFromCoord and compared the result. Layout::size was also compared with Addr2ComputeSurfaceInfo's surfSize.

Layouts. The 13 cases of xor_modes_tile_where_offset_points, unchanged: 2D and 3D, arrays, full mip chains with tails, 1 to 16-byte elements, modes 17, 18, 21, 22, 24, 25, 26 and 27. I added two SW_64KB_R_X planes: the 256x256 R32_FLOAT surface from #880, and a 1024x512 one, so that the coordinate bits above 255 are covered.

Configuration Layouts Offsets matching addrlib Size mismatches
8 pipes / 4 packers (Series S) 15 1,130,290 / 1,130,290 0
32 pipes / 8 packers (Series X) 15 1,130,290 / 1,130,290 0

Checks on the harness itself:

Not covered: MSAA (not addressed here), a non-zero pipeBankXor (this PR assumes block-aligned memory, as #892 does), and the victory-hle texture computer beyond its own test. This is synthetic only: no game files, dumps or extracted data. I can share the harness (about 150 lines of C++ plus a small Rust example) if it's useful.

@kibagami-nc

Copy link
Copy Markdown
Contributor

Good to have the general case, thanks, and for keeping #892's two commits first. If this lands, it contains #892, so #892 can be closed then.

One way to check the new rows the way the 256x256 case was checked: Yoshi-233 compared #892's Layout::offset with a separately built AMD PAL addrlib, every offset, for both configurations, with 0 mismatches. The same comparison over a few more modes and element sizes, for instance SW_64KB_S_X and SW_64KB_D_X at 4 and 8 bytes and one _T mode, would cover the rows extracted by script.

@jptorres96

Copy link
Copy Markdown

@kibagami-nc Our comments crossed: the one just above is that comparison, for the 13 test layouts. To cover the rows extracted by script, I then ran the whole matrix: every XOR mode here (17, 18, 21, 22, 24, 25, 26, 27) at every element size (1, 2, 4, 8 and 16 bytes). Each combination was run as a 203x141 2D array of 2 slices and as a 45x37x19 3D texture, with full mip chains, on both consoles, at 1b1ad18, against the same addrlib build.

addrlib was used two independent ways:

  • Per coordinate, through Addr2ComputeSurfaceAddrFromCoord, as before. This path goes through addrlib's equation table.
  • By copy, through Addr2CopyMemToSurface. This path tiles memory from the swizzle patterns (LutAddresser) and does not use the equations. Each element of a linear mip holds its own 32-bit index, split over passes for 1- and 2-byte elements. After addrlib tiles it, the byte at Layout::offset of each element must hold that element's index.
Path Layouts (both consoles) Elements matching
Copy (patterns) 136 7,994,340 / 7,994,340
Per coordinate (equations) 136 with an equation 8,075,040 / 8,075,040

Notes:

  • 3D SW_64KB_D_X at 8 and 16 bytes: addrlib has no equation for these and returns ADDR_INVALIDPARAMS per coordinate. By copy they match: 35,640 / 35,640 each, on both consoles.
  • SW_64KB_Z_X at 16 bytes: addrlib rejects the surface itself (a Z layout has no 128-bit element). Per coordinate its offsets match anyway.
  • 3D SW_64KB_D_T and SW_4KB_D_X: Layout::new refuses them, so they stay unaddressed rather than wrong. Not in the matrix.
  • Negative control: checking each console's offsets against the other's configuration, by copy, gives 7,272,756 mismatches.

So the rows extracted by script agree with addrlib's own patterns for every mode and element size, 2D and 3D, on both consoles. MSAA and a non-zero pipe/bank XOR remain outside, as in the PR. Synthetic only: no game files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants