Formats: render-target XOR layouts (SW_64KB_R_X) have addresses on both consoles #2879

Open
github-bot wants to merge 4 commits from github-bot/gh-2879 into main AGit
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 22:58 UTC · original
0xkn0wh3r3:formats/render-target-xor-tiling → main · +381 −3 · 3 files · 4 commits · open

What

Render-target XOR layouts had no address equation (Layout::addressable() was false). They could be sized, but not detiled, tiled or addressed. So a title texture in such a layout uploaded nothing from title memory, and XGTextureAddressComputer offsets into it came back as 0 with a warning.

The XOR modes route pipe and bank address bits by the GPU's configuration, and that differs between the Series X and S. This PR adds:

  • XOR tables: for SW_64KB_R_X, the per-coordinate-bit XOR tables of GFX10 SW_64K_R_X_1xaa_RBPLUS without a base pipe XOR. They cover 32 pipes and 8 packers (Series X) and 8 pipes and 4 packers (Series S). Bits past a block's side choose the pipe of the neighbouring blocks.

  • Scope: single-mip, single-slice, single-sample 2D layouts with 2-, 4- and 8-byte elements. Other XOR layouts stay unaddressable, as before.

  • Console model: set_series_s_tiling picks the tables, and victory_gpu::console::set calls it.

  • Copies: detiling and tiling move 16-byte runs, since the low four address bits are column bits in every table.

  • Uploads: texture staging used to refuse every XOR layout. It now refuses only layouts without addresses (Layout::addressable), so title-written textures in these layouts are uploaded. Uploads still go only to textures without render-target, depth or unordered use (texture::title_written), so host-rendered targets aren't overwritten.

Where it came from

From DexNom's fork, DexNom/VIctory@570a941: render_xor_pattern, render_xor_offset, set_series_s_tiling and their address-library test, adapted to this tree's shared pattern tables. Credited with Co-authored-by: DexNom.

