Repository navigation
Conversation
…emory A depth surface keeps its depth in a Vulkan image. boykopovar#7154 stores a single-sample 32-bit plane with the 64 KiB Z swizzle into guest memory when a buffer read overlaps it, and reloads it when the guest wrote it. A PS4 depth target never took part: its DB_Z_INFO names a GB_TILE_MODE index, not a swizzle mode, so the plane kept whatever guest memory held. Risk (CUSA03312) decompresses its scene depth, flushes the depth block's cache over it and copies the 9 MB plane into a second buffer with a compute shader (buffer loads and stores). Its depth of field reads that copy through an R32F Depth2D64 T#, so with stale bytes the whole board was out of focus. A PS4 depth target now records the GB_TILE_MODE of its depth plane (DB_Z_INFO TILE_MODE_INDEX, mapped as the T# decode maps a tiling index). Such a 32-bit plane is mirrored in that tiling with DB_DEPTH_SIZE as its pitch, through the existing store and reload paths. agc_driver_gcn_depth_plane_buffer_memory draws three depths into Depth2D64 and Depth2D256 PS4 targets, reads the plane as a buffer and checks every texel at its GCN tiled offset. It then writes a left/right pattern into the tiled plane and checks that a LESS draw passes exactly where memory holds the greater depth. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 22, 2026
Author
|
Moved upstream as boykopovar#9895 on boykopovar#9431. Closing this one. |
12 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A depth surface keeps its depth in a Vulkan image. boykopovar#7154, now on
ps4/limbo-gpu, keeps a depth plane coherent with buffer reads and writes of its memory:GuestBuffersV#, an image lookup or a pending-store flush overlaps it;It only takes single-sample 32-bit planes with the PS5's 64 KiB Z swizzle (
SW_MODE24). A PS4DB_Z_INFOnames a GB_TILE_MODE index, not a swizzle mode. So a PS4 plane never took part, and a buffer read of it saw whatever guest memory held.Risk (CUSA03312) reads its depth that way in every board frame. On the Hasbro experiment stack (test/ps4-stubs, RX 9070 XT) the frame does this:
DB_RENDER_CONTROL = 0x60over the scene depth: 2048x1152D32_SFLOAT_S8_UINT,DB_Z_INFO = 0xa0000003, so tile index 0 (Depth2D64);ACQUIRE_MEMwithCP_COHER_CNTL = 0x84c44000(DB action) over the scene plane and over a second 9 MB buffer;DISPATCH_DIRECT 0x2400 x 1 x 1, which is 9,216 groups of 64 threads at 16 bytes each. It copies the 9,437,184-byte plane into the second buffer with buffer loads and stores;The copy carried stale memory, so the whole board was out of focus. Menus and 2D screens were sharp. Monopoly Plus, in the same pack, reads its depth through a T# smaller than the padded plane; that view reaches this PR's store through boykopovar#7154's image-lookup flush (see Tested).
This PR:
DepthTarget::gcnTileMode. It takesDB_Z_INFOTILE_MODE_INDEX(bits 22:20) and maps it as the T# decode maps a tiling index (GcnTileMode, a public wrapper of the existingresolveGcnTileMode);DB_DEPTH_SIZE's pitch asgcnPitch. The store, reload and stale-range code is fix(agc): keep depth planes coherent with buffer reads and writes of their memory boykopovar/AnyPS5#7154's, unchanged.PS5 planes are unchanged. D16, stencil and multisampled PS4 planes still keep depth in the host image only, as on the PS5, and the debt entry says so.
#9 adds
DepthTarget::gcnnext to the new field. The two compose, and whichever lands second rebases a neighbouring line.Tested
Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, on
ps4/limbo-gpu5ed564fa79, AMD Radeon RX 9070 XT.New
agc_driver_gcn_depth_plane_buffer_memory, for a Depth2D64 and a Depth2D256 PS4 target two macro tiles wide and high (512x256 for Depth2D64):Surfaceand an optional scissor inDrawOptions.Each part of the change is needed. Reverting one at a time, the same test gives:
mirrorableandmirrorResourceas on5ed564fa79mirrorableas beforemirrorResourceas before (the plane stored asSW_64KB_Z_X)Validation layer, with
ANYPS5_GPU=AMD,ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. The same 27 tests ran on5ed564fa79and on this branch, which also runs the new test:agc_driver,agc_driver_graphics,agc_driver_depth_bounds_state, everyagc_driver_depth_*execution test,agc_driver_gcn_detile,agc_driver_native_depth_bda_clear,agc_driver_native_multisample_depth, and the other users of the changed harness (agc_driver_alpha_to_coverage,agc_driver_dispatch_move_depth,agc_driver_multisampled_pass_order,agc_driver_pass_input_hazard).VUID-line. Both have the same threeUndefined-Value-ShaderOutputNotConsumed-DynamicRenderingwarnings.was not found but was requested by env var VK_INSTANCE_LAYERS. Every device in both logs is the RX 9070 XT.No unit test covers the
DB_Z_INFOdecode line, because no test runsDecodeStatewith GCN guest shaders. The title run below covers it.Risk (CUSA03312): test/ps4-stubs predates fix(agc): keep depth planes coherent with buffer reads and writes of their memory boykopovar/AnyPS5#7154, so this exact commit was not run in the title. A local experiment on that stack stores the same plane into guest memory, in the same tiling, on the
ACQUIRE_MEMDB flush instead of on the buffer read. With it the board is sharp, at the same 21-24 fps. Before and after screenshots of the same board scene are kept locally and available on request.Monopoly Plus, in the same pack, blurs its board for the fix(libSceAgcDriver): sample a PS4 depth buffer through a T# smaller than its padded extent #9 reason. Its depth of field samples the 2048x1152 depth plane through a 1920x1080 R32F Depth2D64 T#, which the depth surface does not serve, so the view read guest memory.
cachedTexture, which calls fix(agc): keep depth planes coherent with buffer reads and writes of their memory boykopovar/AnyPS5#7154'sFlushDepthPlanesbefore it reads memory, so with this PR the view reads the plane stored in its GCN tiling. That follows from the code path and was not run in the title, because test/ps4-stubs predates fix(agc): keep depth planes coherent with buffer reads and writes of their memory boykopovar/AnyPS5#7154.tools/check_conventions.py --base getfix/ps4/limbo-gpupasses.tools/pr_overlap.py --repo Get-fix/AnyPS5 --base ps4/limbo-gpu --branch fix/ps4-depth-plane-buffer-memorycould not compare 13 open PRs that conflict with the rebuilt base. I read their diffs: none decodes the PS4 depth tile mode or touches the depth plane mirror, and fix(libSceAgcDriver): sample a PS4 depth buffer through a T# smaller than its padded extent #9 only adds the field noted above.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