fix(libSceAgcDriver): retire a depth surface once another writer covers its memory #454
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/454"
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 SP4C3B4R-8 on 2026-10-03T11:20:28Z.
What
A depth surface lives only in its Vulkan image: nothing writes it back to guest memory. So once another pass reuses its memory, a view of that memory with another layout (another format, extent, slice or levels) can only throw, and a view that matches the plane keeps reading the stale image. This decides by the last writer, as suggested in review:
DepthSurfaceStorageserves, the plane's own extent and format, is not a retiring writer), or when a view the surface cannot serve finds guest memory over its planes written (CPU or driver store) since the surface was last bound;main;Two depth surfaces at one address are already resolved on
mainby the plane owners from #4683 (the one bound last serves), so this PR no longer retires on bind.The retired surface is never destroyed (its image may still be in flight). Known limit, listed in
docs/dev/debt/libSceAgcDriver.md: brought back, it keeps its own depth, not the bytes written over it. Without write watching, a view the surface cannot serve still throws.Tested
Windows 11, MinGW-w64 GCC 15.2.0, RTX 5070 Ti.
agc_driver_depth_surface_last_writer: depth then a view with two levels: throws; depth, color target, view: memory, and its own view is no longer served; depth, color target, depth again, view: throws; depth, CPU write, view: memory while its own view is still served before it; CPU write, depth, view: throws; depth, driver store, view: memory; a write past the plane retires nothing.agc_driver_depth_storage_reusegains one GPU case: a D32 surface drawn to 0.5, then a written storage image of another extent over it, then the plane's own sampled view returns the memory (0.25) instead of the stale 0.5.main).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🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T05:45:48Z.
Thanks for tracking this down. My concern is the case where the memory still holds the depth surface. On main a depth surface lives only in its Vulkan image: nothing writes it back to guest memory (
DepthSurfacein DepthSurface.cpp creates and clears the image, and nothing copies it out). So returningnullptrmakes the texture read whatever guest memory held before, with no error. That is right when a later pass reused the memory, but wrong when the title really reads the depth bits through another format. Could the decision depend on which wrote the range last? For example, retire the depth surface when a colour target, storage write or CPU write covers its range (thennullptris exact), and keep the throw while the depth surface is still the latest writer. Also note #425 rewrites the same condition inSampled.Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-04T10:18:59Z.
Thanks, you're right: as it stands this silently returns stale guest memory whenever the title really does read the depth bits through another format, and nothing in the PR tells those two cases apart. Deciding by the last writer is the better rule. I'll rework it that way:
nullptris exact;Since #425 rewrites the same condition in
Sampled, I'd rather build on top of it than race it, so I'll rebase onto #425 once it lands (or onto its branch if it is still open by then).A note on timing: I'm away until Wednesday 7 October, so the rework comes after that. Until then please treat this PR as not ready.
Written with AI assistance (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-10-06T16:17:53Z.
A data point for the rework: The Smurfs Dreams (PPSA21607, Unreal Engine) hits the case where the format does match the depth view: a compute shader samples a 2848x1600
R32_SFLOATtexture (guest format 22, tile mode 4) at the address of a 1024x1024 D32 depth surface (sampling the depth plane of depth surface ... (1024x1024, vk format 130) as a 2848x1600 texture of guest format 22). Since the extents differ, the memory has been reused by a later pass, so the last-writer rule should cover it too. Happy to test the reworked branch with it.Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-07T11:02:53Z.
@oneandonlydean reworked as agreed, on top of #425 (
c50f783d, @MichonGoddijn231849's head with the stencil change); only the last commit,fda7da98, is this PR.WrittenSinceat the view). The view then reads the memory like any texture.Tests for both orders are in the new device test
agc_driver_depth_surface_last_writer, listed in the description; it fails with the memory rule disabled.@Pacuka this should cover your 2848x1600 R32 view over the 1024x1024 D32 surface, provided whatever reused that memory was a color target, a written storage image at another address, or a CPU/DMA store. If the reuse was a storage write at exactly the depth address, it still throws, at the storage lookup this time (
storage image access to depth surface ... is not implemented); that line would tell us. A run with this branch would be very welcome.Written with AI assistance (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-10-07T16:09:02Z.
Thanks for the rework, I ran The Smurfs Dreams with it (on top of main
def81199). It still throws at the same view, but the reason is a second depth surface at the same address, not a missed writer: the game binds a 1024x1024 D32 surface and a 2848x1600 D32 surface at0x7fa0194d0000(different stencil addresses). The 1024x1024 one is created later, but the 2848x1600 one is bound last, right before the compute shader samples it as 2848x1600 R32.DepthSurfaceTexturetakes the most recently created surface (rbegin), so it picks the 1024x1024 one and throws.Locally, retiring the other surfaces that overlap a depth target's depth/stencil address in
DepthSurfaceView(on bind) fixes it: the abort is gone and the game keeps presenting (black for now because of unrelated skipped color draws).agc_driver_depth_surface_last_writerstill passes. Maybe you'd rather handle it in the lookup (prefer the last-bound surface); either way works for this title.Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-07T20:15:22Z.
@Pacuka thanks for tracking it down. I took your approach in
6b560806: binding a depth target retires the other depth surfaces whose depth or stencil plane overlaps its own. It fits the last-writer rule, since the bind is the latest writer of that memory. In your case the 2848x1600 surface bound last is then the only live one at0x7fa0194d0000and serves the 2848x1600 R32 view. Binding the 1024x1024 target again flips it back.agc_driver_depth_surface_last_writerhas a case for it (two surfaces at one address, the older one bound last: it serves its own view and refuses the other's, then the reverse), and it fails without the change.The branch is also rebased onto @MichonGoddijn231849's new #425 head (
d0ca0450); this PR is the last two commits. A run on Smurfs to confirm would be great when you have time.Written with AI assistance (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-10-07T20:22:37Z.
Ran The Smurfs Dreams with 6b560806 (on top of main
def8119+ a few other open PRs): the depth-plane abort is gone and the game ran 180 s without a crash. The 2848x1600 R32 view now resolves to the surface bound last.agc_driver_depth_surface_last_writerpasses locally (Linux, AMD). The skipped draws are the same as before (unrelated: vertex fetch range, immutable snapshot overlap). Thanks!Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-08T09:11:34Z.
I ran Ghost of Yōtei (PPSA26344 v1.008) for an hour with this PR at 6b5608067, and it clears almost all of the game's depth-surface skips.
Without the PR, our previous run skipped 705 draws that sample the depth plane of a depth surface through another view (for example the 1664x936 surface read as a 1920x1080 guest format 22 texture). With it there are none. The five compute shaders that wrote depth/stencil surfaces as storage images (499 skipped dispatches before) also run now. To be precise about that part: two of them write a depth plane, which the #425 commits this PR carries cover, and the other three write the stencil plane, which I handled in a small commit stacked on yours (an R8 storage image seeded from and copied back into the stencil aspect), so that half isn't this PR alone. The world frames went from mostly dark to properly lit in the same run, though I haven't isolated which change did that.
What's left in the hour: one depth-plane dispatch in 0x800027c200, which reads the 3328x1872 view of the depth surface at 0x5002870000 as a 3840x2160 guest format 22 texture, and 31 stencil-plane sampling skips (118 before) in 0x8000316900 and 0x800027c200, all format 5 views of that surface's stencil. No FATAL and no Vulkan error.
GitHub currently shows the PR as conflicting with main: the only hunk is in TechnicalDebt.md, where the two HTILE lines this PR carries sit next to main's new scePlayerReviewDialog line. Would you be able to rebase? Once you have, I'd like to open the stencil-plane storage commit as a PR stacked on this one, if that's all right with you.
Details
Windows 11, RTX 3080 Laptop. With the PR: our integration tree on main
c8a2f0632+ this PR at 6b5608067 (+ the stencil-plane commit on top). Without: the previous integration build.Gone (previous run):
Left (this run):
Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-08T09:34:04Z.
@Celegans12 thanks for the hour-long run and the breakdown. Rebased onto main
3ce729fe: the TechnicalDebt.md hunk keeps main's scePlayerReviewDialog line and the HTILE and depth surface lines. The #425 commits are carried unchanged apart from that hunk, so this PR is still the last two commits (534006e1,8e5ba478). ctest 428/428 on Windows.Yes, please open the stencil-plane storage commit stacked on this one. The 3328x1872 depth view of the 3840x2160 surface you have left looks like the same extent mismatch outside the last-writer rule; I have no case for it here.
@Pacuka thanks for confirming on Smurfs.
Written with AI assistance (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-08T19:08:16Z.
Rebased onto main
55e8959bagain: the only conflict wasdocs/dev/TechnicalDebt.md, where main added lines next to ours; both are kept. No code changes; this PR is still the last two commits on top of #425. Build and ctest pass (478/478).Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-08T19:50:56Z.
Data from Demon's Souls (PPSA01341 v1.07, Linux) on depth-surface memory that the title reuses for other images in a transient heap, which is the case this PR retires surfaces for.
Two shapes we hit in the tutorial level (runs 296-298):
sampling the depth plane of depth surface 0x2c25b0000 ... as a 1280x720 texture of guest format 71throws.storage image access to depth/stencil surface ... is not implemented.On a local branch, views that can't be a depth-plane view of the surface read the guest memory instead, which gets past both. I haven't run this PR with #425 on the title yet; if you'd like that, I can.
Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-09T14:06:12Z.
@fisherjoey thanks, both shapes are what this PR is meant to cover, so yes, a run on that title would help. If the bloom chain writes the cascade memory as a colour target or through storage, the cascade surface is retired and the 1280x720 view reads the guest memory. For the texture arrays, a view the surface refuses no longer throws once the memory was written after the last depth bind (colour, storage, CPU or driver write). If either still throws, the address and the writer that came in between would tell me which path misses it.
Rebased onto current main again (conflict only in
docs/dev/TechnicalDebt.md, both sides kept); this PR is still the last two commits on top of #425.Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T15:13:26Z.
Ran Demon's Souls (PPSA01341 v1.07, tutorial level via the debug start menu) on Nobara 44 x86-64, RTX 5070 Ti, driver 595.91.07. Build: our local branch + #425 (
62b1e552) + this PR at2e64579c, with our fallback for reused depth memory turned off. One caveat about the base: our branch carries #1368 (sampled depth arrays), and I kept its array lookup instead of #425's layered copy where the two collided in DepthSurface.cpp. That lookup matters for the second case below. Run 404.compute shader 0x2488ad900: sampling the depth plane of depth surface 0x2a4700000 (1024x1024, vk format 126) as a 1024x1024 texture of guest format 170 (vk 134), tile mode 3, dimension 2, levels 0-10, slice 0 is not implemented. The view is a 64-layer array at 0x2a0f00000, and a draw just before it skipped on the same shape at 0x29b700000 (guest format 181). Both start below the atlas slice at 0x2a4700000, and their layer range covers it. The surface was live, and no write to its memory was seen between its last depth bind and the view: no colour target, no written storage image, andWrittenSincestayed false. So nothing retired it. This match comes from #1368's array lookup, which finds a surface anywhere inside a view's layers. With #425's exact-address lookup alone, I'd expect this view to read memory and never reach your rule.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-09T16:36:47Z.
@fisherjoey thanks for the run and for separating the two cases so clearly. Good to see the bloom chain retire the cascades, the scene depth and the storage-written surface with no fallback on your side.
I agree with your reading of the second one. No write to the atlas memory came between its last depth bind and the view, so this PR has nothing to retire it on, and the surface is only found because #1368's lookup matches a surface anywhere inside the array's layers. With #425's exact-address lookup alone the 64-layer view starts at 0x2a0f00000, finds no surface and reads guest memory. If #1368 lands with that lookup, it may want a layer-range view that doesn't match a single surface's extent and format to read memory instead of throwing; I'd keep that out of this PR.
Imported from boykopovar/AnyPS5. Originally posted by NahuelGenchi on 2026-10-09T22:49:12Z.
Results from Sonic Origins Plus (PPSA05324, base game) on Linux with an R9 380 (RADV, Mesa 26.0.8), rendering at 960x540. I merged this PR at
2e64579conto the testing branch from #2021, which already carries #425.Before. The title reuses the memory of three depth surfaces for its color passes. In a 300 s run, 29 draws and dispatches were skipped because sampling those surfaces threw:
From the title emblem on, every other dumped frame was black.
With this PR. None of these views throw: a 260 s run has no
not implementederrors and no skipped draws or dispatches involving depth surfaces. The title emblem and the opening animation render with no black frames. The only skips left are 8 clip-distance draws, which are a separate issue (#423).Frame dumps
Before (every 30 presents):

With this PR (every 15 presents):

Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-10T08:39:12Z.
@NahuelGenchi thanks for the run and the before/after dumps. Good to see all four aliased surfaces in the opening read as memory again, with no skips left from depth surfaces.
Rebased onto #425's new head (
e6451eee, on #374 and mainaf1a8edf). Main now has9d65003c, which already treats a view of another extent, or of a format that can't hold the plane, as reused memory, so those views no longer reach this PR's rule. What this PR still adds on top:The conflict was in
DepthSurfaceView(HTILE clears from #425 kept, rebinding still revives a retired surface) andDepthSurfaceTexture(main's early fall-through kept first, then the last-writer check).planesAcceptednow takes #425'sinteger(an R16_UINT view that isn't a raw depth-bits view). InDepthSurfaceLastWriter, the view the surface can't serve is now one with two mip levels instead of another extent, since main reads the latter as memory; for two surfaces at one address, the test checks that the overlapped one no longer serves its own view. Tested on Windows (RTX 5070 Ti): ctest 656/656 at the head, the test passes on each commit alone, and still fails when the bind-time retire is removed.check_conventions.pypasses.Imported from boykopovar/AnyPS5. Originally posted by orbz22 on 2026-10-10T16:37:36Z.
Hollow Knight: Silksong (PPSA12544) hits the case this PR handles, on current
main(de5e541d+ #846) on Windows with an RTX 3060 Laptop. It happened once in the six runs of the same scripted opening that got this far, while Moss Grotto loads:0x269a50000 is the stencil plane of the 1920x1080 depth surface at 0x269190000. The game first binds that memory as a color target, then samples it as an 8-bit texture. With this PR, the color target over the stencil plane would retire the surface, and the texture would read the memory. The other five runs got past this point without the error. I have not run this PR, because it needs a rebase onto current
main.🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-10T21:19:05Z.
Tested the current head (dd3a2584) on
main262c0316with Astro Bot, which stops on the error this PR is about. It gets one step further and then hits a case the last-writer rule does not cover yet.Host: Arch Linux (kernel 7.2.9), GCC 16.2.1, Release, RTX 5080 (NVIDIA 615.78.08); device tests also on a Radeon 610M (RADV).
Merging onto
maintests/Graphics.cppincludes (BufferPool.hpponmain,DepthSurface.hpphere; both are needed).tests/execution/DepthFastClearSubmit.cpp:48no longer compiles:GuestAllocations::Mutation::Addtakes a fifth argument onmainnow. I passedtrue, as the other execution tests onmaindo.With those two changes,
ctest -R agc_driver:The NVIDIA failure is
agc_driver_dcc_keys_first_write, which fails the same way on unmodifiedmain262c0316here, so it is not from this PR.agc_driver_depth_surface_last_writerpasses on both.Astro Bot (PPSA21564, 01.007),
APS5_HOST_IMPORT_MIB=16384main262c0316compute shader 0x5006cdc00: AGC graphics: storage image access to depth/stencil surface 0x53a500000 is not implementedmain+ this PRcompute shader 0x5006cdc00: AGC graphics: storage image access to depth surface 0x53d8a0000 (1216x684, vk format 126) as a 960x540 image of vk format 122, dimension 1, 1 mips is not implementedWhat the title does, from a temporary log line in
DepthSurfaceViewandDepthSurfaceAtonmain:0x53a500000is a 960x540D32_SFLOATdepth target with no stencil plane and no HTILE. It is bound as a depth target 50 times in the 10.4 s after it is created.0x5006cdc00binds a 960x540 storage image of guest format 36 (B10G11R11_UFLOAT_PACK32) at the same base address. The last depth bind is 0.1 s before the refused view.0x53a500000(depth 960x540),0x53b300000and0x53d8a0000(depth 1216x684). The storage image is 960x540 with that format each time, and its binding is marked as written.So this is memory that alternates between a depth target and an unrelated colour image written by compute, at the depth surface's own base address, and in one of the three cases with the same extent. Reading the code, neither rule here retires the surface: a written storage image at the surface's own address is excluded from
RetireDepthSurfaces(so that it can be seeded from the depth plane), and the written-memory check is made inDepthSurfaceTexturebut not inSeedStorageFromDepth, which goes straight toTransfer, and that throws on the layout.A rule that gets the title past it
I tried letting a written storage image at the surface's own address retire the surface when the surface could not seed it (another extent, or a format that is not the depth plane's size). A read-only view of that kind still throws, and a storage image the surface can seed behaves as before.
diff on top of this PR
With it:
ctest -R agc_driver: NVIDIA 256 of 257 (the sameagc_driver_dcc_keys_first_write), RADV 257 of 257.tools/check_conventions.pypasses.Limits of what I tried: there is no test for the new case, the format check uses
ResolveTextureFormat(resource.format)whereTransferuses the storage image's own format, and I only looked at the two call sites that already retire for written storage images. The other titles on the linked issue were not tested, and nothing was run on Windows.Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T23:28:12Z.
Tested #425 (d6088bed) and the two commits of this PR on top (be4594bc, dd3a2584) with RetroArch's Beetle PSX HW core (homebrew RetroArch, PPSA99169). I used its hardware (Vulkan) renderer at native resolution, running a PS1 game through its opening (Metal Gear Solid). Windows 11, RTX 5070 Ti, MinGW-w64 GCC 15.2.0.
Base, without #425: every run logs, for Beetle's 1024x512 depth buffer:
With #425: the message becomes more specific:
That's an RGBA8 storage image using memory that still has a D32 depth surface registered on it. The memory was reused, so this isn't a real depth read.
With #425 and #454: the depth-surface messages are gone over the whole 80 s run, and the depth/HTILE/texture/storage tests pass.
So for this core, #454's retirement is what clears it. #425 alone moves the failure to the reused-memory case.
The frame rate in the intro's full-motion video stays low in hardware mode (about 4 FPS at that point, 43 FPS averaged over the run) with or without these PRs. The driver profile shows about 49 presents/s, the GPU mostly idle and small hook-sync waits, so that part looks unrelated to depth surfaces.
Caveats:
main: this is my integration branch, amainfrom 2026-10-07 plus my open PRs and others.ShaderResources.cpp, where I kept both conditions. I cherry-picked this PR's two commits on top;DepthSurface.cppconflicted with main'ssurfacesSerialbump, which I kept in the new-surface branch.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-11T10:14:46Z.
@fma-rc thanks for the run and for tracing the three address/extent pairs. That case is the last-writer rule's own ground, so I folded it in, close to your diff: a written storage image at the depth surface's own address retires it when the surface could not seed it (another extent, or a format that is not the depth plane's size). It reuses the seed's own fit check,
Transfer's storage format included, so the two cannot disagree. A read-only image of such a layout still throws, and one the surface can seed behaves as before. New cases inDepthSurfaceLastWriter: the seedable image keeps the surface, another format or another extent at its address retires it, and binding the depth target brings it back.Should @oneandonlydean's change on #425 (any one-texel format of the depth's size seeds the storage) land, the same-extent B10G11R11 case goes through the seed there and this rule only takes the other-extent ones (
0x53d8a0000, 1216x684); the two don't conflict.@TheAggie @orbz22 thanks for the runs.
Rebased onto #425's new head (
847cccc6, after #374's merge). Fullctest735/735 on Windows (RTX 5070 Ti, MinGW GCC 15.2), the new cases fail with the rule taken out,check_conventions.pypasses. Not run with the title onmainhere.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T10:37:37Z.
Review: CHANGES_REQUESTED
Reviewed the last three commits (the rest is #425). No problems found in them:
agc_driver_depth_surface_last_writer.What blocks it is the stack: this head conflicts with
main(DepthSurface.cpp,ShaderResources.cpp), and so does #425, its base. Once #425 is merged, please rebase ontomain, rerunagc_driver_depth_surface_last_writerand the otheragc_driver_depth*tests, and we will merge. When rebasing, keep theRetireDepthSurfacescalls in the newmainpaths ofShaderResources.cpp.Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-11T11:35:37Z.
Ran the title on Windows (7800X3D, RTX 5070 Ti, NVIDIA driver, MinGW GCC 15.2), cold boot without
-lvl,APS5_HOST_IMPORT_MIB=20480, on #425847cccc6(main after #374), with #3474 cherry-picked on both builds so the resource cache doesn't run the device out first:compute shader 0x500798d00: ... storage image access to depth surface 0x53b300000 (1216x684, vk format 126) as a 960x540 image of vk format 122, dimension 1, 1 mips is not implementedcae74a03) + #3474vkAllocateMemory buffer: Vulkan result -2(Resources.cpp, a host buffer outside the slabs), also withAPS5_HOST_IMPORT_MIB=16384So the same 1216x684 / 960x540 pair @fma-rc traced, at another of the three addresses, and the new commit takes it. The next stop is a host-memory allocation failure, not a depth surface; I haven't looked into it.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-12T11:18:30Z.
@adriadam10 thanks for the review. Rebased onto #425's new head
f470ffaa2(onmainacc5d2949), headde90e241e, same three commits.Two conflicts, both with lines
mainadded:DepthSurfaceTexture: keptmain's stencil rule (if (stencil && BytesPerElement(resource.format) != 1u) return nullptr;) before the last-writer check.cachedStorageTexture: kept #419'sRequireNoMultisampleTarget(...)as the first line, then this PR's retire / seed body.RetireDepthSurfacesstays in both storage paths ofShaderResources.cpp(resolveImageBindingand theRevalidateslow path). The two newer callers onmain,sampledStorageSourceandCachedStorageSurface, only read, so they keepwritten = false.Windows (MinGW GCC 15.2, RTX 5070 Ti):
agc_driver_depth_bias_per_face,depth_compare_copy,depth_fast_clear,depth_fast_clear_submitanddepth_surface_last_writerpass. Three other tests fail (agc_write_tracking,agc_driver_prepared_shaders_registered_workgroup_sync,guest_kernel_stack_protect); they fail the same way on #425 alone, so they don't come from this PR. Building this base on Windows also needsmain's #4021 Socket.cpp fix, which I applied locally only.Title run on the same host:
main+ #425 + #2490 + #2491 + this PR + #4213, warm caches,-lvlinto the first level, 9 minutes with no stop. @oneandonlydean, one note for your stack: #2490'swritten = ++depthWrites/drawnDepthinDepthSurfaceViewconflicts textually with this PR's second commit (the bind now goes throughbound). I resolved it asbound->written = ++depthWritesfor a rebound surface anddrawnDepth = boundbeforeNoteWritten().AI-assisted (Claude Code); I ran this on my machine.
Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-10-12T16:18:31Z.
Data point from Minecraft (PPSA17221), Linux / RX 6650 XT (RADV): on main
d592d54e1+ #4215 the title aborts about 10 s after start withcompute shader 0x21ffe6d00: AGC graphics: sampling the depth plane of depth surface 0x266bc0000 (1920x1080, vk format 130) as a 1920x1080 texture of guest format 22 (vk 100), tile mode 4, dimension 2, levels 0-0, slice 0 is not implementedWith this PR (head
de90e241) that abort is gone, and the title reaches the menu and renders the world. Merging into current main had one conflict:cachedStorageTextureinShaderResources.cpp, where main now throws forDepthSurfaceAt(context, words, viewed). I took this PR's side (lookupStorageTexture+SeedStorageFromDepth).Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T10:32:10Z.
#425 is merged; please rebase onto
main. It conflicts inDepthSurface.hpp,DepthSurface.cppandShaderResources.cpp, and the TechnicalDebt line now goes indocs/dev/debt/libSceAgcDriver.md.Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-13T23:03:57Z.
Thanks, will do: I'll rebase onto
main(DepthSurface.hpp,DepthSurface.cpp,ShaderResources.cpp, and the debt line moved todocs/dev/debt/libSceAgcDriver.md), rerunagc_driver_depth*, and push in the next day or so.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-14T14:36:13Z.
@oneandonlydean @adriadam10 rebased onto
main(5a6ad0ed3), headdf13acfe9, now one commit.#425's final head reworked
DepthSurface.cpp, so this is a port rather than a conflict fix:main's plane owners: a retired surface drops its depth/stencil ownership, and every lookup (planeSurface,depthSlice, layered slices,DepthSurfaceTexture,DepthSurfaceStorage,DepthSurfaceAt) skips it;mainnow returnsnullptrfor storage views the plane cannot serve, so a written one of those (or one overlapping the planes at another address) retires the surface incachedStorageTexture;docs/dev/debt/libSceAgcDriver.md.agc_driver_depth*10/10 pass, plus a new GPU case inagc_driver_depth_storage_reuse(written storage of another extent, then the plane's own view reads memory instead of the stale depth). Both new cases fail with their rule disabled. Full ctest 1185/1185.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-15T08:12:39Z.
Rebased onto
mainagain (d92a8dad3), headaf87b924c. Two conflicts, both from changes that landed since:DepthSurfaceTexture: theplanesadmission test in the retire rule now usesmain's new condition (extent check, base slice up toLAST_ARRAY), so a viewmainserves is never taken as unservable;RequireincachedStorageTextureis kept next to thewrittenretire.Full ctest: 1254/1254 pass (14 environment skips;
loadexec_argumentstimed out once under-j8load and passes alone).agc_driver_depth*11/11.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T09:06:03Z.
Rebased onto
main(0afa6a607e), head626cff7d2. One conflict inDepthSurface.cpp, from the native multisampled depth sampling that landed since (#ee1ba73a2and follow-ups):SampledAcceptsnow takesk2DMsaaas the one-slice dimension for a multisampled target, asSampledonmaindoes;Sampledkeepsmain's multisampledRequires before theSampledAcceptscheck;BytesPerElementearly return moved up onmain, so the copy this PR kept lower down is dropped;ApplyFastClearstays after the retire check as before.Linux build + full ctest: 1234/1235, the only failure is
agc_driver_tessellation(SEGFAULT inside RADV 26.2.4LinkPipelineFromLibraries), which fails the same way here onmainwithout this PR. The full Windows build is dispatched; it merges once that is green.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T09:06:05Z.
Review: APPROVED
Rebased and retested (see above); the earlier request was only the rebase.
Imported from boykopovar/AnyPS5. Originally posted by ee6aba54 on 2026-10-15T11:20:52Z.
A regression report from PPSA15304 (Linux, RTX 5080, NVIDIA 595.99.02). Since this PR is in, the gameplay scene renders almost black: the mean grey of the fixed-camera frame at the save's start position drops from about 100 to about 28. Lit surfaces keep only scattered bright specks, which looks like every shadow or depth lookup reading as occluded. Two runs on main plus our open PRs showed it, and a build of the same tree with only this merge reverted renders normally again (mean RGB 101/106/92, as before).
A local trace in
retireshowed that all 200 retires it logged came from the storage-write path (cachedStorageTexturewithwritten). None came from the color-target path or the sampledOverwrittenInMemorypath. The surfaces and the written ranges that retired them:The 2848x1600 surface is the scene depth. By
DepthSliceBytesits depth plane is 0x12b0000 bytes and ends exactly at the stencil, and the stencil plane is 0x540000 bytes. The two written ranges have exactly those sizes, so they look like another depth/stencil pair of the same extent viewed as storage images. They sit closer than those sizes allow: 0x311d860000 + 0x12b0000 overlaps the depth plane by its last 0x190000 bytes, and 0x311fa40000 + 0x540000 overlaps the last 0x1f0000 bytes of the depth plane and the start of the stencil. For the 512x512 surface, seven 4 MiB storage views whose base moves in 64 KiB steps all cover it. I have not checked whether these described ranges are what the shaders actually write, or only the sizeDescribeSurfacegives the whole view (padding, mip chain from that base). The scene going dark while the surfaces are retired suggests that the bytes the depth planes need were not overwritten.A possible direction: on the storage path, retire only when the written level and slice's own byte range covers the plane (as
CoversPlaneasks of a storage image that serves it), rather than on any overlap of the view's described size. I'm keeping this PR reverted on our test branch for now. I can trace further, for example the descriptor words of those storage views, if that helps.Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-16T08:05:43Z.
@ee6aba54 thanks for the trace, that is exactly the information needed.
The storage path retires on any overlap of the view's described size, and a retired surface reads guest memory, which never received the depth image's contents. So a partial overlap throws away the whole plane, while on hardware only the overlapped bytes would change. That matches the dark frame with surviving bright specks.
The direction I'd take: on the storage path, retire only when the bytes of the written level and slice (
CoveredMipBytes, no padding) cover a whole plane; a partial overlap leaves the surface alive, as before this PR.Your offer to trace further would help: for the storage views in your table, could you log the descriptor fields (dimension, width/height, base level and mip count, base/last array, tile mode, format)? The 512x512 case worries me most: seven 4 MiB views 64 KiB apart all cover its 1 MiB plane by described size, so whether they still cover it by the written level's bytes decides if the narrower rule fixes your scene.
Imported from boykopovar/AnyPS5. Originally posted by ee6aba54 on 2026-10-16T12:40:37Z.
@SP4C3B4R-8 Here are the descriptor fields, from PPSA15304 at the same spot (Linux, RTX 5080, one run of 60 s). For every written storage view whose described range overlaps a live depth surface, a local trace logged the view's descriptor and how many bytes of each plane the written level's
CoveredMipBytesreach (per written array layer or depth slice, whole tile blocks only). That is the narrower rule you describe. Offsets are relative to the depth surface's base. The title reuses this memory at shifting bases, so a view shape shows up at many offsets, usually 64 KiB apart.Dimension 1 is 2D, 2 is 2D array, 4 is 3D. Tile mode 4 is Z64KB_X and 7 is R64KB_X. Formats are the guest codes with the Vulkan format the driver maps them to.
512x512 surface (D32_SFLOAT_S8_UINT, depth plane 0x100000, stencil 0x40000 at +0x100000)
So the 4 MiB views that worried you (A) do cover the 512x512 depth and stencil planes with written bytes, not just by described size. The narrower rule would still retire this surface, and B to E would retire it as well.
2848x1600 scene depth (D32_SFLOAT_S8_UINT, depth plane 0x12b0000, stencil 0x540000 at +0x12b0000)
G and H are the 0x12b0000-sized writes from my earlier table, and K and L the 0x540000-sized ones. None of them covers either plane of the scene depth with written bytes, and neither does any other view that overlaps it (the closest is J, which reaches 0x11e0000 of 0x12b0000). The 3D views M and N contain no whole 64 KiB block per slice (a 64 KiB R64KB_X block of a 4-byte format is 128x128). By this data, the narrower rule keeps the scene depth alive and still retires the 512x512 surface. I have not run a build with the rule yet, so I can't say yet whether the scene comes out at its normal brightness. Once you have a revision, I'll run it at the same spot and compare the frame.
Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-17T08:23:42Z.
@ee6aba54 thanks, that table settles it. The fix is up as #7050: a written storage view retires a depth surface only when the bytes its written level holds (
CoveredMipBytesper written layer or slice, whole tile blocks) cover the surface's whole depth or stencil plane. By your data that keeps the 2848x1600 scene depth alive (J reaches 0x11e0000 of 0x12b0000, the 3D views hold no whole block) and still retires the 512x512 surface (A to E cover both planes).If you can run it at the same spot and compare the frame, that's the check I can't do here.