Tested

  • texture::tests::render_xor_layouts_match_the_address_library (DexNom's): an FNV-1a hash of every element's offset in row order. It matches the hashes DexNom computed with AMD's Addr2ComputeSurfaceAddrFromCoord (GFX10.3, PAL c5e8000) for 256×256 and 513×357, both consoles and the three element sizes. Tiling and detiling round-trip.
  • texture::tests::render_xor_blocks_hold_each_element_once (new): each 64 KiB block holds each of its elements exactly once, wherever the block lies. 16-byte elements, mips and arrays stay unaddressable.
  • texture::tests::a_render_target_xor_texture_is_staged (new, victory-gpu): a 256×256 RGBA8 SW_64KB_R_X texture is staged, and the bytes read back from the upload buffer equal victory-formats' detile of its memory. The test builds the Staging directly, so it doesn't go through staging()'s layout check.
  • cargo test -p victory-formats (48 passed, 5 ignored) and cargo test -p victory-hle (all pass).
  • cargo test -p victory-gpu: 230 passed. The 2 known NVIDIA failures are fixed by #2121.
  • cargo clippy --all-targets -- -D warnings on victory-formats, and on victory-gpu with and without --features diagnostics: clean.

Not tested

  • The address-library hashes are DexNom's, so this PR's check of the pipe and packer configuration is only as good as theirs. I didn't run addrlib myself or compare against console memory.
  • Not run with the title, so I haven't checked which of its textures use SW_64KB_R_X with title-written contents.

Changes after review

  • cf9deaa: console::tests::the_console_set_chooses_render_target_xor_addresses sets the Series S, then the Series X, and checks one element whose bit the two consoles route differently (0x800 and 0x2000). That covers the console::set → Layout::new wiring.
**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 22:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/2879) `0xkn0wh3r3:formats/render-target-xor-tiling` → `main` · +381 −3 · 3 files · 4 commits · open ## What Render-target XOR layouts had no address equation (`Layout::addressable()` was false). They could be sized, but not detiled, tiled or addressed. So a title texture in such a layout uploaded nothing from title memory, and `XGTextureAddressComputer` offsets into it came back as 0 with a warning. The XOR modes route pipe and bank address bits by the GPU's configuration, and that differs between the Series X and S. This PR adds: - **XOR tables:** for `SW_64KB_R_X`, the per-coordinate-bit XOR tables of GFX10 `SW_64K_R_X_1xaa_RBPLUS` without a base pipe XOR. They cover 32 pipes and 8 packers (Series X) and 8 pipes and 4 packers (Series S). Bits past a block's side choose the pipe of the neighbouring blocks. - **Scope:** single-mip, single-slice, single-sample 2D layouts with 2-, 4- and 8-byte elements. Other XOR layouts stay unaddressable, as before. - **Console model:** `set_series_s_tiling` picks the tables, and `victory_gpu::console::set` calls it. - **Copies:** detiling and tiling move 16-byte runs, since the low four address bits are column bits in every table. - **Uploads:** texture staging used to refuse every XOR layout. It now refuses only layouts without addresses (`Layout::addressable`), so title-written textures in these layouts are uploaded. Uploads still go only to textures without render-target, depth or unordered use (`texture::title_written`), so host-rendered targets aren't overwritten. ## Where it came from From DexNom's fork, [DexNom/VIctory@570a941](https://github.com/DexNom/VIctory/commit/570a941e9b4e945121c26eb30dfc10c126845207): `render_xor_pattern`, `render_xor_offset`, `set_series_s_tiling` and their address-library test, adapted to this tree's shared pattern tables. Credited with `Co-authored-by: DexNom`. ## Tested - `texture::tests::render_xor_layouts_match_the_address_library` (DexNom's): an FNV-1a hash of every element's offset in row order. It matches the hashes DexNom computed with AMD's `Addr2ComputeSurfaceAddrFromCoord` (GFX10.3, PAL c5e8000) for 256×256 and 513×357, both consoles and the three element sizes. Tiling and detiling round-trip. - `texture::tests::render_xor_blocks_hold_each_element_once` (new): each 64 KiB block holds each of its elements exactly once, wherever the block lies. 16-byte elements, mips and arrays stay unaddressable. - `texture::tests::a_render_target_xor_texture_is_staged` (new, victory-gpu): a 256×256 RGBA8 `SW_64KB_R_X` texture is staged, and the bytes read back from the upload buffer equal `victory-formats`' detile of its memory. The test builds the `Staging` directly, so it doesn't go through `staging()`'s layout check. - `cargo test -p victory-formats` (48 passed, 5 ignored) and `cargo test -p victory-hle` (all pass). - `cargo test -p victory-gpu`: 230 passed. The 2 known NVIDIA failures are fixed by #2121. - `cargo clippy --all-targets -- -D warnings` on victory-formats, and on victory-gpu with and without `--features diagnostics`: clean. ## Not tested - The address-library hashes are DexNom's, so this PR's check of the pipe and packer configuration is only as good as theirs. I didn't run addrlib myself or compare against console memory. - Not run with the title, so I haven't checked which of its textures use `SW_64KB_R_X` with title-written contents. ## Changes after review - cf9deaa: `console::tests::the_console_set_chooses_render_target_xor_addresses` sets the Series S, then the Series X, and checks one element whose bit the two consoles route differently (0x800 and 0x2000). That covers the `console::set` → `Layout::new` wiring.
Render-target XOR layouts had no address equation (Layout::addressable
was false): they could be sized, but not detiled, tiled or addressed, so
a title texture in one (and XGTextureAddressComputer's offsets into it)
read nothing. The XOR modes route pipe and bank address bits by the GPU's
configuration, which differs between the Series X and S.

SW_64KB_R_X now has the per-coordinate-bit XOR tables of GFX10
SW_64K_R_X_1xaa_RBPLUS without a base pipe XOR, for 32 pipes and 8
packers (Series X) and 8 pipes and 4 packers (Series S), for single-mip,
single-slice, single-sample 2D layouts of 2-, 4- and 8-byte elements;
other XOR layouts stay unaddressable. The emulated console chooses the
tables (set_series_s_tiling, called by victory_gpu::console::set).
Detiling and tiling move 16-byte runs (the low four address bits are
column bits in every table).

Tests: render_xor_layouts_match_the_address_library (FNV-1a of every
element's offset, against AMD's Addr2ComputeSurfaceAddrFromCoord as
DexNom computed them, for 256x256 and 513x357, both consoles, three
element sizes; tile and detile round-trip), and
render_xor_blocks_hold_each_element_once (each 64 KiB block holds each
of its elements once, wherever it lies; other layouts stay
unaddressable).

From DexNom/VIctory@570a941e9b
(render_xor_pattern, render_xor_offset, set_series_s_tiling and the
address-library test), adapted to this tree's shared pattern tables.

Co-authored-by: DexNom <[email protected]>
Texture staging refused every XOR layout, so with render-target XOR
addresses (SW_64KB_R_X of one 2D slice and mip) a title-written texture
in one still uploaded nothing. It now refuses only layouts without
addresses (Layout::addressable); uploads still go only to textures the
host does not render to or write (texture::title_written).

Test: a_render_target_xor_texture_is_staged (256x256 RGBA8 SW_64KB_R_X:
the bytes read back from the upload buffer equal the formats crate's
detile of its memory).
Review: the formats tests pick the console's tables directly
(new_for_model); nothing checked that console::set reaches the layouts
Layout::new makes. the_console_set_chooses_render_target_xor_addresses
sets the Series S, then the Series X, and checks the address of one
element whose bit the two route differently (0x800 and 0x2000).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:16:33 +00:00
The render-target XOR tables give addresses without a base pipe/bank
XOR. In an XOR layout the GPU takes one from base-address bits 8-15 of
the texture's descriptor (Mesa ORs a surface's tile_swizzle into them:
va |= tile_swizzle << 8), so a texture whose memory is off a 64 KiB
boundary would have been detiled with the wrong pipes and banks and
uploaded scrambled. Such a texture is now refused with a warning, as
every XOR texture was before.

