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

Open
0xkn0wh3r3 wants to merge 4 commits from upstream-pr/2879 into main
0xkn0wh3r3 commented 2026-11-25 22:58:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T22:58:07Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5500619892 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2879). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T22:58:07Z. --- ## 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.
fuzeofficlal commented 2026-11-25 23:06:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T23:04:55Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177124703 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2879#issuecomment-7177124703). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T23:04:55Z. --- 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.
AwsAli05 commented 2026-11-25 23:06:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AwsAli05 on 2026-11-25T23:06:48Z.

Review: COMMENTED


All 18 victory-formats texture tests passed on Windows at f343026. That includes the independent address-library hashes for both models and the round trip with a padded linear row pitch.

The tests construct layouts through new_for_model, while the title uses console::set followed by Layout::new. A profile-level test that checks one known XOR address after Series S selection would cover that wiring too. The format tests establish the single-slice, single-mip layouts described in the PR.

AI-assisted review and test.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066206451 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2879#pullrequestreview-6066206451). Originally posted by [AwsAli05](https://github.com/AwsAli05) on 2026-11-25T23:06:48Z. **Review:** COMMENTED --- All 18 `victory-formats` texture tests passed on Windows at `f343026`. That includes the independent address-library hashes for both models and the round trip with a padded linear row pitch. The tests construct layouts through `new_for_model`, while the title uses `console::set` followed by `Layout::new`. A profile-level test that checks one known XOR address after Series S selection would cover that wiring too. The format tests establish the single-slice, single-mip layouts described in the PR. AI-assisted review and test.
kotekompotek commented 2026-11-25 23:37:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T23:37:07Z.

Review: COMMENTED


Scoped review: the per-console XOR tables for SW_64K_R_X can't be verified bit-by-bit in review, but the structure is right — element-size-keyed OnceLock patterns, Series S toggle set once with the emulated console before any texture, and the pipe-vs-bank routing split documented per entry. Wrong values would show immediately as RT corruption on S-profile targets, so the value is in having the table at all. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066497861 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2879#pullrequestreview-6066497861). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T23:37:07Z. **Review:** COMMENTED --- Scoped review: the per-console XOR tables for SW_64K_R_X can't be verified bit-by-bit in review, but the structure is right — element-size-keyed OnceLock patterns, Series S toggle set once with the emulated console before any texture, and the pipe-vs-bank routing split documented per entry. Wrong values would show immediately as RT corruption on S-profile targets, so the value is in having the table at all. LGTM.
Marvisak commented 2026-11-26 05:04:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T04:26:31Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7182598214 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2879#issuecomment-7182598214). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T04:26:31Z. --- <!-- 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)_
0xkn0wh3r3 commented 2026-11-26 05:04:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T04:30:55Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7182661375 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2879#issuecomment-7182661375). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T04:30:55Z. --- 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 commented 2026-11-27 06:44:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-27T06:44:49Z.


On the credit: the commit that adds the tables, f3430262 ("Formats: render-target XOR layouts (SW_64KB_R_X) have addresses on both consoles"), already carries Co-authored-by: DexNom, since they come from DexNom's 570a941. Whether this lands or the same tables come in through #2643 or #2759 is your call. If one of those goes first, I'll drop the table commit here and keep only the staging change.

On the pipe and packer counts: I don't have a public source for them. The 32/8 and 8/4 figures come from DexNom's work, so this needs either a source or a run on a title texture from someone who can do that.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7211807915 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2879#issuecomment-7211807915). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-27T06:44:49Z. --- On the credit: the commit that adds the tables, f3430262 ("Formats: render-target XOR layouts (SW_64KB_R_X) have addresses on both consoles"), already carries `Co-authored-by: DexNom`, since they come from DexNom's 570a941. Whether this lands or the same tables come in through #2643 or #2759 is your call. If one of those goes first, I'll drop the table commit here and keep only the staging change. On the pipe and packer counts: I don't have a public source for them. The 32/8 and 8/4 figures come from DexNom's work, so this needs either a source or a run on a title texture from someone who can do that.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2879:upstream-pr/2879'
git switch 'upstream-pr/2879'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2879'
git switch 'upstream-pr/2879'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2879'
git switch 'upstream-pr/2879'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2879'
git switch 'main'
git merge --squash 'upstream-pr/2879'
git switch 'main'
git merge --ff-only 'upstream-pr/2879'
git switch 'main'
git merge 'upstream-pr/2879'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2877
No description provided.