feat(agc): lay out PS4 multisampled color textures in 2D tile modes #23672
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23672"
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 adam25136 on 2026-11-19T12:33:40Z.
What
#22629 lays out a PS4 (GCN) 2D multisampled texture in a depth tile mode and still refuses the color tile modes (
PS4 multisampled textures outside the depth tile modes are not implemented). This lays out a 2D multisampled T# in the two 2D color tile modes, display and thin (tiling indices 10 and 14, the 2D color modesDecodeGcnColorBufferrenders). It is the base PS4 layout:mainreads PS4 Pro (Neo mode) alternate tiling for no PS4 surface, and this PR does not change that (see below). It builds on #22629, which has merged.sampleOffset = sample * (microTileBits / numSamples)inComputeSurfaceAddrFromCoordMacroTiled,r800/egbaddrlib.cpp); a depth surface keeps the samples of an element together, as #22629 has it. InGcnTiling's address equation the sample bits now follow the six pixel bits in a color mode and stay in front of them in a depth mode. (addrlib as read in OpenBSD's import of Mesa 25.0.7, xenocara483f148565a7; GitLab, which #22629 links for Mesa 25.2.8, refuses automated reads.)HwlComputeMacroModeIndexinr800/ciaddrlib.cpp:colorTileSplit = Max(256u, sampleSplit * tileBytes1x),tileSplitC = Min(m_rowSize, tileSplit),tileBytes = Min(tileSplitC, numSamples * tileBytes1x)). addrlib reads the sample split from GB_TILE_MODE and gives no PS4 value; the sample split of 2 for these modes and the 1 KiB row are shadPS4's (GetSampleSplitandDRAM_ROW_SIZEinsrc/video_core/amdgpu/tiling.cppat8e23388af83f, whoseCalculateTileSplitandCalculateMacrotileModecompute the same formula), not a console measurement.GcnTilingonmainalready uses them for single-sample color modes; #22629 made its micro tile include the samples, and this commit takes the micro tile of one sample for the split again, the same number at one sample, so no single-sample layout changes. A micro tile larger than the split is cut into slices a whole surface apart, as for depth: 4 samples of 32 bits (1 KiB) split at 512 bytes into two slices, 8 samples of 8 bits (512 bytes) at 256 bytes into two.main: inFAMOUS Second Son's targets are alternate-tiled. Every CB_COLOR_INFO in its trace that enables a target (32 writes; the other 24 are 0, a disabled target) sets bit 31 (alt_tile_modein shadPS4'sregs_color.hatee0364a9c17a), and its DB_DEPTH_INFO (0x00131241 in all 26 writes, fields as in GPCS4'sGnmRegInfo.h) gives pipe config 18 (P16), 8 banks, bank height 4 and aspect 2: shadPS4's alternate values for the macro tile modes of its two depth targets, whose base values have 16 banks. With shadPS4's alternate tables (GetAltPipeConfig,GetAltBankHeight,GetAltNumBanksandGetAltMacrotileAspectat8e23388af83f: 16 pipes, and for the 512-byte tile's macro tile mode 3 bank height 2, 8 banks and aspect 1), the T# above has 128x128 macro tiles and pads to 1920 rows, the 1664 x 1920 the title programs in CB_COLOR7_SLICE.mainreads neither bit (GcnImageWordsdrops T# word 6, andDecodeGcnColorBufferdoes not read CB_COLOR_INFO bit 31), so every alternate-tiled PS4 surface, single-sample or not, gets the base layout, and with this PR so does inFAMOUS's color texture: its addresses here are not the title's. In addrlib's alternate tiling (AltTilingEnabled()inCiLib::ReadGbTileModeandCiLib::ReadGbMacroTileCfg) only the pipe config, bank height, bank count and macro tile aspect change, so this sample order and split carry over; shadPS4 also takes a bank swizzle from the T# base in that mode (GetBankSwizzleinresource.h). Modeling it is follow-up work, and a fragment entry records the gap.createFilled(MultisampleTarget.cpp), which has no PS4 tile modes; inFAMOUS stops there next.PS4 (GCN) multisampled color textures, and a Functional entry,PS4 Pro alternate tiling. It also edits #22629's fragment so that it no longer lists color tile modes among what still throws:tools/debt_fold.pycan onlychangean entry already in the debt file, so a direct edit is the only way while #22629's fragment is not folded yet; once it is, I will turn it into a## changein this PR's fragment.Tested
Windows 10 Pro 22H2 (19045), NVIDIA GeForce RTX 5080 (driver 621.14), WinLibs GCC 15.2.0 (r7), CMake 4.3.1, Release. Everything but the inFAMOUS starts, whose stack is described below, ran on this change at
6f33d481e9onmain4fa81a86fb. The head is the same change rebased ontomain20c535f30eafter #22629 merged, and differs from the tested commit only in two lines of the debt fragment; on it,agc_driver_graphics(which holds the tiling tests) passes.RunTextureTilingTests(ctestagc_driver_graphics),gcnMultisampleTilingTestsextended:referenceGcnAddress, now with the color sample order and the color split from one sample's micro tile) places it, and no two samples share an address. That is 30 layouts, next to #22629's 80 depth layouts, which still pass;GcnTilingwith samples in a 1D or PRT color mode, still throw.It passes, and each of 11 deliberate breaks fails it: color samples in the depth order, depth samples in the color order, the color split taken from the micro tile with its samples (as #22629 had it), a sample split of 1 and one of 4 in the code only, a 2 KiB row, the color sample bits one bit lower, the color refusal kept in
describeGcnMultisampledor inGcnTiling, 1D modes accepted, and PRT color modes accepted. It also passes in a build configured with-DANYPS5_ENABLE_SPIRV_TOOLS=ON.tools/select_tests.pyselects for the 5 changed files (ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1), onmainand on this branch: the same 5 fail on both (agc_driver_bda_device,agc_driver_msaa_dcc_unwatchwithDCC unwatch did not preserve unchanged data or refused a real write incorrectly,agc_driver_stencil_plane_memory,agc_driver_store_over_untrackedandagc_storage_write_back_host_retile), and the same 19 are skipped on both.VK_LAYER_KHRONOS_validation1.4.367 (VK_ADD_LAYER_PATH=<the layer's folder> VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer VK_LOADER_LAYERS_DISABLE=~implicit~ ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1), the 56 tests matchingagc_driver_graphics$|gcn|tiling|detile|multisample|msaa,ctest -V, onmainand on this branch: each log has 55Insert instance layer "VK_LAYER_KHRONOS_validation"lines, no "was not found" line and noVUID-message; on both, 52 pass, 3 are skipped andagc_driver_msaa_dcc_unwatchfails as above.main'stools/unwrap_self.pyand converted with--windows --registry --trace-imports, on the local stack it needs to reach this shader:main5d5ae377c0(which has #22517) with #17711, #18184, #21961 and #22629 merged, plus local changes, none of them part of this PR: an answer for libSceDiscMap'sfJgP+wqifno(fpPS4's; #23349 has since merged a different one), the SDWA decode of #23128, the multisample depth import layers that come after #22629, a bypass of the multisample depth write-back, and a change tov_div_scale's destination that the Sea Islands ISA does not support. One traced start each:9dcdb4232c): stops 29.4 s in, in compute shader0x2f2fb2100, atPS4 multisampled textures outside the depth tile modes are not implemented(a local print gave the T#: thin 2D, 4-byte format, 1600x1800, pitch 1664, 2 samples);bff21104d5: the same stack plus this PR's commit and a local print): gets past that, and stops 32.9 s in, in the same shader, atsampling the 1600x1800 multisampled texture 0x3075c0000 of 2 samples, which no draw rendered to and whose tile mode 18 has no modeled multisampled color footprint, is not implemented(createFilledinMultisampleTarget.cpp, which has no PS4 tile modes; tile mode 18 is the driver's thin 2D, tiling index 14). A local print gave the T#'s guest size as 0x1790000 bytes, as above.CB_COLOR7with the same base (0x3075c0000), pitch 1664, 2 samples and 2 fragments, tiling index 14,COMPRESSIONclear and bit 31 (alternate tiling) set, and aCB_COLOR7_SLICEof 1664 x 1920 elements: what the alternate layout pads 1800 rows to, not this PR's 1856 (see What). So this run shows that the title gets past the refusal, not that its texture is now laid out right, andUnblocksis none.python tools/check_conventions.py --base origin/mainwith this title and description: all checks passed.python tools/pr_overlap.py --branch: #22629 has merged. Open #20786 (Gag21, PS4 2D thick tile mode 20) changes the same lines ofGcnTilingandTextureTiling.hpp, as it does #22629's; the two compose, and I will rebase if it lands first. #6280 (draft) and #7085 (Amoenus) changeTextureTiling.hppandTextureTiling.cpptoo, next to lines this changes, and conflict withmain, sopr_overlapcould not compare them.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 wrote the change and its tests from addrlib's formulas, ran the tests and the inFAMOUS starts, and drafted this description; separate review agents checked it.
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T17:37:22Z.
Review: APPROVED
Reviewed — looks good
The review covers all five changed files at head
80ca72d2a56ef4fad4c8edfb5769a59b969892c3; no verified defect blocks merging.What I ran
No build or tests were run during this review. The author reports tests and checks in the PR description; these were not rerun here.
Results
Findings
Blocking
None.
Non-blocking
createFilled; it confirms the new refusal is passed, but does not validate the texture’s addresses. Console behavior and alternate-tiled address correctness remain unverified.Not verified
TextureTiling.hpp,TextureTiling.cpp,tests/TextureTiling.cpp,feat-gcn-msaa-color-layout.md, andfix-gcn-msaa-depth-layout.md.To get this to a good state
Nothing is required. Optional: model PS4 Pro alternate tiling and verify multisampled color addresses against a console or a trusted reference.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T20:23:56Z.
Review: COMMENTED
Reviewed — comments
The color layout change is internally consistent with the stated addrlib formula, but review evidence is incomplete because the core color address and detile consumers were not read.
What I ran
Reviewed head
3656bbf265db9c2d77598a138ca5a5b93e473fc0using the prepared diff andrepo_read.pysource reads. No tests were run.Results
Findings
Blocking
None identified in the code read.
Non-blocking
GcnTiling. Include those callers in a follow-up review to confirm sample addressing and bank/slice handling end to end.Not verified
Read
description.md,commits.md,manifest.json,diff.patch,TextureTiling.cpplines 440–710, andtests/TextureTiling.cpplines 140–180 and 610–715. All four changed files listed inmanifest.jsonare included in the review bundle; the two debt fragments were reviewed in the diff.files.jsonwas unavailable through the reader. Did not read the color-target, detiler, or state callers identified by search, and did not run tests or independently verify the author's reported results.To get this to a good state
Nothing is required. Optional: inspect the downstream consumers of
GcnTilingfor the new color sample equation.