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. Since boykopovar#9026 a plane is stored in 64 KiB units. A PS4 plane is tracked as one unit, so it is stored and reloaded whole: with 64 KiB units the Depth2D256 case left the texels past its first unit unstored. 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>
Brings in main 07da04f through the boykopovar#9431 merge offered as Get-fix#22. The PS4 tile mode lands in main's decodeDepthPlane, which now holds boykopovar#9431's PS4 depth decode. The debt file keeps this branch's PS4 depth plane entry under the guest-memory entry it extends, followed by main's shared-memory and unmapped-plane entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
boykopovar#9431 is on main now, so every file it touched takes main's version. Only this PR's own changes stay on top. In the debt file, this PR's PS4 entry sits after main's "Depth planes in guest memory" entry, with main's text of that entry and of its new stencil entry; StencilMirrorable still needs the PS5 swizzle, so a PS4 stencil plane stays in the host image as the entry says. The entry now names its sources for TILE_MODE_INDEX. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The new optional adds 8 bytes to State (928 on Linux x86_64 with libstdc++). The journal needs no other change: CanonicalPipelineState and the recipe codec keep only the depth target's format and samples, so the field never reaches a recipe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Mode Covers Risk's 0xa0000003 as Depth2D64, indices 2 and 7, the field above the index, a PS4 surface with no depth plane, and a PS5 DB_Z_INFO. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sameSurface does not compare DepthTarget::gcnTileMode, as it does not compare the swizzle of a single-sample PS5 plane, so a surface rebound at the same address and size keeps the mode it was created with. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A surface was reused at the same address and extent when only its GCN tile mode changed, so stores kept the layout it was created with while the sync at bind used the new one. Surfaces now compare the tile mode. Binding another tiling of the same storage stores the old surface's stale depth in its own layout and retires it, and a surface created for the new tiling reads the plane from memory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rfaces Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch and main both contain 26d651d, so a default merge uses a virtual base and reports conflicts in GuestTextureResource.hpp/.cpp, TextureDetiler.cpp, TextureTiling.cpp and the libSceAgcDriver debt file that neither side made. Merged against main's last merge base de83e8f instead. The one conflict left, in GuestTextureResource.cpp, is two new functions added at the same place (this branch's GcnTileMode, main's TextureResourceAllocationAddress); both are kept. Both sides grew State and each set the size check in PipelineJournal.cpp from 920 to 928, so git kept 928 silently. With both sets of fields State is 936; the canonical state and recipe codec already cover each side's fields.
State.hpp: DepthTarget keeps both fields, the PR's gcnTileMode (DB_Z_INFO tiling of a PS4 depth plane) and main's gcn (PS4 guest flag, boykopovar#9672); they are separate facts. Debt doc: the PS4 render target line keeps both added clauses.
The PS4 depth-plane entry already says a 32-bit plane reaches guest memory in its GB_TILE_MODE, and the added clause took the render-target entry past the 1000-character limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both sides grew State by 8 bytes and both set the size guard to 936; the merged State is 944.
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
Get-fix#20, moved upstream as Get-fix asked. boykopovar#9431 is on
mainnow, so this PR's diff is only the change below.A depth surface keeps its depth in a Vulkan image. boykopovar#7154 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;sizeof(State)guard inPipelineJournal.cppfrom 920 to 928.CanonicalPipelineStateand the recipe codec keep only the depth target'sformatandsamples, so the new field never reaches a recipe.PS5 planes are unchanged.
Since boykopovar#9026 a plane is stored in 64 KiB units. A PS4 plane is tracked as one unit (
SizeUnits), so it is stored and reloaded whole. With 64 KiB units, the Depth2D256 case below left the texels past its first unit unstored, even with a read in every unit. A debt entry of its own says so. D16, stencil and multisampled PS4 planes still keep depth in the host image only.main's stencil store (boykopovar#12210) needs the PS5 swizzle inStencilMirrorable, so it does not take a PS4 plane.Source for
TILE_MODE_INDEX. Nothing here is an AMD statement about Liverpool or a console measurement:DepthBuffer::GetTileModereads the index, and its depthImageInfouses it.DepthRenderTarget::getTileModereads the same field.TILE_MODE_INDEXat bits 22:20 ofDB_Z_INFO, the bits this reads.DB_DEPTH_INFO's array mode and macro-tile fields instead. So the register list doesn't show that Liverpool's DB uses the index.DB_DEPTH_INFO.This code does not read
DB_DEPTH_INFO, so a title whose two registers disagreed would be stored in the index's tiling. The debt entry records that.boykopovar#9672 (Get-fix#9 upstream) adds
DepthTarget::gcnnext to the new field. The two compose, and whichever lands second rebases a neighbouring line and recomputes the guard.Tested
Return to a tiling, 2 Nov. Head
c72cf633cd, test-only. oneandonlydean's review: going back to a tiling whose surface still exists.TileModeSwitchnow binds the first tiling again without writing and compares a draw at 0.5 under LESS with the plane's bytes in that tiling, on a new surface and on a reused one (a sampled texture held across the switch,DepthSurfacesSerialunchanged). No driver change was needed. Removing theSyncFromMemorycall on that bind, hiding the store from the reused surface, or removing the store each fails it at its own check (see the thread).agc_driver_gcn_depth_plane_buffer_memorypasses, 1 of 1 on the RX 9070 XT, noVUID-line. Not rerun: the other 34 tests of the 1 Nov run (no driver code changed), the same test onmain, the flip tests, Linux, games.Tile-mode switch, 1 Nov. Head
55f884b209(0b365d9926plus a shorter debt entry). oneandonlydean's review: a surface reused across a tile-mode change stored in its old layout.agc_driver_gcn_depth_plane_buffer_memorygainsTileModeSwitchon one 512x256 allocation, Depth2D64 then Depth2D256 and the reverse. Removing the tile compare, the store at the switch or the reload each fails it at its own check (see the thread). 35 of 35 pass once on the RX 9070 XT:agc_driver,agc_driver_pm4,agc_driver_graphics,agc_driver_gcn_detile,agc_driver_gcn_depth_plane_buffer_memory,agc_driver_resource_cache_replaced_textureand everyagc_driver_depth_*test, noVUID-line. Not rerun: the same set onmain, the flip tests, Linux (no struct under the size guards changed), games.Windows 11 Pro 26300, WinLibs GCC 15.2.0, Release, AMD Radeon RX 9070 XT (driver 32.0.31041.1004),
ANYPS5_GPU=AMD.Merge of
mainde83e8f270, 31 Oct. Head5d1381c40e. The only conflict was indocs/dev/debt/libSceAgcDriver.md: both sides kept.agc_driver_gcn_depth_plane_buffer_memory,agc_driver_depth_fast_clear_submitandagc_driver_graphicspass, 3 of 3 on the RX 9070 XT, noVUID-line. Not rerun: the other tests, Linux (mainchanged no struct under the size guards in this merge), games.Base. This branch is now
853389c92c:main5b913d40c6merged in (d8a0a2734b), then the guard bump, the decode test and a debt line. Every file boykopovar#9431 touched takesmain's version.git diff 5b913d40c6 853389c92cholds only this PR's ten files.git merge-treewithmaind2250771abhas no conflicts; that merge was not built. The Windows and Linux runs below were on4c37f8af0c;853389c92cadds one debt sentence to it.New
agc_driver_gcn_depth_plane_buffer_memoryruns a Depth2D64 and a Depth2D256 PS4 target, each two macro tiles wide and high (512x256 for Depth2D64):The test harness gains an optional GCN tile mode on
Surfaceand an optional scissor inDrawOptions.New
GcnDepthTileModeTestsinagc_driver_graphicsdecodesDB_Z_INFOthroughDecodeState:0xa0000003withDB_DEPTH_SIZEfor 2048x1152 gives Depth2D64 at that size, index 2 gives Depth2D256, index 7 gives DepthPrt1K, the field above the index changes nothing, a PS4 surface with no depth plane stays unset, and a PS5DB_Z_INFOstays unset.Revert checks on
4c37f8af0c, one rebuild each. Each test fails as shown and passes again with the files restored:DepthSurface.cpp,GuestTextureResource.cppandState.cppas on5b913d40c6, headers keptagc_driver_gcn_depth_plane_buffer_memorygcnTileModetest inSizeUnits(one-unit rule)agc_driver_gcn_depth_plane_buffer_memoryState.cppagc_driver_graphicsagc_driver_graphicsagc_driver_graphicszFormat != 0testagc_driver_graphicsif (gcn)scope (PS5 decode also takes the index)agc_driver_graphicsValidation layer: run with
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest -V, onmain5b913d40c6and on this branch. The tests:agc_driver_gcn_depth_plane_buffer_memory,agc_driver,agc_driver_pm4,agc_driver_pm4_replay,agc_driver_graphics,agc_driver_register_key,agc_driver_gcn_detileandagc_driver_pattern_buffer_fillagc_driver_flipand the 17video_out_flip_*modesagc_gcn_decode,texture_format_lookup,agc_driver_resource_cache_replaced_textureandagc_depth_copy_kept_bytesagc_driver_depth_*tests, among themagc_driver_depth_plane_buffer_memory,agc_driver_depth_fast_clearandagc_driver_depth_fast_clear_submitResults:
main: 58 of 58 pass (the new test is not onmain).VUID-line orwas not found but was requested by env var VK_INSTANCE_LAYERS. EverySelected GPUline names the RX 9070 XT (49 onmain, 50 here).Linux: WSL Ubuntu, g++ 15.2.0, cmake 4.2.3, Unix Makefiles,
-j4, from agit archiveof this code on the Linux filesystem.CMakeLists.txt:513and:521, because the machine has no X11 or audio development packages. In that local copy only, those twoFATAL_ERRORs became warnings. FFmpeg came from the project'sffmpeg-linux-x64.zipthroughFFMPEG_PREBUILT_DIR.PipelineJournal.cppstopped at the guard with(928 == 920).ShaderStagesstays at 164.shader_recompiler_agc_driver,agc_driver_pm4_tests,agc_driver_graphics_tests,agc_driver_depth_plane_buffer_memory_testsandagc_driver_gcn_depth_plane_buffer_memory_tests, and so all oflibSceAgcDriver. That includesGraphics/src/PipelineJournal.cppandcore/shader/recompiler/ShaderDiskCache.cpp, with their size guards active.agc_driver_depth_plane_buffer_memoryandagc_driver_gcn_depth_plane_buffer_memoryran on llvmpipe (LLVM 21.1.8); the other two print noSelected GPUline.Risk (CUSA03312): its board is sharp with a local stand-in that stores the same plane in the same tiling on the DB-flush
ACQUIRE_MEM. That stand-in ran onps4/limbo-gpuat93eeee0141(feat: run PS4 games on the AGC driver — Limbo (CUSA01664) in game (integration branch) boykopovar/AnyPS5#6977's head then), with the Get-fix pull requests and local stand-ins forsceGnmDrawInitDefaultHardwareState200andsceGnmUpdate*Shader; that base predates fix(agc): keep depth planes coherent with buffer reads and writes of their memory boykopovar/AnyPS5#7154. This exact commit wasn't run in the title, which also needs feat(libSceGnmDriver): build PS4 command buffers and submit them boykopovar/AnyPS5#9432.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branch pr9895-local(this commit), againstmaind2250771ab. Six pull requests conflict with this PR's lines:DepthTarget::gcnnext togcnTileModeinState.hpp, and changes a neighbouring debt entry.sizeof(State)guard line.DepthFastClearHarness.hpp, at line 44 onmain.All of them compose, and whichever lands second resolves the conflict and recomputes the guard if
Statechanged. Another 64 pull requests conflict withmainthemselves, so the tool could not compare them; 41 of those share a file with this PR's code or tests, among them feat: run PS4 games on the AGC driver — Limbo (CUSA01664) in game (integration branch) boykopovar/AnyPS5#6977 and feat(libSceGnmDriver): build PS4 command buffers and submit them boykopovar/AnyPS5#9432.Head
224af33ff1(2026-11-03): a docs-only commit on55cc111fe4that drops this PR's clause from the PS4 render-target debt entry, as XairRrR's review of55cc111fe4suggested; the entry is now identical tomain's and the PS4 depth-plane entry still states the tiling.tools/check_conventions.py --base origin/main(1e658521a0) passes. No code changed, so nothing was rebuilt or rerun.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