Test: a_base_pipe_bank_xor_is_refused.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 23:04 UTC · original

Reviewed and verified f3430262 on Windows 11 against main (842b0cb):

  • render_xor_pattern(series_s, element_bytes) cleanly covers SW_64KB_R_X (2/4/8 B/px, 2D, single mip/slice/sample, block == 1) for both Series X (32 pipes / 8 packers) and Series S (8 pipes / 4 packers), with console::set wiring SERIES_S_TILING cleanly.
  • Verified addressing bounds: x & (ox.len() - 1) / y & (oy.len() - 1) handle high pipe-XOR bits past a 64 KiB tile, 16-byte copy chunks clamp properly (16.min(bytes - at)) for odd/small extents, and unsupported shapes (16 B/px, multi-mip, array/3D, SW_64KB_D_X) stay !addressable().
  • Local checks: victory-formats 48/48 passed (5 ignored; including render_xor_layouts_match_the_address_library and render_xor_blocks_hold_each_element_once), victory-gpu --lib console 4/4 passed, cargo clippy --locked -p victory-formats -p victory-gpu --all-targets -- -D warnings 0 warnings, cargo xtask policy (191 files ok).

Looks solid and ready to merge.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 23:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/2879#issuecomment-7177124703) Reviewed and verified `f3430262` on Windows 11 against `main` (`842b0cb`): - `render_xor_pattern(series_s, element_bytes)` cleanly covers `SW_64KB_R_X` (`2/4/8` B/px, 2D, single mip/slice/sample, `block == 1`) for both Series X (32 pipes / 8 packers) and Series S (8 pipes / 4 packers), with `console::set` wiring `SERIES_S_TILING` cleanly. - Verified addressing bounds: `x & (ox.len() - 1)` / `y & (oy.len() - 1)` handle high pipe-XOR bits past a 64 KiB tile, 16-byte copy chunks clamp properly (`16.min(bytes - at)`) for odd/small extents, and unsupported shapes (`16 B/px`, multi-mip, array/3D, `SW_64KB_D_X`) stay `!addressable()`. - Local checks: `victory-formats` 48/48 passed (5 ignored; including `render_xor_layouts_match_the_address_library` and `render_xor_blocks_hold_each_element_once`), `victory-gpu --lib console` 4/4 passed, `cargo clippy --locked -p victory-formats -p victory-gpu --all-targets -- -D warnings` 0 warnings, `cargo xtask policy` (`191 files ok`). Looks solid and ready to merge.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 04:26 UTC · original · edited 2026-11-26 05:31 UTC

Automated triage for the maintainers.

Needs work. Thanks for the reply. 8016b43 takes care of one point: staging() in victory-gpu/src/texture.rs now refuses an XOR-layout texture that is not on a 64 KiB boundary (pipe_bank_xor), so a base pipe/bank XOR no longer gives a scrambled upload. That reads correctly.

The main point is still open. The render_xor_pattern tables in victory-formats/src/texture.rs depend on the 32-pipe/8-packer (Series X) and 8-pipe/4-packer (Series S) counts, and nothing public gives those counts. The tests only check that the tables match those same inputs. Your reply also says the tables come from DexNom's commit 570a941, which is part of the open PRs #2643 and #2759. If the tables are taken from there, please credit that author in the commit, or let that work land through its own PR.

