fix(agc): address texture views that start past the surface's last mip #490
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/490"
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 oneandonlydean on 2026-10-04T07:11:08Z.
Title: fix(agc): address texture views that start past the surface's last mip
What
Replaces #483, as @ThisIsAkill asked (comment): instead of dropping the stores, a view whose
BASE_LEVELis pastMAX_MIPaddresses that level where the hardware puts it, when it lies inside the surface's allocation.PPSA21564 (and PPSA21567, see #483) ends each 1920x1080 RGBA16F bloom downsample chain (
MAX_MIP5) with a compute pass that stores level 6 through a view of levels 6..6, every frame from the PS logo on.DecodeTextureResourcethrows for that view.On GFX10,
MAX_MIPonly decides where the levels are placed: a level's address comes from the levels below it, and a level in the mip tail is a fixed slot of the tail block, counted from the first tail level. A level pastMAX_MIPis addressed the same way. ThisIsAkill's own addrlib check on #483 (Addr2ComputeSurfaceInfo, fiveGB_ADDR_CONFIGsettings) and mine below agree: for this surface, 6 and 7 levels give the same layout and size (0x1640000), the tail starts at level 5 in both, and level 6 is the next slot of that tail block. So the title's stores land in memory the surface owns, and levels 0 to 5 do not move.Two commits:
GuestTextureResource.cpp,TextureTiling.cpp): whenBASE_LEVEL > MAX_MIP,LevelsFitAllocationdescribes the chain extended to the view'sLAST_LEVELand accepts it only if the guest size, the layer size and every allocated level (offset, size, pitch, tail slot) are unchanged, and the extra levels end inside the layer. The view then decodes withmipCount = LAST_LEVEL + 1over the same bytes. Anything else still throws ("starts past the surface's last mip level at levels that would move the surface's own"), for example linear chains or chains without a tail, where an extra level would change the size. Views that start at or belowMAX_MIPare clamped to it as before.ShaderResources.cpp): storage images are shared through a surface key that includes the level count, so the extended view would get a second image of the same memory, and the two would flush and re-upload each other every frame. A surface once viewed past its allocated levels now keeps one image holding the extended chain, and its other descriptors find that image; the allocated-level image is evicted with its results stored.GuestTextureResourcegetsallocatedMipCount(MAX_MIP + 1) for this.No recompiler change is needed: the shader side only rejects such descriptors for MSAA types.
Base: current
main. The inventory note that this waited on #394 was about textual overlap in the tiling files; the change needs nothing from #394. It merges cleanly with #394 and with my thick-mip-tail follow-up of #394 (feat/agc-3d-thick-mip-tails), in either order, andagc_driver_graphicsand the new execution test pass on that merge. With #394, a 3D view pastMAX_MIPgoes through the same check (#394 throws for 3D chains that reach a tail until the follow-up lands).Tested
Linux (CachyOS, GCC 16.2, RTX 4090): full build with
BUILD_TESTING=ON;ctestpasses (169/169).Expected values from addrlib: Mesa's
src/amd/addrlibat e5f06878, built standalone, created as Navi10 (family 0x8F, revision 1) withGB_ADDR_CONFIG0x44 (16 pipes, like the PS5 equations inTextureSwizzleEquations.hpp).Addr2ComputeSurfaceInfo(ADDR_RSRC_TEX_2D) gave the sizes, level offsets and tail coordinates, andAddr2ComputeSurfaceAddrFromCoordthe texel addresses. The harness (addrlib-2d-harness.cpp, about 120 lines) and its output (navi10-2d.txt) are linked here.agc_driver_graphics(GuestTextureResourcecases): the 1920x1080 view of levels 6..6 overMAX_MIP5 decodes to 7 levels; size, every level's offset and the tail slots of levels 5 to 8 match the table, and levels 0 to 5 are identical to the 6-level layout. A view to level 8 covers 9 levels. The linear and untailed views are refused, and the sizes behind the refusals match addrlib.New execution test
agc_driver_view_past_last_mip(runs on lavapipe in CI): a compute shader stores through a level-3 view of a 256x256 R32_UINT SW_64KB_R_X surface withMAX_MIP2. After write-back, addrlib's eight texel addresses of level 3 hold the stored value and levels 0 and 1 are untouched. A second store through the level-2 view lands at addrlib's level-2 addresses and keeps the level-3 texels.agc_driver_recorder_tests(not registered in ctest; run by hand): after a view pastMAX_MIP, the allocated-level storage image leaves the cache, and both views get the same 4-level image, whose levels 2 and 3 are read from their addrlib tail slots.Fails without the change: on
mainwith only the new tests, all three stop at "guest texture descriptor starts past the surface's last mip level". With the first commit only, the recorder test fails with "the allocated levels' image is still the surface's after a view past its last mip".PPSA21564: the same two changes have been in my integration branch since 2026-10-03; both bloom chains' level-6 passes run every frame. This branch itself was not run in the title.
Fork CI (Linux and Windows) passes.
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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-04T07:40:37Z.
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/src/ShaderResources.cppL519core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppL519-526