fix(agc): render into non-resident packed mip tails #4328
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4328"
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 pipe1os on 2026-10-12T06:31:27Z.
What
Fixes #4070. A draw into a packed mip tail of a color target that took the non-resident path threw
rendering into a packed mip tail needs the resident image of its surface. That stops Wobbly Life (PPSA29413) onmainwhen the surface's resident image is unavailable.This carries @devavijitsingh's #4176. The intake limit closed it, and its author couldn't build it. Their four commits are kept as they wrote them, and two commits on top make it pass:
ComputeColorTargetMipLayouttakes the mip's tail origin (tailX/tailY) from the surface's mip chain, the same layoutDecodeColorBufferalready uses to place the mip's address. The detiler reads the whole shared tail block. The retile writes back only the drawn mip's texels, so the other tail mips in the block keep their bytes, andWriteChangedstores only the bytes that changed. Packed tails in other tile modes, 3D targets and XOR array slices are still refused.ColorTargetLayout.cppnow callsComputeElementMipLayout, soagc_driver_bda_device_tests, which compilesColorTargetLayout.cppon its own, also getsTextureTiling.cppandTextureFormat.cpp(PostCompile.cmake). Without them it fails to link.ColorTargetMip, so non-mipmapped and untailed mip targets are unchanged.buffer range exceeds device limits. Its layout checks forComputeColorTargetMipLayoutstay in the unit test; the mock dispatches are removed.agc_driver_packed_mip_tail_targetcovers the dispatch on a real device:APS5_NO_RESIDENT_TARGETS=1).ColorTargetLayout::Offsetat the mip's tail origin. Each drawn mip's texels must hold its value, and everything else must still hold the initial pattern. That includes mip 2's texels after the draw into mip 3, which shares its block.DCC and CMASK are only decoded for color targets without mips (
maxMip == 0), so a fast-clear fill never covers a shared tail block.Tested
Windows 11, WinLibs GCC 15.2.0 r7, Release, RTX 4060 (NVIDIA 617.42).
agc_driver_packed_mip_tail_target:main'sDraw.cpprendering into a packed mip tail needs the resident image of its surfaceColorTargetMip(tail origin ignored)after the draw into mip 2: surface byte 0x0 holds 0x3e800000, expected 0x5a5a5a5aSo the CPU offsets the test checks against agree with the resident image path, which already rendered into tail mips.
agc_driver_graphicspasses, including theComputeColorTargetMipLayoutchecks.cteston this branch: 929 of 929 pass. The 5 skips are the same as onmain: the fourvideo_out_fliptests andguest_video_out_wqhd_detection_no_vulkan.agc_driver_image_plane_address_on_line_implicit_lodandagc_driver_image_volume_address_planar_texturewere not built here. Their object paths exceed WindowsMAX_PATHin my checkout, and the same happens onmain.tools/check_conventions.pypasses.I don't have Wobbly Life, so the title itself is not tested.
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 exefer on 2026-10-12T08:20:21Z.
Tested with #4341 alongside on Wobbly Life (PPSA29413, Linux (CachyOS), GCC 16.2.1, Intel i5-12400 + NVIDIA RTX 3060 Ti (615.71.09), current
mainplus both PRs, stock build plus relink): the packed-mip-tail abort is gone, noVUID-vkDestroyBuffereither. Five runs reach new endpoints past both walls instead: 2x compute-shader depth/stencil storage abort when opening the map, 1x segfault afterstorage image destroyed with GPU results pendingwarnings, 1xstd::__ios_failureduring teardown, 1x killed by me mid-run.Map abort matches open #1409.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T14:41:43Z.
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/PostCompile.cmakeL31-32core/libs/prx/libSceAgcDriver/PostCompile.cmakeL31-32core/libs/prx/libSceAgcDriver/PostCompile.cmakeL31-32core/libs/prx/libSceAgcDriver/PostCompile.cmakeL31-32core/libs/prx/libSceAgcDriver/PostCompile.cmakeL31-32core/libs/prx/libSceAgcDriver/PostCompile.cmakeL31-32core/libs/prx/libSceAgcDriver/PostCompile.cmakeL31-32core/libs/prx/libSceAgcDriver/PostCompile.cmakeL31-32core/libs/prx/libSceAgcDriver/PostCompile.cmakeL31-32core/libs/prx/libSceAgcDriver/PostCompile.cmakeL31-32core/libs/prx/libSceAgcDriver/PostCompile.cmakeL31-32Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-12T14:54:28Z.
Merged R_X fallback regression: on main
2a5eca11plus each of our independent centroid-only/D_X branches,agc_driver_packed_mip_tail_targetpassed five consecutive runs on both Windows RTX 5080/NVIDIA 610.62 and AMD 1002:13c0/driver 32.0.21036.18, ordinary LTO, AnyPS5 shader cache disabled. Full suites passed 967/0/7 of 974. These are merged-code tests, not a run of the original unchanged PR head.Updated title scope (2026-10-12): a controlled Sonic Unleashed Recompiled PPSA99902 / 01.003.000 replay now reproduces the packed-tail guard and captures its descriptor: D64_X (tileMode 26), RGBA32_UINT / 16-byte texels, surface 128x64 with 10 mips, selected mip 2 at 32x16, pipeBankXor 0x4000, one sample, no DCC/CMASK.
gpuTiling=0despite an available detiler. The replay stopped atrendering into a packed mip tail needs the resident image of its surfaceafter 771.826s, exit 0xC0000409, without timeout. Its older experimental integration head is0f6edc64d; private observer logging was the only addition. This is conditional integration evidence, not clean-main startup.This draw is outside the R_X GPU-routing scope of #4328: current draw routing enables GPU tiling for R_X only, while the packed-tail fallback requires GPU tiling. Our D_X layout PR #4318 is also a prerequisite for that mode and was merged on 2026-10-12 at
6f438a1c2. I investigated a separate D_X GPU detile/retile routing follow-up; the later-main native control below narrows whether this title still needs it. No such code change has been submitted. This observation does not invalidate the passing R_X regression or establish a defect in your original patch. The replay stopped before the MSAA clear/stamp comparison, so it supplies no new MSAA writer/coherence verdict. Originals, runtime and user data were restored; no private assets attached. Shared progress remains in Game bring-up #4443.Later-main captured-descriptor control (2026-10-13): a private synthetic probe based on the existing PackedMipTailTarget fixture now decodes the captured D64_X / RGBA32_UINT / 128x64 / ten-mip / XOR0x4000 shape on unchanged main
5f01c8082. With the normal resident path, drawing into mips 2, 3 and 1 and reading back throughGuestMemory::Readpasses 5/5 on both RTX5080 and AMD1002:13c0. Every word of the surface is compared after each draw, including the untouched mips and padding. This is a native replay of captured scalar state, not a new title startup.Forcing the existing
APS5_NO_RESIDENT_TARGETS=1diagnostic reproducesrendering into a packed mip tail requires the GPU tiled fallback5/5 on each device, because Draw's fallback is still R_X-only. The normal current-main control does not stop there, so the older integration observation alone does not establish that this title still needs a new routing PR. Refreshing the older integration with merged work is the next title-validation step. Initial private probe attempts had register/unsigned-export/readback mistakes; the reported passing control uses the corrected register encoding and establishedFlushPending/WaitIdle/GuestMemory::Readsequence. Raw host-pointer comparison was not a valid resident-image readback and is not reported as a rendering defect. No original assets or runtime were changed by these native controls.Imported from boykopovar/AnyPS5. Originally posted by devavijitsingh on 2026-10-12T15:14:08Z.
Hey, thanks for carrying #4176 forward and keeping my original commits in. I’ll be honest, it felt a little rough seeing the work continue under a different PR, but I appreciate you keeping the attribution clear.
Imported from boykopovar/AnyPS5. Originally posted by pipe1os on 2026-10-12T15:20:32Z.
Hey, totally fair, and I'm sorry it felt that way. I should've pinged you on #4176 before picking it up instead of just running with it. That's on me.
The fix is yours, though. Your commits are untouched, and all I did on top was get it through CI (the mock buffer limit in the unit test and a missing source in the BDA device test build) and add a GPU test. Glad it's already getting Wobbly Life past that wall.