fix(agc): lay out 3D SW_64KB_D_X textures as thick volumes #1609
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1609"
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 kr4y4 on 2026-10-08T14:24:14Z.
What
DescribeSurfacetreats 3DSW_64KB_D_Xvolumes likeZ_XandR_X, as a stack of thin 2D slices. In GFX10 a display swizzle on a 3D resource is thick. addrlib'sHwlIsThickisIsTex3d(resourceType) && (isStd || isDisp)(gfx10addrlib.hL229-234), and theADDR_SW_64KB_D_Xrow hasisDispset (gfx10addrlib.cppL85). OnlyZ_XandR_Xvolumes are thin.addrlib addresses these volumes with
GFX10_SW_64K_D3_X_PATINFO(gfx10SwizzlePattern.h). With the thin layout, every element after the first block row lands elsewhere, and the surface size is wrong:SW_64KB_D_X3DFor example, in a 32 bpp 1×1×5 volume, element (0,0,1) is at 0x20 in addrlib and 0x10800 on main. The guest allocation is addrlib's size, so the thin layout also reads past it.
D_Xvolumes now take the thick path, likeS_X:ThickBlockExtentgives them the 64 KiB thick block extents.TextureDetileruses a new equation key 0x11a.TextureSwizzleEquations.hppgets five rows for that key (1 to 16 bytes per element). They were generated from addrlib's 16-pipeGFX10_SW_64K_D3_Xpattern rows, the same way as the existing 0x119 rows.Some of the pipe bits use x/y bits above the block, which the detiler shader already supports because it passes full coordinates, as for 0x119.
Tests:
RunTextureTilingTestspins addrlib's guest size, first tail level and sample element addresses for 32 bpp 64×64×16 (1 level), 8 bpp 100×60×70 (7 levels) and 128 bpp 9×5×3 (4 levels).agc_driver_image_xor_swizzle_volumenow also samples a thickD_Xvolume through the detiler on the GPU.How it was found: AnyPS5's
TextureTiling.cppand equation tables were compared against Mesa's addrlib, compiled unmodified and called throughAddr2ComputeSurfaceInfo/Addr2ComputeSurfaceAddrFromCoord. The config was gfx1013, revision 0x82, GB_ADDR_CONFIG 0x00100044 (16 pipes, non-RB+). Every 2D equation matched bit for bit. For volumes, main has about 4.2 million mismatchingSW_64KB_D_Xaddresses at 4 and at 8 bytes per element. That comparison covers 7616 3D configurations, compared wherever both addrlib and AnyPS5 accept them: the swizzle modes AnyPS5 implements, at 8–128 bpp, 15 sizes, 1, 2, 4 or a full chain of mips, and depths of 1, 5, 16 and 33. With this change, the linear-volume rounding fix from #1602 and the Z_X tail limits from #1590 applied together, it reports 0 mismatches in 143,437,500 addresses.Tested
Windows 11 (26200), WinLibs GCC 15.2.0 r7, CI configure flags, main at
fe9beae0:agc_driver_graphicsandagc_driver_image_xor_swizzle_volumepass with--repeat until-fail:3on an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU.D_Xput back on the thin path,agc_driver_graphicsfails withSW_64KB_D_X 32 bpp 64x64x16, 1 level: guest size differs from addrlib.Checklist
main; no other open PR implements the same thing🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T04:22:30Z.
Linux results, since this was tested on Windows only. Everything passes here, including
agc_driver_graphicsandagc_driver_image_xor_swizzle_volume.Nobara 44 (Linux 7.2), GCC 16.2.1, Release,
BUILD_TESTING=ON. PR head merged ontomain29e533ac.ctest -R agc_driver -j1CPU tests (
-E agc_driver): 279 / 280. The one failure isguest_dynamic_loader(subprocess aborted), which fails the same way onmain29e533ac.