fix(agc): discard a new depth surface's depth before taking storage writes #10681
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10681"
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 PYTHONRETARDE on 2026-10-24T17:31:36Z.
What
DepthSurface::TakeStoragecopied the storage image into a new single-sample depth surface inGENERAL, right after the surface's creation clear. On an RX 7800 XT one or two 8x8 blocks of a D16 surface then tested as the clear value in about 1 of 12 runs ofagc_driver_depth_surface_from_storage(#6630). A copy of the depth image back to a buffer read the copied values in every row, so the stale data is in the depth test's view of the surface (likely its HTILE state from the clear), not in its texels.Without a stencil plane the depth aspect now goes
UNDEFINEDtoTRANSFER_DST_OPTIMALbefore the copy and back toGENERALafter it, so the clear's state is discarded before the copy writes every texel. A surface with a stencil plane keeps the previous path, since its depth aspect is not discarded alone. The behaviour is recorded indocs/dev/debt/libSceAgcDriver.md.Tested
Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, RX 7800 XT, AMD driver 32.0.31041.1004.
%LOCALAPPDATA%\AMD\VkCachecleared before each set.agc_driver_depth_surface_from_storage, run repeatedly:main29f539a5fd84a94e6don29f539a5fmainbfb080619mainbfb080619with the creation clear skipped (diagnostic only)5d251e6b0and6cd36e651The failing runs on
mainall reporta new D16 depth surface over a pending R16 unorm storage write: 79 pixels passed, expected 15.Validation:
ctest --test-dir build -R "depth|stencil" -V(42 tests) onmain29f539a5fand on this PRd84a94e6d, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Vulkan SDK 1.4.363.0). Neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS, and neither contains aVUID-error.Failures this PR does not change, seen in both validation runs:
agc_driver_depth_clear_hle:16-bit plane, mode 0: after a clear to 0.0 the depth test 0.5 > 0.0 did not pass everywhere. It fails in about 1 of 4 runs onmainon this GPU.agc_driver_depth_plane_partial_store:repeated lookups of the first layer of an unchanged array proved no refresh.git diff --check upstream/main HEAD,tools/check_conventions.py --base upstream/mainandgit merge-tree --write-tree upstream/main HEADpass.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T17:37:37Z.
Review: CHANGES_REQUESTED
Reviewed head
b529785d491d962222b0cabf302eb833d0336898against currentmain(d0e7fe7bebcb20325d8fd707451afec7d40a57cb). The reported RX 7800 XT reproduction and the paired validation logs are useful, and the described transition discards the pre-clear depth contents before the replacement copy. I cannot approve yet because the validation baseline in the report is6cd36e651, while currentmainhas since changedDepthSurface.cppsubstantially (including the depth sampling/copy-source path). This makes the posted 40-test comparison stale for the current PR base, even though the PR still merges cleanly. Please rerun the same focused depth/stencil validation set on currentmainand this exact PR head on the same machine/GPU, withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1, andANYPS5_REQUIRE_VULKAN=1; include the exact tested commits and confirm the layer loaded and whether the VUID set changes.git diff --check, the current-main conventions check, and the merge-tree check pass. Hosted product build jobs are skipped for this PR. I could not execute AGC tests locally: this runner’s Xeon E5-1620 v2 lacks the AVX2/BMI/LZCNT/FMA extensions the test harness requires.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T19:28:35Z.
Review: APPROVED
Reviewed exact head
d84a94e6d2833dcf0a1906be30fd377c79e703d4. For depth-only targets, the change inserts an execution-ordered discard transition toTRANSFER_DST_OPTIMAL, copies the full depth range, then transitions toGENERALwith transfer-write visibility; targets with stencil retain the combined-layout path. Barrier accounting is updated for the extra barrier. The author reports paired main/change validation runs on an RX 7800 XT with the Khronos layer confirmed and no VUIDs, plus 300 change runs with no reproduced stale-clear blocks; known unrelated depth failures are disclosed. Local diff-check and conventions pass; I did not run the Vulkan test here. Hosted product jobs are skipped by policy, and the PR is mergeable.