fix(agc): place a layered depth storage view at the guest's layer pitch #8109
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8109"
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 ebosido444-ai on 2026-10-19T22:01:40Z.
What
A 2D-array storage view over a depth surface is served as one storage image with a copy per layer, but each layer's depth surface was looked up at
layer * DepthSliceBytes(extent, bytesPerTexel), and any other guest layer pitch was refused outright:That comparison is wrong in the ordinary case.
DepthSliceBytesis the 64 KiB-aligned slice size the driver copies, while a linear (untilied) depth array's layer pitch is the texel-tight size — the case intests/execution/DepthStorage.cpp, where the pitch is 0x4000 and the aligned slice is 0x10000. Nothing else in the file assumes the aligned size: the depth-plane sampling path already reads each layer atgeometry.GuestLayerOffset(layer), andLayeredDepthStorageis built from that sameDescribeSurfacegeometry.The layer lookup now uses the descriptor geometry's layer pitch, stored with the layered storage, and the refusal is gone. The image, the per-layer copies, the store-back and the cache key are unchanged; only the address of layer N moves.
Tested
Windows 11 26200.8117, winlibs GCC 15.2.0, Ninja, Release. GPU: NVIDIA GeForce GTX 1650 Ti, driver 617.14 (Vulkan).
tests/execution/DepthStorage.cpppreviously asserted the refusal ("a two-layer 2D array view of the depth plane with a layer pitch other than the depth slice size was accepted"). It now asserts that the view is taken with two image layers, that the plane's data reaches it, and that a view from layer 1 is taken too.main:agc_driver_depth_storageexits 1 withAGC graphics: storage image access to the depth planes of depth surface … with a layer pitch of 0x4000 bytes, not the depth slice size 0x10000, is not implementedagc_driver_depth_storageexits 0,depth surface storage access tests passedagc_driver_depth_plane_guest_layers(passed),agc_driver_depth_storage_reuse(passed)tests/execution/*.cpptargets and their ctest entries come from the existing glob, so no CMake change is part of this PR.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-20T07:38:54Z.
Tested on RTX 3080 (NVIDIA 617.42) and AMD Radeon RDNA 2 iGPU (
1002:164e, 32.0.21045.5002), Windows 10 Pro 22H2, WinLibs GCC 15.2.0, Release, head11cc05929:agc_driver_depth_storagepasses 3 of 3 on both GPUs, so AMD (RDNA 2) and a second NVIDIA generation behave like the GTX 1650 Ti.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T00:41:42Z.
@ebosido444-ai Thanks, placing layer N at
GuestLayerOffset(N)matches how the depth-plane sampling path already reads it, and the test covers the pitch != slice case. One question before merge:Depth targets are always placed at
slice * DepthSliceBytes(64 KiB aligned). When the view's layer pitch is smaller (the test's 0x4000 against 0x10000), view layers 1..3 fall inside layer 0's tracked depth surface without starting at it.layeredSlicesmatches surfaces by start address, so those layers aren't found and come from guest memory throughStorageTexture::Create. If that depth surface holds data that hasn't been written back yet (rendered, store pending), the view would read stale bytes there. Main threw in this case, so nothing could read it stale before.Could you confirm that the
FlushPendingat view creation also lands a tracked depth surface's pending bytes for a range that overlaps a view layer (a test that renders into layer 0's depth surface, then reads layer 1 of the view, would show it)? If it doesn't, please keep the refusal for the case where a tracked depth surface overlaps a view layer it doesn't start at.Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-21T08:25:03Z.
Yes, it lands, and the case is now covered by a test rather than argued from the code.
FlushPendingdoes not match pending images by start address: it walks the pending list and keeps every image whose guest range intersects the requested range (StorageTexture::overlaps,Graphics/src/Texture.cpp:3490, used atTexture.cpp:3661), then narrows to the images with a pending unit inside that range (pendingUnitInside,Texture.cpp:3633). A tracked depth surface that a view layer only overlaps is stored the same way as one the view starts at. There is a second call on the same path:StorageTexture::Createflushes the range again in its refresh (Texture.cpp:2057), so the store happens before the upload even without the constructor's call — disabling the constructor'sFlushPendingand rerunning still passes the new test, so the ordering does not rest on that line alone.tests/execution/DepthStorage.cppnow covers your case: it fills a 64 KiB swizzled depth plane (kStandard64KB, guest 0x10000, pitch 0x10000) with 0.75 and does not store it back, marks the bytes of the layer that only overlaps the slice with a 0.375 sentinel, then takes a four-layer linear view at pitch 0x4000 over the same memory. It asserts that the pending 0.75 is in guest memory by the time the view exists, and that after the readback the overlapping layer still holds the 0.375 sentinel — the depth result reached the bytes the surface owns, and none of it leaked into the view layer that does not start at it.I also found a hole in the assertion I had added:
layerPitch + sliceBytes > BlockBytes || CountFloats(...)holds for this fixture, so the pitch check never ran. It runs now and asserts the added layer's content (the guest bytes at 0x4000, which the fixture leaves zero).So I would not keep the refusal for the overlap-without-start case: the store covers it, and the test fails if neither flush reaches the range.
Ran on the GTX 1650 Ti, Windows 11, WinLibs GCC 15.2.0,
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest --test-dir build -R agc_driver_depth_storage -V:agc_driver_depth_storage,_dispatchand_reuseall pass. There is no Khronos validation layer installed on this machine, so I could not run theVUID-comparison AGENTS.md asks for — say the word if you want that run before this goes in and I will install the layer and do it.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-21T08:58:40Z.
Follow-up on the
VUID-comparison AGENTS.md asks for — I installed the validation layer here and ran it, so that gap is closed.Machine: GTX 1650 Ti, Windows 11, WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON. Layer: Khronos validation 1.4.363 from the Vulkan SDK, requested withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation; the loader log confirms it was loaded (thewas not found but was requested by env var VK_INSTANCE_LAYERSline does not appear).main50efb5c:ctest --test-dir build -R agc_driver_depth_storage -VwithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1— 3/3 passed, 0VUID-lines.5a67ff9: same command — 3/3 passed, 0VUID-lines.So the change adds no validation errors, and the three depth storage tests behave the same on both trees. The new assertions above do not run on
mainat all, since the layered view throws there.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-22T10:11:33Z.
Heads-up: the
conventionsjob had gone red on this head — my test added four explanatory comment lines, and this repo only allows comments that come with a debt file. They are removed in2d7a8dab5(the explanation lives here and in the commit message instead), soconventions,eligibility,labelsandreportall pass again and the PR isCLEAN.Re-verified at
2d7a8dab5:agc_driver_depth_storage_testsbuilds in 15 s incremental andctest -R agc_driver_depth_storagepasses 3/3 withVK_LAYER_KHRONOS_validationloaded, 0VUID-lines. Behaviour is unchanged — the diff is four deleted comment lines.The open question above (view layers that only overlap the depth slice) is unchanged and still answered with the test at
DepthStorage.cpp:274.AI-assisted: yes.