feat(agc): render into XOR-swizzled color targets with a pipe/bank XOR, and into SW_4KB_S_X/D_X #1735
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1735"
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 TheAggie on 2026-10-08T17:52:13Z.
What
This is the color-target half of #1734, which it builds on. Its first commit is that PR's and drops out once it merges. It has two parts.
Pipe/bank XOR. Mesa ORs the pipe/bank XOR into
CB_COLOR_BASE(cb_color_base |= tile_swizzleinac_set_mutable_cb_surface_fields,src/amd/common/ac_descriptors.c).DecodeColorBufferpassed the unaligned address toGuestMemory::CheckRangewith the block alignment, which threwnull or misaligned address. Under RADV on the PS5, ccleste (PPSA59322) dropped its off-screen render passes this way.DecodeColorBuffersplits the base into the block-alignedaddress/surfaceAddressandColorTarget::pipeBankXor. The new field is placed at the end of the struct, because tests initialize it positionally.ColorTargetLayouttakes the XOR and applies it to the in-block offset, as addrlib does, for the CPU paths inColorTargetTransfer. It rejects an XOR for non-XOR modes, values that are not whole 256-byte units, and values beyond the block.SW_64KB_R_Xdetile and retile dispatches inDraw.cpppass it to the detiler.SurfaceForTargetcopies it into the resident surface. A texture that samples the target then finds the same image throughSurfaceKey, and the draw key includes it.SW_4KB_S_XandSW_4KB_D_X.DecodeColorTileModeaccepted only linear,SW_4KB_S,SW_64KB_SandSW_64KB_R_X. RADV renders small surfaces inSW_4KB_D_X. ccleste's three such draws failed earlier, at the FMASK check (ATTRIB30x0da58000:COLOR_SW_MODE0x16,FMASK_SW_MODE0x14).ColorTileMode::S4KBX/D4KBX, mapping to the texture modes the detiler already handles. Resident targets take the existing storage-image path.ColorTargetLayoutbuilds their block tables from the samekTextureSwizzleEquationsentries asSW_64KB_R_X. Its 4 KiB alignment is used forCheckRange. The XOR split uses the 4 KiB mask.FMASK_SW_MODE == COLOR_SW_MODE & ~3. Mesa sets this for every color surface without FMASK (ac_surface.c: "CMASK fast clear uses these even if FMASK isn't allocated. FMASK only supports the Z swizzle modes, whose numbers are multiples of 4"). The existing 0 and 0x18 stay accepted; 0x18 is what a logged AGC descriptor uses withSW_4KB_S.Tests:
agc_driver_graphics(ColorTargetLayout):SW_64KB_R_Xoffsets equal the unswizzled ones XORed inside each block, across two blocks.ATTRIB3, itsS_Xtwin and aD_Xtarget without FMASK decode. An FMASK mode that matches neither rule is rejected.agc_driver_graphics(ColorPipeBankXorTests):DecodeStatesplitsSW_64KB_R_Xbases with XOR 0, 0x5600 and 0xff00, andSW_4KB_D_Xbases with 0, 0xa00 and 0xf00.There is no GPU draw test of the XOR'd color paths. The detile shader they use is covered by the GPU test in #1734.
Tested
Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, NVIDIA GeForce RTX 5070 Ti.
CTestTestfile.cmakecommands because antivirus blocksctest.exeon this machine.RADV_DEBUG=nonggcset.Not tested on AMD, Intel or Linux.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-08T18:59:07Z.
Linux run, since the description lists AMD and Linux as not tested: Ubuntu 24.04.5 (kernel 6.8), GCC 13.3, Release, AMD Radeon RX 7600 (RADV NAVI33, Mesa 25.2.8). This PR's head
c2b22c44, merged onto main6b56175a.Full ctest: 479 of 480 pass. The one failure is
agc_driver_image_pipe_bank_xor, which comes from #1734's commit. I explained the cause and a one-line fix (OOB_SELECT3 in the test's buffer descriptor) on #1734. With that change applied to this branch's version of the test, it passes on the RX 7600 and on llvmpipe.agc_driver_graphics, which has this PR'sColorTargetLayoutandColorPipeBankXorTestscases, passes.Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-08T19:43:19Z.
Rebased onto the updated #1734, whose test had built its buffer V#s with
OOB_SELECT0 and stride 0 (out of bounds on GFX10, which AnyPS5 honours since #639) and caused the red Linux CI here. The full suite (478 tests) passes on currentmain.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T05:58:09Z.
Review: CHANGES_REQUESTED
Reviewed on top of #1734; the delta looks right (XOR split in
DecodeColorBuffer,ColorTargetLayoutXOR validation, detile/retile only on theRenderTargetGPU path, FMASK rule). Build andagc_driver_graphicspass on my side.maininGraphics/include/State.hpp(ColorTarget, newpipeBankXorfield next to a recent change). It can't land before #1734.main(the first commit drops out), rerunagc_driver_graphicsand the new XOR tests, and I'll look at it again.Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T06:46:26Z.
@adriadam10 #1734 is merged, so I rebased this onto
mainecd3dbadb. #1734's commit dropped out, leaving this PR's two commits (the SW_64KB_R_X pipe/bank XOR split and SW_4KB_S_X/D_X). One conflict on the way:DecodeColorTileMode, wheremainhad added 1D color targets. The resolution keepsmain's rule that 1D targets can't use a standard swizzle, alongside the new modes and the FMASK rule.Windows 11 (MinGW-w64 GCC 15.2, NVIDIA GeForce RTX 5070 Ti):
agc_driver_graphics(which holds the color-target layout and XOR decode tests) passes. Full suite: 512 of 515 pass, 1 skipped. The two failures,agc_driver_prepared_shaders_debug_failureandagc_driver_f32_arithmetic_nan, fail the same way on cleanmainecd3dbadbon this machine.tools/check_conventions.pypasses.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T08:37:42Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Graphics/include/State.hppL58Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T08:49:40Z.
Review: APPROVED
Checked the XOR split in
DecodeColorBuffer, theColorTargetLayoutvalidation, the detile/retile dispatches (onlyRenderTargetgoes through the GPU tiling path, so the fixedkR64KBXis right) and the FMASK rule. Build andagc_driver_graphicspass on Linux (RADV host) on top of currentmain; the new tests fail to build without the change. Merging.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-11T11:05:09Z.
Independent AMD-source validation: XOR input/test coverage discrepancy (main74981fa, 2026-10-11)
While validating the separate missing D64KBX mode in #2970, I compared unmodified main74981fabe1c0fc56b561914beb027ddc9b07d358 ColorTargetLayout against compiled, unmodified AMD PAL addrlib c5e80007. This exposes a source/model mismatch for some XOR inputs accepted by this PR's tests; it is not a measured PS5 defect or a claim that valid, driver-generated XOR values are broken.
Windows 11, Winlibs GCC15.2.0r7, standalone production-source CPU probe. Addrlib configuration is synthetic GFX10.1 non-RB+, family0x8f/revision0x82, GB_ADDR_CONFIG0x00100044,16pipes/256-byte interleave, matching the table model under investigation, not measured console registers. Directly linked main's ColorTargetLayout.cpp/header (Git blobs b4deb5dd/8c492a1a); no D64 changes in this control.
Minimal independent reproduction: SW_64KB_R_X,2D,color/texture,noMetadata,1x1,1slice/1mip/1sample/1fragment; bpp=8/16/32/64/128. Compare ColorTargetLayout(1,1,RenderTarget,bpp/8,code<<8).Offset(0,0) with Addr2ComputeSurfaceAddrFromCoord using the same geometry and pipeBankXor=code. Test codes0,0x0f,0x10,0x20,0x30,0x40,0x56,0xcf,0xff. 45 comparisons,25 discrepancies, identical across5 runs.
These results hold at the origin for all five element sizes. The other tested codes match. AMD HwlComputeSurfaceAddrFromCoordTiled masks the code with pipeMask|bankMask before shifting8bits. Here pipeMask=0x0f; ColumnBits=2; two bank bits start at bit6, yielding code mask0xcf / byte mask0xcf00. AnyPS5 applies every accepted256-byte-aligned bit. Existing fixtures0x5600/0x3200 therefore assert behavior that differs from this independent source configuration; roundtrip or CPU/GPU checks that share the same XOR assumptions cannot settle that semantics question.
I also checked the cited Mesa bridge at pinned 418c4cfa ac_surface.c: Addr2ComputePipeBankXor output becomes surf->tile_swizzle; ac_descriptors.c ORs that into the256-byte color base for GFX9+. AMD's generator leaves the two column bits unset in this configuration. This supports using generated legal codes in the tests; it does not establish how PS5 should handle arbitrary reserved raw CB_BASE bits. Masking, rejecting, or preserving those bits needs that distinction resolved before changing DecodeColorBuffer generally.
Limits: no console measurement; no title observed invoking those non-pipe/bank bits. A broader R_X coordinate sweep also diverges beyond these origin differences and remains under investigation; I am not attributing its aggregate failures solely to this mask. Suggested follow-up: add independent source-expected offsets/legal generated values, then separately settle unsupported raw bits and any coordinate-table differences. Keeping this on the existing PR to avoid a premature duplicate issue. No PR created; all experimental work remains fork-only. AI-assisted validation/report: Codex.
Broader legal-value discrepancy isolated and tracked separately (2026-10-11)
The broader sweep is now resolved into a different, confirmed source-model gap, tracked in new issue3475. With only legal codes0/0x0f/0x40/0xcf, unchanged main gives 95,156 differences/536,940 comparisons,5/5 repeatable, confined to64/128bpp R_X surfaces spanning blocks. For example33x65/64bpp/(0,64)/zero XOR: AnyPS5=0x10000,AMD=0x10800. ColorTargetLayout drops higher-coordinate XOR contributions by evaluating per-block coordinates. Changing only the external R_X probe's production offset path to use full x/y in the existing equation, with no XOR masking/table/geometry changes, gives zero differences across the same sweep5/5. The new issue includes the128bpp example and suggested correction. This separates the coordinate defect from the arbitrary-column-bit question above; no console/title/render claim. It is not a runtime-tested or committed correction yet.
The separate D64 mapping proposal now uses legal test values and ten fixed independent AMD-source offsets; fork3034273, no PR. Current-base CPU/GPU D64 groups pass5repeats before and after the full suite. Full833:822 pass,5 skip,6 failures (Windows unwind and flat_apertures0/2/3/4/5); those failures remain reported on their existing issues. AI-assisted validation/report: Codex.