What would change the verdict: a public source for the pipe and packer counts of each console, or one title texture in this layout detiling correctly on main plus this PR, from anyone who can run it.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 04:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2879#issuecomment-7182598214) · edited 2026-11-26 05:31 UTC <!-- victory-triage v1 head=8016b4355cf07eb14439ab97781da9c3498fa112 verdict=needs-work at=2026-11-26T05:31:12Z --> Automated triage for the maintainers. **Needs work.** Thanks for the reply. `8016b43` takes care of one point: `staging()` in `victory-gpu/src/texture.rs` now refuses an XOR-layout texture that is not on a 64 KiB boundary (`pipe_bank_xor`), so a base pipe/bank XOR no longer gives a scrambled upload. That reads correctly. The main point is still open. The `render_xor_pattern` tables in `victory-formats/src/texture.rs` depend on the 32-pipe/8-packer (Series X) and 8-pipe/4-packer (Series S) counts, and nothing public gives those counts. The tests only check that the tables match those same inputs. Your reply also says the tables come from DexNom's commit `570a941`, which is part of the open PRs #2643 and #2759. If the tables are taken from there, please credit that author in the commit, or let that work land through its own PR. What would change the verdict: a public source for the pipe and packer counts of each console, or one title texture in this layout detiling correctly on `main` plus this PR, from anyone who can run it. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-26 04:30 UTC · original

Thanks for the review. Taking the three points in order:

Non-zero base pipe/bank XOR: handled in 8016b43, which refuses it. In an XOR layout the GPU takes the base pipe/bank XOR from base-address bits 8–15 of the descriptor; Mesa ORs tile_swizzle << 8 into the address. This tree has no other place a base XOR could come from, because texture_layout already refuses any layout word above 0x1ff. So staging now refuses an XOR-layout texture whose memory is not on a 64 KiB boundary, with the same warning as before. A texture whose layout has one is no longer uploaded scrambled. Test: a_base_pipe_bank_xor_is_refused.

Address-library inputs: I can't give a public source for the consoles' GB_ADDR_CONFIG. The tables are DexNom's. In 570a941 they describe them as addrlib's GFX10_SW_64K_R_X_1xaa_RBPLUS with no base pipe XOR, computed with Addr2ComputeSurfaceAddrFromCoord (PAL c5e8000) for 32 pipes / 8 packers (Series X) and 8 pipes / 4 packers (Series S). No register values or source for those counts are given. The test hashes therefore check consistency with those inputs. They don't tie the inputs to a documented register value. If that's not enough to merge, I understand keeping this open until someone can confirm the counts.

A title texture detiling correctly: I can't produce that here. I don't have a legitimately obtained title to run.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-26 04:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2879#issuecomment-7182661375) Thanks for the review. Taking the three points in order: **Non-zero base pipe/bank XOR:** handled in 8016b43, which refuses it. In an XOR layout the GPU takes the base pipe/bank XOR from base-address bits 8–15 of the descriptor; Mesa ORs `tile_swizzle << 8` into the address. This tree has no other place a base XOR could come from, because `texture_layout` already refuses any `layout` word above `0x1ff`. So staging now refuses an XOR-layout texture whose memory is not on a 64 KiB boundary, with the same warning as before. A texture whose layout has one is no longer uploaded scrambled. Test: `a_base_pipe_bank_xor_is_refused`. **Address-library inputs:** I can't give a public source for the consoles' `GB_ADDR_CONFIG`. The tables are DexNom's. In 570a941 they describe them as addrlib's `GFX10_SW_64K_R_X_1xaa_RBPLUS` with no base pipe XOR, computed with `Addr2ComputeSurfaceAddrFromCoord` (PAL c5e8000) for 32 pipes / 8 packers (Series X) and 8 pipes / 4 packers (Series S). No register values or source for those counts are given. The test hashes therefore check consistency with those inputs. They don't tie the inputs to a documented register value. If that's not enough to merge, I understand keeping this open until someone can confirm the counts. **A title texture detiling correctly:** I can't produce that here. I don't have a legitimately obtained title to run.
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/2879/head:github-bot/gh-2879'
git switch 'github-bot/gh-2879'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2879'
git switch 'github-bot/gh-2879'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2879'
git switch 'github-bot/gh-2879'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2879'
git switch 'main'
git merge --squash 'github-bot/gh-2879'
git switch 'main'
git merge --ff-only 'github-bot/gh-2879'
git switch 'main'
git merge 'github-bot/gh-2879'
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!2879
No description provided.