fix(agc): rotate the bank of PS4 array layers like addrlib #12998
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12998"
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?
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-29T20:03:01Z.
What
The layers of a PS4 macro-tiled array were placed by a plain offset, with the same bank bits in every layer. For the non-PRT modes the AMD address library also rotates the bank by
(banks / 2 - 1)times the layer index, and applies it to the bank as one XOR of the sum with the bank swizzle (egbaddrlib.cppL3002-L3049). That is the XOR form shadPS4 uses; fpPS4 adds the rotation after the XOR instead.This adds
GcnLayerBankXor, the rotation of one layer as a constant in the bank bits of the address (shift taken from the tile geometry, bit 11 for the 8-pipe modes modelled here), and the detiler passes it with its existing bank/pipe XOR, so the shader is unchanged. The product(banks / 2 - 1) * layeris taken modulo the bank count; it is not a bitwise function of the layer index, so it cannot be folded into the swizzle equation. It applies to the non-PRT modes (Display2D,Thin2D,Depth2D*) from layer 1 and only to mips that are macro-tiled; PRT modes and the micro-tiled small mips are unchanged. The bank swizzle of the surface is taken as 0, as before.Only surfaces with a
gcnPitch(PS4 GCN) are affected; PS5 modes are not. A PS4 color target view of an array slice is rejected onmain(DecodeGcnColorBufferthrows for a slice other than 0), so no color-target path addresses PS4 array layers yet; a change that allows such a view with a plain slice offset would need this rotation as well. The rotation rests on the address library and the two emulators; it is not measured on a console, and no title that reaches it has been run.Commits: the test commit comes first and fails on
mainfor the non-PRT modes from layer 1; the fix commit makes it pass.Overlap
Open PRs that change
TextureTiling.hpp,TextureTiling.cpp,TextureDetiler.cpp,TextureDetile.compor the two teststests/TextureTiling.cppandtests/execution/GcnDetile.cpp(file sets fromgit diff --name-onlyagainst each PR head's merge base, all 1470 open pull requests as of 2026-10-29 19:20, mainbb04a4f1ea): 26 touch these files or are ours.git merge-treeof this branch against each of them gives the same result with and without these commits, so none of them gets a new conflict from this PR. #9674 (tile mode 19) edits the same files and merges without a text conflict; a trial merge of both builds, and the tests below pass on it. The 16 pull requests opened since then (#12979 to #12994, checked 2026-10-29 20:25 against main58b2753d74, which did not change these files) touch none of them. No open PR adds a bank rotation for array layers. Re-checked when opening against the 14 pull requests opened since 19:20 and main420b6a064e(which has not changed these files): none of them touches them.Tested
Windows 10 Pro 10.0.19045.
agc_driver_gcn_detile_tests(GPU) andagc_driver_graphics_tests(the CPU tiling tests among them), with 1 and 2 mip levels and array layers 0 to 5:a12f933bb8alone, on top of mainbb04a4f1ea: the GPU test fails on an NVIDIA GeForce RTX 4080 SUPER and on an AMD Radeon RX 6400 at array layer 1 (detiled as 204, expected 0), and the tiling test fails withis at 524288, addrlib places it at 538624.c7a3fff544: all three pass, the GPU test on both GPUs (RTX 4080 SUPER, driver package 32.0.16.1074; RX 6400, 32.0.21033.3005, as reported by Windows).356cb639ef): the same three runs pass.tools/check_conventions.py --base upstream/mainpasses. No title was run.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T21:57:25Z.
Review: APPROVED
Reviewed — looks good
The array-layer bank rotation matches the cited address-library rule and is covered by tiling and GPU detile tests; I found no blocking issue in the exact head reviewed.
What I ran
c7a3fff5445fae8de8497a87fdabc25c30b0677f.upstream/mainatd820fef1827f27247cd28da7b4eec7891904bae5; current-main merge preview was clean (3056b89e4d4bd99822a2c30c5dd18cd415163ca6). The changed tiling, detiler, shader, and test paths have not changed on currentmainsince the PR's reportedbb04a4f1eacomparison base.Results
3056b89e4d4bd99822a2c30c5dd18cd415163ca6.Unedited local command output
python tools/check_conventions.py --base upstream/main --head refs/review/pr-12998-headgit merge-tree --write-tree upstream/main refs/review/pr-12998-headgit diff --check upstream/main...refs/review/pr-12998-headexited 0 with no output. The current-main changed-path comparison also produced no output.Sources
393bf0d1467c4a7e208fd0d36b05b99438926079Not verified