fix(agc): copy a depth surface's plane through the texture's padded linear slices #4873
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4873"
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 GustavoGamarra95 on 2026-10-13T01:14:32Z.
What
Follow-up to #425 for depth surfaces whose linear layout is padded.
DepthPlaneCopylaid its staging buffer out as tight slices, while the detiler writes the guest's linear layout, which pads rows and slices, so the copy refused these surfaces withdepth plane copy geometry does not match its layers. Two shapes of padding reach it:DescribeSurfacegives 16384-byte slices where the copy expected 2048: the padding is in the slice size;Changes:
record()takes the layer'sLinearLayerOffsetplus the mip's linear offset, and the mip's pitch as the row length, for both the slices copied from a live depth surface and the ones detiled from guest memory. The staging buffer grows to the padded size whenever a larger layout shows up, keeping the buffer it replaces alive for copies already recorded, and a mismatch says which geometry it saw.agc_driver_depth_plane_samplingsamples both cubes (face 0 from the live surface, faces 1-5 from guest memory). The draw helper sizes its color target withColorTargetLayout, since a linear 32x32 target is padded to a 64-pixel pitch. The 128x128 case is taken from #4722 with its authorship kept.Overlaps #4722, which implements the same fix for the 128x128 case; this PR carries its test case too, so the maintainers can pick one. Rebased onto
mainafter #2490/#2491: the fix now lives inrecord()with itscopiedLayers/uploadLayerssplit.Tested
Linux, RTX 3050 Laptop (NVIDIA 615.78.08), on
maindacd78525. Both new cases fail without the fix with the message above (the 32x32 case also on its own) and pass with it; thedepthctests andagc_driver_graphicspass, andtools/check_conventions.pypasses. Beast of Reincarnation (PPSA29343) gets past this copy on currentmain; it then stops at a separate refusal of a multi-layer depth storage view, which we are still working on. @ps54all also ran this PR on Super Meat Boy 3D (PPSA31162, Windows, RTX 3080): it reaches its main menu instead of stopping at this refusal.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-13T17:37:40Z.
Super Meat Boy 3D (PPSA31162, UE5) data point, Windows 11, RTX 3080 (610.74), WinLibs GCC 15.2.0 r7, Release.
Without this PR (on
mainplus unrelated picks) the title runs about 120 s and stops atAGC graphics: depth plane copy geometry does not match its layers. With this PR it reaches its main menu (Continue / Start Game / Theater / Settings / Credits) and stays up for the full 420 s run.The PR no longer merges cleanly:
mainnow copies only changed layers (#2490/#2491), and the detiled uploads already land in the staging buffer atgeometry.LinearLayerOffset(layer). I ported it by giving thatregionlambdabufferOffset = geometry.LinearLayerOffset(layer) + mip.linearOffsetandbufferRowLength = mip.pitchBytes / texel, and keeping yourstagingSize/retiredStaginggrowth. #4722 covers the same refusal from the Kena side.AI-assisted (Claude Code); I ran the above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-13T18:00:39Z.
Cross-reference before further review effort: #4722 (alfalfa-star) implements the same padded depth-plane copy, and its version is already aligned with
main's newer structure.Both PRs make the depth-plane copy handle linearly padded layouts with the same core mechanism —
bufferOffset = geometry.LinearLayerOffset(layer) + linearOffsetandbufferRowLength = pitchBytes / texelBytes— but they're built against different generations of the surrounding code:mainhas since refactored the copy path into therecord()helper (with theregion()lambda and the copiedLayers/uploadLayers split), which #4722's diff already matches, while this PR reworks the older inline path.A plain rebase of this PR would therefore mean porting its region computation into
record()— work #4722 appears to have already done, on top of the motivating case (Kena's 128x128 D16 shadow-map cubes) and the tight-packing refusal fix. I'd suggest the maintainers pick between them before anyone spends merge effort here; happy to do the port intorecord()if this PR's version is the one that should carry it.Imported from boykopovar/AnyPS5. Originally posted by GustavoGamarra95 on 2026-10-13T19:19:18Z.
@blawesom thanks for the cross-reference. I rebased this PR onto
main: the fix now lives inrecord()(with #2491'scopiedLayers/uploadLayerssplit) and keeps both test cases, because they cover two different kinds of padding the same rule has to handle:A fix tested on only one of them could get the per-face offset right and the row length wrong, or the other way around. Both cases fail without the fix with
depth plane copy geometry does not match its layersand pass with it.The staging buffer grows whenever a larger layout shows up, keeping the previous one alive for copies already recorded, instead of refusing a larger layout after the first copy. Thanks also to @ps54all for the Super Meat Boy 3D (PPSA31162) run.
Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-14T07:07:30Z.
Super Meat Boy 3D (PPSA31162, UE5) retest on the rebased head, Windows 11, RTX 3080 (610.74), WinLibs GCC 15.2.0 r7, Release: main
f74ec639c+ this PR (17423e21emerge in a scratch tree).The
depth plane copy geometry does not match its layersstop is gone: three runs (300 s, 240 s, ~300 s) never hit it. The game stays on the Unreal/FMOD logo screen at about 2.4 FPS for the first 240 s on a warm second run and does not reach its main menu in these runs; the third run aborts at about 300 s with a different, existing refusal (storing storage image results pending over memory outside the write watch without the guest bytes saved before them is not implemented, Texture.cpp), which this PR does not touch. Earlier today the same title reached its main menu on my integration branch (main8cf6a0bc3plus my port of this PR); that branch has other local changes, so I do not claim a regression from this PR.AI-assisted (Claude Code); I ran the above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T17:26:35Z.
Rebased onto current
main(the depth plane copy now keys its textures by base slice; conflicts were only in theDepthPlaneCopymembers and the test list, no logic changed). Checked: build and the libSceAgcDriver ctest scope are green (the only failure,agc_driver_tessellation, is a RADV segfault unrelated to this change),agc_driver_depth_plane_samplingpasses, and it fails withDepthSurface.cppreverted, so both new cube cases exercise the fix. Per-layerLinearLayerOffsetplus the mip's pitch asbufferRowLengthis consistent with how the detiler writes the guest's linear layout. This covers #4722's case as well (its test is kept with authorship); merging.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T17:32:57Z.
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/DepthSurface.cppL332