feat(agc): detile XOR-swizzled textures whose base carries a pipe/bank XOR #1734
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1734"
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:03Z.
What
On GFX10 the XOR swizzle modes (
SW_4KB_*_X,SW_64KB_*_X,SW_64KB_*_T) add a per-surface pipe/bank XOR to the offset inside each block. AMD addrlib,Gfx10Lib::ComputeSurfaceAddrFromCoordMacroTiled:Every mip and slice uses the same
pipeBankXor, masked to the block. Mesa stores it in the low bits of the descriptor base:desc[0] |= swizzleinac_set_mutable_tex_desc_fields, andcb_color_base |= tile_swizzleinac_set_mutable_cb_surface_fields(src/amd/common/ac_descriptors.c).DecodeTextureResourcethrewcombines an XOR swizzle with a pipe/bank XOR base which is not implementedfor those descriptors. Under RADV on the PS5, ccleste (PPSA59322) dropped one such draw every frame: the blit of its rendered image to the display buffer.DecodeTextureResourcesplits the base into the block-alignedbaseAddressandpipeBankXor, which is the address bits below the block size. Nothing that addresses guest memory moves.null base address.DetileWindow::pipeBankXorreachesTextureDetile.compas a new push constant. The equation family XORs it into the block offset, the same place as addrlib, tail mips included. All eight texture detile and retile dispatches inTexture.cpppass it.SurfaceKeyfolds the XOR into its address word, which is zero there for an aligned base. The view check inTexture.cppcompares it too, so two descriptors that differ only in their XOR do not share an image.agc_driver_graphics(GuestTextureResource):SW_64KB_R_X,SW_4KB_D_XandSW_64KB_D_Tbases split into the expected base and XOR.agc_driver_graphics(TextureDetiler): a dispatch without a window pushes 0, and the window's XOR reaches the push constant.agc_driver_image_pipe_bank_xor:image_loadwith the descriptor base raised by that value.SW_4KB_D_Xwith XOR 0 and 0xa00,SW_64KB_S_Xwith 0x5600,SW_64KB_R_Xwith 0xf100.Color targets with such a base still throw
null or misaligned address; #1735 follows on top of this one.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:05Z.
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
512f8c0e, merged onto main6b56175a.Full ctest: 479 of 480 pass. The new
agc_driver_image_pipe_bank_xorfails at its first case, the one without an XOR:It fails the same way on llvmpipe (
MESA_VK_DEVICE_SELECT=10005:0!), so it isn't specific to AMD. -255/255 is the-1.0fthatRunfillsOutputwith, so the shader's store never landed.The cause seems to be the test's buffer descriptors.
BufferDescriptorsets word 3 to0x01016fac, which meansOUT_OF_BOUNDS_SELECT0 (structured: index and offset are both checked) with a stride of 0. With that, every access counts as out of bounds.ImageXorSwizzleVolume.cpp, which uses the same shader, uses0x31016fac(OOB_SELECT3, raw).ImageSint8.cpppicksstride == 0u ? 0x31016facu : 0x01016facu.With only that value changed to
0x31016facu, all four cases pass on the RX 7600 and on llvmpipe, including the XOR 0xa00, 0x5600 and 0xf100 ones. So the detile change itself checks out here.I haven't worked out why the original passes on your Windows machine. If it helps, I can run it on Windows with an RTX 4080.
All other tests pass, including
agc_driver_graphicswith the newGuestTextureResourceandTextureDetilercases.Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-08T19:43:18Z.
The red Linux CI here was my test's fault: its buffer V#s used
OOB_SELECT0 (structured with offset) with stride 0, so every access is out of bounds on GFX10 ((index >= NUM_RECORDS) || (offset >= STRIDE), per Mesa'sac_descriptors.c), and since #639 AnyPS5 honours that. The test now builds them as raw buffers (OOB_SELECT3, as Mesa does). Rebased onto currentmain; the full suite (478 tests) passes, and the test still fails with the detile shader's pipe/bank XOR removed.Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-08T20:13:14Z.
Confirmed on the RX 7600 (RADV, Mesa 25.2.8) with
8eb2c3d5merged ontomain4b6ab6bb: the full suite passes (486/486), includingagc_driver_image_pipe_bank_xor, which also passes on llvmpipe. #1735 (fc103d99) passes 486/486 on the same setup.Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-08T20:25:43Z.
Thanks for testing on the RX 7600 and for pinning down the
OOB_SELECTcause before I got there. That's the fix I pushed, and good to have it confirmed on AMD and llvmpipe.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:00:41Z.
Checked: build and
agc_driver_graphics+agc_driver_image_pipe_bank_xoron RADV (Rembrandt), plus theOOB_SELECT3 fix; the new tests don't compile without the change. Matches the AMD/llvmpipe full-suite run from @johnmaia and the Windows RTX run in the description. Merging; #1735 can rebase on top.