fix(agc): leave no empty layered depth storage behind when building it throws #23864
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23864"
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 milescoviello on 2026-11-19T20:13:06Z.
What
layeredDepthStorage(DepthSurface.cpp) inserted itslayeredStorages()entry withoperator[]and only then constructed theLayeredDepthStorageinto it. When the constructor threw, for example becauseStorageTexture::Createrefuses the view or an allocation fails, the map kept the key with a nullunique_ptr. The nextDepthSurfaceStoreBackwalks every entry and readsentry->storage, so it crashed on that null entry.Crimson Desert (PPSA25286) hit this in one run. On
mainit first stops on the cube-face image store that #22534 fixes. With #22534, #22609 and #22778 (all open) onmain7c836568c, it crashed at 361 s withfatal SIGSEGV (code 1) at address 0x00000000000007d8, right after a 39 GB storage texture was placed in host memory and a 75 GB texture-cache release request freed nothing.0x7d8isoffsetof(LayeredDepthStorage, storage), measured with a struct that has the class's data members in order (Context,0x760bytes;DepthTarget,0x58; the extent, the three layer counts and the layer pitch), so the crash is the read ofstoragethrough a null entry. Later runs of the same stack ended earlier in other crashes. #22534 and #22609 have merged since, and round 37 of my rotation on plainmain21baa27bfended the same way within 520 s. It hitfatal SIGSEGV (code 1) at address 0x00000000000007d8inDepthSurfaceStoreBack, called fromShaderResources::MarkGpuWrites, right after the same 39,397,711,872-byte storage texture and a 75,145 MiB release request that freed nothing. I haven't run the title with this change on thatmain.The change: look the key up, construct the storage, and insert it only when construction succeeds. An existing entry is refreshed as before. A failed construction now propagates its own error and leaves the map as it was.
This doesn't change why that title's construction fails, which I haven't pinned down: the 39 GB storage texture before it comes from another path (a later run with #23880 still makes it), so the failure is likely allocation pressure rather than this view itself.
Tested
Linux (Ubuntu 26.04.1, kernel 7.0), GCC 15.2, Ninja, Release,
-DBUILD_TESTING=ON, RTX 4070 Ti on NVIDIA 615.71:agc_driver_depth_storage(tests/execution/DepthStorage.cpp) gains a layered view whose construction fails: a copy of the test's context withmaxImageArrayLayerslowered to 2, and a three-slice 2D array view of the depth plane, soStorageTexture::Createthrows inside theLayeredDepthStorageconstructor; the test requires that refusal, so it fails if the setup stops reaching the failed construction. It then runs its existing last check, a store back of an unrelated storage image, which walks the whole map and must return false.agc_driver_depth_storagepasses 3 runs onf26c5230de(and on6db22413e4before the test required the refusal).main'sDepthSurface.cppand the new test, it ends infatal SIGSEGV (code 1) at address 0x00000000000007d8, the same address as the title's crash.ANYPS5_REQUIRE_VULKAN=1):agc_driver_depth_storagepasses 3 runs on6db22413e4.6db22413e4merged ontomain34369467e4: all 7agc_driver_depth_storage*tests pass with the layer inserted and noVUID-lines; withmain'sDepthSurface.cppthe new check ends in SIGSEGV at0x7d8.f26c5230demerged ontomain50d85e27bc(Mesa 26.2.6, RX 7900 XT and 7800X3D iGPU, Khronos validation layer 1.4.363.1): no new failures againstmainin the full suite on the 7900 XT or the GPU tests on the iGPU, and noVUID-orSYNC-HAZARDlines.git merge-treeagainstmainis clean, andgit apply -3of this diff ontomainwith #22778 or #11551 merged is clean.tools/check_conventions.pypasses on the branch and this body.f26c5230de, applied with other PRs ontomainfd4aeed483(one combined tree, not this PR alone), Windows 11, WinLibs GCC 15.2.0 r7, Release, no validation layer: the 6agc_driver_depth_storage*tests pass on an NVIDIA GeForce RTX 3080 (driver 621.24) and on the AMD Radeon iGPU of a Ryzen 7 9800X3D (gfx1036).mainnow reaches the crash, since #22534 and #22609 are merged: onmain66f88154a, a 600 s Crimson Desert (PPSA25286) run crashed at 272 s withfatal SIGSEGV (code 1) at address 0x00000000000007e0(0x7d8 on the earlier build), withripatlibSceAgcDriver.prx+0x69277b.addr2lineon that build resolves it toAgcDriver::Graphics::DepthSurfaceStoreBack, called fromShaderResources::MarkGpuWrites. The crash came right aftervkAllocateMemory storage texture: ... 39397711872 bytes placed in host memory type 0and a 75,145 MiB texture-cache release request that freed nothing.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 MarcZX10 on 2026-11-19T22:31:54Z.
Review: COMMENTED
Reviewed — no blocking findings
The cache insertion now constructs the layered storage before adding its key, so a construction exception leaves no null entry; I have one optional test-coverage point.
What I ran
Reviewed head
6db22413e40b8ec0ce1652bec5fc21ce4ae3a6c1. Read the prepared description, commit summary, manifest, diff, and the changed function and test context throughrepo_read.py. No tests were run.Results
Findings
Blocking
None identified in the inspected hunks.
Non-blocking
core/libs/prx/libSceAgcDriver/tests/execution/DepthStorage.cpp:315: the test silently catches the expected construction exception and continues even if construction succeeds. Consider asserting that the exception occurred, so the regression test fails if the setup no longer triggers the failure path.Not verified
The full contents of both changed files and excluded files were not read. Tests and author-reported environment results were not independently verified.
To get this to a good state
Nothing is required. Optional: assert that the construction attempt throws, as noted above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T04:41:37Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the optional point below is for clarity.
What I ran
Reviewed head
f26c5230deb76f11a3dfc9baf96d398e95b90321usingrepo_read.py. I readdescription.md,commits.md,manifest.json,diff.patch, and both changed files at the relevant code ranges. No commands or tests were run. Author-reported test results were not independently verified.Results
files.jsonwas not available in the prepared bundleFindings
Blocking
None.
Non-blocking
DepthStorage.cpp:315expects the failure message to containmaxImageArrayLayers. Consider checking only that construction fails, or assert a more stable error contract if message text is not intended as API. The test otherwise exercises the failed layered-storage construction and subsequent store-back path.Not verified
The reported Linux, Windows, NVIDIA, AMD, validation-layer, negative-control, merge-preview, and convention-check results were not run or independently confirmed.
files.jsonwas unavailable, so excluded-file details were not verified. Files read:core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppandcore/libs/prx/libSceAgcDriver/tests/execution/DepthStorage.cpp. The manifest lists both changed files as included; no other changed files were listed.To get this to a good state
Nothing is required. Optional: avoid coupling the test to the exact
maxImageArrayLayersdiagnostic unless that wording is part of the intended contract.