fix(agc): execute the DB's out-of-place depth expand #6146
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6146"
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 EagleBearerYS on 2026-10-14T23:29:28Z.
What
A draw that sets DB_RENDER_CONTROL's DEPTH_COMPRESS_DISABLE with DB_Z_WRITE_BASE different from DB_Z_READ_BASE is a DB expand. The DB writes the read surface's depth plane, uncompressed and in the same swizzle, at the write base. With DB_DEPTH_CONTROL 0,
DecodeStatetook the "always-pass depth/stencil state is rendered without a depth target" path, so the draw drew nothing and the write base kept whatever the CPU had written there.Resident Evil Village (PPSA01556, 01.210.000) issues four such draws per frame in its first 3D scene, then lights, fogs, resolves and blends the scene from the copy. With zeros there, which is the far plane in its reverse Z, the scene renders as soft light discs on black. One of the game's draws, from a register trace at first player control:
That's Z_32_FLOAT, one sample, SW_64KB_Z_X, 1920x2160. All other depth draws in the frame read and write at the same base.
Recognition:
DecodeDepthExpandPassdecodes the target with the draw state's own decoder (depthTargetFor) and takes exactly this shape:ColorWriteMask's rule, so an INVALID-format target writes nothing, as for a draw;The copy: each moving plane of the live depth surface at the read base, with any pending fast clear applied, is copied into the storage image of a view of its write base and marked written: R32F or R16 UNORM SW_64KB_Z_X for the depth plane, and R8 UINT at DB_STENCIL_WRITE_BASE for the stencil plane. A slice of a depth array goes to the same slice of the write base. Sampled views of the write base use that image. Raw and CPU reads store it into guest memory in the Z swizzle, as for any written storage image.
In order: the expand runs only from the draw precheck, which decodes it and the colour-metadata pass as one outcome and runs either the same way: it drains the draw pipeline, takes the GPU lock, writes the packet's labels and runs the pass.
a39261b75c), records the copy after every earlier draw. An indirect expand was already drained before the precheck.Address-based builds: they read host-imported heaps in place without storing the results pending there. So the expanded planes still pending in imported write bases are stored ahead of every address-based build (
StoreDepthExpandWrites). Resident Evil Village's copy shader reads its write base through a V# right after the expand.HostImportOverlaps), not only when one import holds all of it.main, sinceea3a2152d). When part of it has no import, the write-back goes through the CPU after a wait for the expand.UploadFinishstores again after the build's own imports, so a build that imports the range itself stores the plane before reading it. When nothing is noted, that second call is a lock and a scan of an empty map.UploadFinishnow stores the results pending under every read-only V# of an address-based build, as it already did for written ones. Pointer reads keep the exemption; for them the expand's planes are still stored ahead of every such build, as above.Indirect expands: Resident Evil Village issues its expands as indirect draws.
DRAW_INDIRECT,DRAW_INDEX_INDIRECTand their multi forms read their count and records on the CPU, as the draw path's CPU route does.No depth surface at the read base yet (Resident Evil Village does this once during boot): the write base takes DB_DEPTH_CLEAR when an HTILE depth clear of the surface is pending, and otherwise the read base's guest bytes.
Repeats: an expand whose plane the write base's image already holds is skipped. The surface's write serial and the image's content version decide that; 7 expands in the test make 3 copies.
What throws: every other out-of-place expand, naming the reason: Z_24 or no depth plane, multisampled, other swizzles, mips and layer exports, partial coverage, and one into a live depth surface of the same device or from one of another extent, format or sample count. An in-place expand changes nothing modelled, as before.
Debt: a new "Out-of-place DB expand" entry under Unknown function info lists what is inferred and what is left:
The entry keeps to the gaps, within the 1,000 characters
check_conventions.pyallows. Two things it leaves out: the first expand into a write base uploads bytes that the copy then overwrites (35-47 ms at 1920x2160 on lavapipe, against about 3 ms for a later expand), and a depth surface bound later at the write base without HTILE starts from the expanded plane (TakeStorage, #5446), while one bound with HTILE doesn't. "Reused depth storage" stays as onmain. A second new entry, "Pending storage-image results under the heaps of an address-based build", says what such a build stores and what it leaves to pointer reads. The "HTILE address of a depth array slice" entry goes: since #5111 each slice has its own HTILE.Not done here, with the reasons:
Tested
agc_driver_depth_expand_out_of_place, an execution test through PM4 using the game's register values:image_loadand throughGuestMemory::Read, detiled with the driver's SW_64KB_Z_X equation.main9f03c4fe0the write base holds 0 of 15,360 texels of the depth. With the change it holds 15,360 of 15,360 both ways, with one raster sample and with the game's two (PA_SC_AA_CONFIG 0x00108001).DRAW_INDIRECT,DRAW_INDEX_INDIRECT, and a record that draws nothing;agc_driver_depth_expand_reviewchecks the expand beyond the game's case:agc_driver_pipelined_filldoes for fills, and puts the depth draw and the expand in one submission. On GitHub's Linux runner, withmain'sDrawPrecheck.cpp, each of 10 runs failed all three cases on the texture read of the write base, with the draw queued every time; with the drain, all three passed 20 of 20 (run).agc_driver_depth_expand_out_of_placecopy the write base with address-based programs right after the expand:split-imported-buffer-read,split-imported-pointer-read), or one imported and the other heap-mirrored (split-mirrored-buffer-read) or copied (split-copied-buffer-read).103316e332, onmainand on this branch's base, all four fail:expanded planes stored ahead of the copies: 0 (expected 1), then0 of 15360 texels hold the read surface's depthwith both ranges imported, or3072 of 15360with one mirrored or copied.15360 of 15360.main, a temporary print in the write-back showedDB expand: GPU path, 2 segment(s), 131072 byteswith both ranges imported. With one mirrored or copied it showedDB expand: CPU path, 0 segment(s), 65536 bytes, after that range's own write-back of the other 64 KiB.unimported-mirrored-buffer-read,unimported-copied-buffer-read): these pass with and without103316e332, because the mirror refresh and the copy store the pending plane themselves.address-based-storage-image-readinagc_driver_depth_expand_out_of_placestores a value to every texel of an image with one compute dispatch, then copies the image's bytes through a read-only V# with the address-based copy kernel. It does that twice with different values: the first copy takes the per-build path, the second the cached address space. Withoutbfcd1839a8both copies hold 0 of 15360 texels; with it, 15360 of 15360.depthExpandPassTestsinagc_driver_graphicscheck the decoder on the game's values and every refusal.f2f52d08atoa6005bab04, merged at the head), each red without its change on CI's Linux configuration (lavapipe) and green with it:agc_driver_graphics: the state-only refusal (with it reverted: "an out-of-place DB expand that reached the draw path was not refused"), the 0xc0 shape, an INVALID-format colour target and a non-finite clear (with the old decode: "… with color writes is not implemented"), Z_16 and Z_24, slices and layer exports, and the stencil decode.agc_driver_depth_expand_review, each read through a texture and raw:agc_driver_depth_expand_out_of_place:direct-indexed: DRAW_INDEX_2 with no indices, or no instances, keeps 32768 of 32768 dwords the CPU wrote (before: 17408), and a three-index expand matches 15360 of 15360;five-range-write-base(a write base across five registered ranges, as Resident Evil Village's spans five 4 MiB mappings),compute-queue-read(an ACB copy),dma-read(DMA_DATA),depth-bind-of-write-baseandstore-without-import-room: 15360 of 15360 in each check. The last pins the import-neutral store, which no lavapipe run can make fail: every address-based build there imports its ranges itself.agc_driver_depth_expand_out_of_place_inline, withAPS5_PIPELINED_DRAWS=0.maind6eafa54d0(97ad315a0a, the head), which brings #7927's depth mips (whamre). #7927's mip branch now runs insidedepthTargetFor, which bothdecodeDepthand the expand call.decodeDepthkeepsmain's checks for partially resident depth and stencil, and its own depth-mip refusal goes, as onmain. The expand still refuses depth mips and mip views itself.agc_driver_graphicsand the other tests built from the changed files pass 10 runs in a row on Linux. On Windows they build and pass, with the Vulkan tests skipping.agc_driver_graphicsreports Passed in all 10 Linux runs, so its disabled-colour and expand-decoder cases ran.^agcsweep on Linux (run) fails 1 of 877:agc_driver_sgpr_pattern_fill_keys,main's #8715 test, failed once under the sweep's parallel load ("the dispatch completed 17 times without a pending write over the keys") and passes 20 of 20 alone (run). It has failed the same way under load on branches without this PR.mainagainst this PR (CONTRIBUTING's AGC rule), on one GitHub Linux runner (run). Both runs usedVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1andctest -V, withVK_LOADER_DEBUG=layerto show the layer loading. The device was llvmpipe (LLVM 20.1.2) on Mesa 25.2.8, Ubuntu 24.04.5, Khronos validation layers 1.3.275.main's depth tests,agc_driver_depth_storage,_clear_hle,_fast_clear,_plane_samplingand_htile_write, withagc_driver_graphicsand the other tests built from the changed files, on both trees, plus this PR's three expand tests.main's tree ran its set once and this PR's three times.VK_LAYER_KHRONOS_validation6 times onmainand 36 with this PR, and neither log haswas not found but was requested by env var VK_INSTANCE_LAYERS.VUID-VkDeviceCreateInfo-pNext-pNextandVUID-VkImageCreateInfo-samples-02258. This PR adds noVUID-message.main2f161d4f33(fa02e9bbe3), which brings #8975's DB depth copies. Both PRs had pulled the CB metadata pass's coverage check out into a helper, so the merge keepsmain'sdrawCovers(which also checksPA_CL_VTE_CNTL), points the expand's call at it, and drops this PR'spassCovers. ADEPTH_COPYdraw still reaches #8975's decoder: the expand's decoder returns nothing unless a compress-disable bit is set. On GitHub's runners (run), the depth-expand tests,agc_driver_graphicsandagc_driver_depth_storagepass 5 runs in a row on Linux, with the other tests of that run: 34 in all, none skipped or failed. On Windows 28 of the run's 33 tests pass 5 runs in a row,agc_driver_graphicsamong them, and 5 skip, as the runner has no Vulkan device: the three depth-expand tests,agc_driver_depth_storageandagc_driver_sgpr_pattern_fill_keys. An^agcsweep on Linux (run) fails 1 of 865,agc_driver_sgpr_pattern_fill_keysunder the sweep's parallel load, as onmain.846f0af61fcuts the "Out-of-place DB expand" debt entry to its gaps and leaves "Reused depth storage" as onmain, which #8412 also edits, so the two no longer conflict. On GitHub's runners (run), Linux:agc_driver_depth_expand_out_of_place, its_inlinerun,agc_driver_depth_expand_reviewandagc_driver_graphicspass 5 runs in a row, and an^agcsweep fails 1 of 851 (57 skipped),agc_driver_sgpr_pattern_fill_keysunder the sweep's parallel load, as onmain. The Windows job stopped atmain's own MinGW build error intests/execution/ImageArrayWindowPastLayerLimit.cpp, before any test ran; this commit changes only the debt file.main6696def6e6(dbbcdcd1c0), which brings #6725: the decoder compares the depth write base only when the depth plane is written. With this PR, a split-base draw with a compress-disable control (0x20, 0x40 or 0x60) is an out-of-place expand, soDepthStencilTestsexpects the expand's refusal for those three in its state, and "depth read and written at different addresses" for a depth clear (0x01).maina86577e464(13ad1f4663), which brings #7178's depth clear and #7346's 32-bit depth-bits debt entry. The debt file keeps both ofmain's entries. The merges before it:mainf474fb7768(c053a554a7;decodeDepthtakesmain's DB_RENDER_CONTROL check) andmain55f82fee83(24ec2d46c3; the debt file keepsmain's plane-fill entry and drops the HTILE slice entry, as25594523aedoes). On GitHub's runners (run): of the 709^agctests on Linux, 661, the expand tests among them, pass 3 runs in a row, 48 skip and none fail, and the libc and libkernel suites pass. On Windows the only failures areagc_driver_pm4_replay_toolandagc_shader_replay_tool, which fail the same way on that runner for an unrelated branch (run).25594523ae, on GitHub's runners:ctest -R '^agc'ran 604 tests, 1 failed (agc_driver_preparation_scope_settle, as onmain), 41 skipped on Linux, and 598 tests, 1 failed (agc_driver_pm4_replay_tool, as onmain), 466 skipped on Windows (run). The expand tests andagc_driver_graphicspass 10 runs in a row on Linux, andagc_driver_graphicson Windows, whose runner has no Vulkan driver for the others; with the sources of the previous head (d359e15280) the new cases don't build (run).main2e5dd5aa14, which brought #5627, #5554 and #5524's changes toDepthSurface.cpp: the HTILE clear,ApplyFastClearand surface retirement, which the expand uses. The only conflict was one include block, wheremaindropped a duplicateGuestMemory.hppinclude next to the two this PR adds.ctest -R '^agc'ran 603 tests, 1 failed (agc_driver_preparation_scope_settle), 41 skipped (run). Onmain2e5dd5aa14alone: 601 tests, the same one failed, 41 skipped (run). The two extra tests are this PR's. The two expand tests and seven others around the code the merge changed passed 10 of 10 at the head (run).agc_driver_depth_expand_out_of_placefails with 103316e332's code reverted (run), and again with bfcd1839a8's reverted (run). With the code, the two expand tests pass 3 of 3, and in the second run so doagc_driver_graphics,agc_driver_bda_device,agc_driver_bda_span_readsandagc_sparse_buffer_holes. The libc and libkernel suites pass in every build.main8856f180ca, in WSL:ctest -R '^agc'at6596a1d3a2ran 558 tests, 0 failed, 40 skipped (the same 40 as onmain), and the two expand tests passed 10 of 10. Merged intomaind92a8dad39: 579 of 579 in two of three runs (41 skipped), the third failing onlyagc_driver_preparation_scope_settle, which also fails onmain. The full suite there: 1195 of 1201; the other 6 are 5 network tests that need IPv6, which the build VM lacks, and that flake.25594523ae(run): MinGW build, thenctest: 1,293 tests, 0 failed: 805 pass and 488 skip, all skips expected bycheck_skips.py.7809e9d443merged intomain8856f180ca, the tree of the head's merge commit (run): MinGW build, thenctest: 1267 tests, 0 failed, 475 skipped, all expected bycheck_skips.py.agc_driver_graphicspassed. The workflow carried the runner-image CA-bundle fix (CI only, no source change). The head itself built with MinGW in the sweep's Windows job (run), wherectest -R '^agc'ran 597 tests: 465 skipped, and 1 failed,agc_driver_pm4_replay_tool, which fails the same way onmain2e5dd5aa14in that job (the tool exits 0xc0000139 there). Windows runners have no Vulkan driver, so the expand execution tests are skip stubs there and ran on a GPU separately (next item).ANYPS5_REQUIRE_VULKAN=1with only the NVIDIA driver visible,ctest -R '^agc_driver_depth_expand_(out_of_place|review)$' --repeat until-fail:5.25594523ae:ctest -R '^agc_driver_depth_expand_(out_of_place|out_of_place_inline|review)$|^agc_driver_graphics$' --repeat until-fail:5passes all four 5 of 5. Every expand case holds 15360 of 15360 in every run: the Z_16 read base within one 16-bit step, and its 16-bit raw read and R16 UNORM texture read; the stencil-only and depth-and-stencil expands (7696 texels of 0x5a and 7664 of 0xa5); slice 1 of a depth array, with slice 0 keeping the CPU's bytes; and the queued-draw, two-write-base, in-place and always-pass cases.main8856f180caand the drain, merged with #5815's follow-up for one combined run, both pass 5 of 5. The four split cases printexpanded planes stored ahead of the copies: 1 (expected 1)and15360 of 15360, and the address-based storage-image read prints15360 of 15360 texels hold itfor both copies, through the cached address space and without it.a4137dc3f1) fixes a failure this PR had on that GPU. Ate252c03bc6,agc_driver_depth_expand_reviewfailed 3 of 3 withsecond expand: second read base: 15358 of 15360 texels hold the drawn depth.main23be5a02b, plus #5113 and #5111 (merged since; this change builds on both);[gpu] DB expand: the depth plane of 0x202a8a0000 (1920x2160) is written at 0x20298b0000and, once during boot,[gpu] DB expand: 0x202a8a0000 (1920x2160) has no depth surface; its guest bytes are written at 0x20298b0000;103316e332stores such a plane (above), and the split cases reproduce the game's case.25594523ae), 2026-10-15, onmain2e5dd5aa14with the local commits Resident Evil Village needs on this PC (the merge with this change is clean), withAPS5_LAZY_SHADER_PREPARE=1 APS5_HOST_IMPORT_MIB=6400 APS5_NO_GPL=1:89d7d879da, 2026-10-28, at first player control after Continue. Both trees aremain04fefebe90with #11580 merged locally and a local one-linescePadOpenchange for ports 3 and 4, one with this change and one without. EnvironmentAPS5_LAZY_SHADER_PREPARE=1 APS5_NO_GPL=1 APS5_HOST_IMPORT_MIB=6000, unprofiled, one boot each, clocks not held, 0.3–0.5 fps at the shot:without the change the scene at the "R Look" prompt is three out-of-focus glows. With it, the lamp, the pendant lights, the shelving and the lit lampshade in the foreground are drawn:
both expand forms log once each, as above; without the change neither logs;
Host memory: at first control, host heap 1 held 1,101 MiB beyond the 5,999 MiB of live host imports with this change, against 969 MiB without it. That's 132 MiB more, from one pair. Readings at a 6400 MiB import setting, taken at different points of the boot, put the gap at 110 to 280 MiB. The two places where this change stores pending results to guest memory (expand write bases, and the read ranges of address-based builds) stored 12 distinct images, 50.1 MiB, in a traced boot. The source of the rest isn't found yet;
At
APS5_HOST_IMPORT_MIB=6400: 2 of 5 boots with this change and 0 of 3 without it aborted in the intro. Each time, a host import failed atvkAllocateMemory(-2), and then a compute dispatch stopped on "AGC graphics: guest buffer has no GPU owner". That'smain's path for a failed host-import join, which a tighter heap reaches. The two traced boots with this change passed the intro.2c8eaec716,main11f976b27cmerged in, which brings #8099 (a stencil clear on a target without a stencil plane is ignored) and #8871. This PR movesdecodeDepth's target decoding intodepthTargetFor, and #8099 changed two lines of the olddecodeDepth. The merge applies #8099's two lines to this PR'sdecodeDepth:stencilClearis read only when the target has a stencil plane, and the writable-plane check no longer repeatsstencil. Main's other hunks merged unchanged. The PR's own diff differs from before the merge only in those two lines. On GitHub's runners:agc_driver_graphics, which holds #8099's case, and the depth expand, depth storage and depth clear tests pass 10 of 10 on Linux, none skipped. On Windows they build and pass, with 8 skipping without a Vulkan device. This PR's tests don't build againstmain's code, so the red is the one above.mainagainst this head (run), on one GitHub Linux runner: the loader insertedVK_LAYER_KHRONOS_validation6 times onmainand 12 with this PR, and neither log haswas not found. Both logs report the same two messages,VUID-VkDeviceCreateInfo-pNext-pNextandVUID-VkImageCreateInfo-samples-02258, so this PR adds noVUID-message.APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.dbaad7ace3,main0db47b263dmerged in, which brings #6946's draw finisher pipeline with its pipelined CB metadata pass.precheckDrawkeeps this PR's shared block for a metadata pass or a depth expand, and #6946's pipelined path runs inside it for metadata passes only. A depth expand still drains the queue and records inline, as before. Both includes are kept.agc_driver_pipelined_metadata_pass,agc_metadata_passand the draw pipeline trace tests pass 10 of 10 on Linux, none skipped. An^agcsweep on Linux passes (run).tests/execution,main'sagc_driver_pipelined_metadata_passandagc_driver_pipelined_metadata_pass_draw_pipeline(from #6946) fail atvkCreateInstance(-9) on GitHub's device-less runner, before this PR's code; upstream's Windows job builds them as skipped stubs. The rest build and pass there, with the Vulkan tests skipping.APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.python3 tools/check_conventions.py --base origin/main: passed.dd34282b4e,main44a59edc3amerged in, which brings #6682. One conflict, inGuestBufferMemory.cpp's upload loop, where both PRs add a flush after the regions are copied: this PR's depth expand stores and #6682's unit-shadow publish for address-based heaps. Both are kept, this PR's first. On GitHub's runners (run), of the depth expand tests,agc_metadata_passand #6682's unit-shadow tests, 33 pass 10 runs in a row on Linux and 3 of the unit-shadow tests skip there; on Windows 35 build, 27 pass 10 runs in a row, and 8 skip: those 3, and 5 that need a Vulkan device. The libc and libkernel suites pass on both, run withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.9f70521a8a,maine5ca7307cfmerged in, which brings #6292's draw-path locks. One conflict, inDepthSurface.cpp's includes: this branch'sGuestBufferMemory.hppandShaderResources.hppand #6292'sMutex.hpp, all kept. On GitHub's runners (run), of the depth expand tests,agc_metadata_passand #6682's unit-shadow tests, 33 pass 10 runs in a row on Linux and 3 of the unit-shadow tests skip there; on Windows 35 build, 27 pass 10 runs in a row, and 8 skip: those 3, and 5 that need a Vulkan device. The libc and libkernel suites pass on both, run withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.94c49deb18,mainc9b75825f3merged in, which brings #8999's DB depth copy draws (milescoviello). Four conflicts, each resolved by keeping both sides' changes:State.cpp: #8999 movesdecodeDepth's depth-plane decoding intodecodeDepthPlane. The expand's decoder now calls it too, and sets the clear values fromDB_DEPTH_CLEARandDB_STENCIL_CLEARafter it, asdecodeDepthdoes.DepthSurface.hpp: this PR's expand-pass declarations and #8999'sDepthCopySourceWordsandDepthCopySourceScope.CopyDepthSample, which #8999 removes, stays removed.VulkanDevice.hpp: this PR'sDepthExpandPass.VulkanDevice::DepthCopyPass, which #8999 removes, stays removed.DrawPrecheck.cpp: this PR'sindirectRecordsDrawcheck and #8999'sDepthCopyDraw.^agc_driver_depth_,^agc_driver_unit_shadow,^agc_unit_shadow), with the other tests built from the changed files: on Linux 60 run, 57 pass 10 runs in a row, 3 unit-shadow tests skip, 0 fail; the expand tests and #8999'sagc_driver_depth_copy_draware among the passes. On Windows 59 run, 29 pass 10 runs in a row and 30 skip without a Vulkan device, 0 fail. The libc and libkernel suites pass on both (142 and 204 tests on Linux, 169 and 217 on Windows), run withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.^agcsweep (run): Linux 981 run, 917 pass, 64 skip, 0 fail. Windows 1,005 run, 282 pass, 719 skip, 4 fail:agc_submit_progress,agc_submit_progress_no_timeline,agc_driver_pipelined_metadata_passandagc_driver_pipelined_metadata_pass_draw_pipeline, which also fail onmainc9b2660d56(run).main49d1f9b07eand built on Windows (Release, WinLibs), and the title ran for the full 112 s. Its log differed from amainrun only within run-to-run noise, with no error added or removed. The visual effect wasn't checked.94c49deb18merged cleanly ontomaincb78d89650and ran against thatmainon Arch Linux (kernel 7.2.8, Mesa 26.2.2, GCC 16.2.1), with RADV as the only ICD andVK_LAYER_KHRONOS_validationloaded in every Vulkan test. The depth tests andagc_driver_graphicsgive 41/41 with this PR and 38/38 onmainin each of three runs, the three depth expand tests included; the one skip, on both sides, isagc_driver_native_depth_bda_clear. Neither side logs aVUID-line. The full suite gives 2,347/2,348 with this PR and 2,344/2,345 onmain; the one failure on both isagc_driver_tessellation, RADV'snir_opt_varyingscrash from #5444.89d7d879da,main035ac96eddmerged in, which brings #9940 (compared host imports). One conflict, inGuestBufferMemory.cpp: this PR'sHostImportOverlapsand #9940'sComparedHostImportCoverswere both added right afterHostImportCovers, and both are kept. Nothing else conflicted, and this PR's changed lines are the same. On GitHub's runners (run), the depth, unit-shadow and host-import tests, with the other tests built from the files the merge changes, ran 10 times each. Linux: 845 run, 830 pass, 15 skip, 0 fail. Windows: 866 run, 741 pass, 125 skip, 0 fail. The libc and libkernel suites pass on both (145 and 210 on Linux, 174 and 231 on Windows), run withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.89d7d879daagainstmain035ac96edd(review): fresh builds of both from source, with Vulkan required, shader caching off andVK_LAYER_KHRONOS_validationloaded (the loader logs confirm it was inserted). This PR passes all 9 focused graphics and depth tests, andmainthe 6 they share, with no skips or failures; neither log has aVUIDmessage. The expand tests still check full 15,360/15,360-texel transfers through the covered read-back and address-based routes.9894ba7d14, oneandonlydean's merge ofmain88e804b0a7, which brings #9717 and #8395. The conflicts were inDrawPrecheck.cpp's includes (this PR's<algorithm>besidemain's secondDepthSurface.hppinclude) and the debt file, where this PR's "Out-of-place DB expand" entry sits beside #8395's reworded GS_FAST_LAUNCH entry; both sides are kept, and this PR's changed lines are the same. On GitHub's runners (run, on 2e1ec328ec, the same merge with those two includes in the other order), the depth, unit-shadow and host-import tests ran 10 times each. Linux: 44 run, 41 pass, 3 skip, 0 fail. Windows: 45 run, 2 pass, 43 skip, 0 fail. Suites: libc and libkernel pass on Linux (210 and 310) and on Windows (237 and 331). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners. TechLevelZero's NVIDIA bot ran this head merged ontomain88e804bon an RTX 2000 Ada (report): 2,555 passed, 6 failed, none new (3 also fail onmain, 3 unstable onmain), 45 skipped, with no new validation IDs (975 tests on the GPU).aca3cf0ca5, a merge ofmainb611e634f7(×10, everyagctest), which brings BunnyFl's #15855 (the sampled depth shadow allocated through the image allocator) and mrfelek's #15783 (moved read-only draw inputs kept within the draw snapshot cap).docs/dev/debt/libSceAgcDriver.md, where #15783 extends the "Draw input snapshots" entry next to this PR's "Pending storage-image results under the heaps of an address-based build" entry. The merge keeps both. The code merged without conflicts,DepthSurface.cppincluded, whichmain's #15300, #15301 and #15855 changed. This PR's diff overmainis unchanged.agc_driver_graphics. Linux: 56 run, 52 pass, 4 skip (agc_unit_shadow,agc_driver_unit_shadow,agc_driver_unit_shadow_budget,agc_host_import_sparse), 0 fail. Windows: 60 run, 4 pass, 56 skip (no Vulkan device), 0 fail. The libc and libkernel suites run 303 and 329 tests on Linux and 335 and 360 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.agctest, once: Linux: 1,336 run, 1,249 pass, 85 skip, 2 fail. Windows: 1,375 run, 412 pass, 963 skip (no Vulkan device), 0 fail. Both failures aremain's:agc_driver_image_gather_volume("the vertex shader was not emitted in the device's module form") fails the same way inmain's ownlinuxcheck on638187daec, the #15855 merge (job). JJenkx's #15875, merged afterb611e634f7, updates the test for the specialized vertex form #14265 emits.agc_driver_pipeline_journal's 120-second timeout (833/1336 Test #1431: agc_driver_pipeline_journal ***Timeout 120.32 sec),main's own cold run.aca3cf0ca5merged ontomain0eba5db30d, withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1:agc_driver_depth_expand_out_of_placepassed 2 of 9 runs andagc_driver_depth_expand_out_of_place_inline3 of 8. Each failure they read stopped in the same case, address-based buffer copies of a write base across an imported range and a heap-mirrored one: after the depth draw, the read base held 0 of 15,360 texels of the drawn depth. No host import failed, and noVUID-message appeared.main0eba5db30dwith and without the validation layer, and with another process holding 3.3 GB of device memory, and onmain0540ef0ef2;diag/6146-amd-split-mirrored(b272a98b22) withAPS5_TRACE_DEPTH_SYNC=1, 48 of them while another process held 3.3 GB and wrote 3.3 GB, then 9 GB, on the GPU. In all 80 the split cases hold 15,360 of 15,360 texels at the read base, the read base's depth surface is live at every step from the depth draw on, and no[depth-retire]or[depth-texture]line appears.maind23df92b38andVK_LAYER_KHRONOS_validation, the three expand tests, the six depth tests from the change request andagc_driver_graphicspass 10 of 10, with noVUID-message. Withmain'sDrawPrecheck.cpp, the three expand tests abort.VK_EXT_memory_budgetbudget for the device-local heap, and every later run 15,419 MiB. Holding device memory from another process didn't lower the budget the test sees, so what lowered it, and whether it relates to the failure, isn't known.aca3cf0ca5. If the failure comes back on that machine, they'll run the print build and post its log.aca3cf0ca5, both on Linux:mainb611e63(report): 2,872 passed, 10 failed, none new (9 also fail onmain, 1 unstable onmain), 60 skipped, with no new validation IDs (992 tests on the GPU). This PR's three expand tests,agc_driver_depth_expand_out_of_place,agc_driver_depth_expand_out_of_place_inlineandagc_driver_depth_expand_review, ran on the GPU with the validation layer and passed; being new, they aren't inmain's validation baseline.mainacac7c8(report): 2,890 passed, 6 failed, none new (3 also fail onmain, 3 unstable onmain), 55 skipped, with no new validation IDs (999 tests on the GPU). This PR's three expand tests,agc_driver_depth_expand_out_of_place,agc_driver_depth_expand_out_of_place_inlineandagc_driver_depth_expand_review, ran on the GPU with the validation layer and passed; being new, they aren't inmain's validation baseline.e85032327f, a merge ofmain090f57166a(×10, everyagctest).DepthMaintenanceRejectioninState.cpp, against stuart-russell's #16058, which narrows the maintenance bits to0x101c(depth and stencil copy, resummarize and decompress), so reserved DB_RENDER_CONTROL bits 14–31 no longer count. This PR didn't change that mask; it adds the out-of-place expand branch before it. The merge keeps this PR's branch first, then #16058's mask and its resummarize line, and this PR's diff in that function is now the five-line branch.DecodeDepthExpandPassstill refuses an out-of-place expand with any other DB_RENDER_CONTROL bit set, reserved bits 14–31 included, as onaca3cf0ca5, while #16058's maintenance check now ignores those bits.^agc_driver_depth_,^agc_driver_unit_shadow,^agc_unit_shadow,^agc_driver_host_importor^agc_host_import, withagc_driver_graphics. Linux: 56 run, 52 pass, 4 skip (agc_unit_shadow,agc_driver_unit_shadow,agc_driver_unit_shadow_budgetandagc_host_import_sparse), 0 fail;agc_driver_depth_expand_out_of_place,agc_driver_depth_expand_reviewandagc_driver_graphics, which has #16058's reserved-bit cases, pass 10 of 10. Windows: 60 run, 4 pass, 56 skip (no Vulkan device), 0 fail. The libc and libkernel suites run 327 and 344 tests on Linux and 358 and 371 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.agctest, once: Windows: 1,424 run, 424 pass, 1,000 skip, 0 fail. Linux: 1,385 run, 1,295 pass, 88 skip, 2 fail:agc_driver_image_depth24("image_load of 8_24_UNORM reads the wrong depth for format 141: 0x3effe004 for texel 0x007ff001") also fails onmain090f57166a's own tree (run), and adriadam10's #16807 has since fixed it onmain;agc_driver_sgpr_pattern_fill_keysfailed once in that 4-wide run ("the dispatch completed 513 times without a pending write over the keys"), then passed 3 of 3 run alone on this head (run) and onmain's tree (run).525ed87a85, a merge ofmaindd7c8de5de(×10).DrawPrecheck.cpp, where oneandonlydean's #17083 passesDrawPipeline::CommitKind::ColorMetadatato the colour-metadata pass'sEnqueue, the call whose capture this PR renames topass = *metadata. The merge keeps both:Enqueue(DrawPipeline::CommitKind::ColorMetadata, [this, localDevice, queueId, opcode, pass = *metadata] {. This PR's other newEnqueue, inDepthExpandReview.cpp's test helper, uses the overload without a kind, which #17083 keeps. This PR's other changed lines are the same, and the debt file differs in context only.^agc_driver_depth_,^agc_driver_unit_shadow,^agc_unit_shadow,^agc_driver_host_importor^agc_host_import, withagc_driver_graphicsandguest_font_graphics. Linux: 57 run, 53 pass, 4 skip (agc_unit_shadow,agc_driver_unit_shadow,agc_driver_unit_shadow_budgetandagc_host_import_sparse), 0 fail;agc_driver_depth_expand_out_of_place,agc_driver_depth_expand_out_of_place_inline,agc_driver_depth_expand_reviewandagc_driver_graphicspass 10 of 10. Windows: 61 run, 4 pass, 57 skip (no Vulkan device), 0 fail. The libc and libkernel suites run 344 and 346 tests on Linux and 375 and 373 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.e85032327fmerged with--no-ffontomainc2ea254d0d(clean), Windows 11 Home 10.0.26300, driver 32.0.16.2101, WinLibs GCC 15.2.0, Release,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, no validation layer. Of the tests matching^(agc_|shader|video_out|guest_video), 1,532 of 1,532 pass with this PR and 1,529 of 1,529 onmain, and the three new depth-expand tests pass.e85032327fagainst its merge basemain090f57166a. They builtagc_driver_graphics_tests,agc_driver_prepared_graphics_testsandagc_driver_prepared_unregistered_graphics_testson each side and ran their tests 3 times each withctest. Linux (Ubuntu 26.04.1, NVIDIA 615.71.09, GCC 15.2, Release): 52 tests. Windows (a Windows 11 VM, NVIDIA 582.78, WinLibs GCC 15.2 UCRT, Release): 50 tests. Every test passes 3 of 3 on both sides. This PR's three depth-expand tests aren't in that set.5fda38b35f, a merge ofmaine907e6d31b(×10, everyagctest).docs/dev/debt/libSceAgcDriver.md, against zaryabzip's #15868. #15868 replaces the oldsceAgcDriverGetHsOffchipParamentry with asceAgcDriverGetHsOffchipParam, sceAgcDriverSetHsOffchipParamentry further down, and this PR removes the stale "HTILE address of a depth array slice" entry on the next line. The merge drops both lines, so it keeps #15868's new entry and this PR's removal. This PR's changed lines are the same in all 14 files.main: since525ed87a85,mainbrought #13023, #15688, #15690, #15707 and #16373, which changeDepthSurface.cppand merged without conflicts, so this merge also ran everyagctest once.agc_unit_shadow,agc_driver_unit_shadow,agc_driver_unit_shadow_budgetandagc_host_import_sparse), 0 fail;agc_driver_depth_expand_out_of_place,agc_driver_depth_expand_out_of_place_inline,agc_driver_depth_expand_review,agc_driver_graphicsandguest_font_graphicspass 10 of 10. Windows: 61 run, 4 pass, 57 skip (no Vulkan device), 0 fail.agctest, once: Windows: 1,572 run, 478 pass, 1,094 skip (no Vulkan device), 0 fail. Linux: 1,529 run, 1,433 pass, 95 skip, 1 fail:agc_driver_frame_replay_busy_queue("the replay gave up pacing or released the compute queue while the graphics queue was still copying").mainwent red on that test with #12567, whiche907e6d31bincludes, and adriadam10's #17921 has since fixed it onmain.guest_kernel_resident_fmem_exportandguest_kernel_resident_fmem_export_patchedfail in both runs. The same harness fails them onmain7259cce111alone (run), andmain's own Windows job passes them, so they come from the verify harness, not this PR. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.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)Overlap: #6188 (draws compiled ahead of queue 0) rewrites most of
DrawPrecheck.cpp, includingprecheckDraw, where this PR runs the DB expand and the colour-metadata pass as one outcome. Whichever merges second carries the other's change: in #6188's design, aDepthExpandoutcome next toMetadataPass, decoded byDecodeDepthExpandPassand run by the executor after the drain. Without one, #6188's ahead classification gets the state-only refusal, so a merge that forgets the expand fails loudly instead of dropping it.#5925 (resolving ahead) guards only the colour-metadata branch of
precheckDrawwithresolvingAhead(). Here both passes share one block, soDrawPrecheck.cppconflicts there, and the guard belongs on that block's first line, where it covers both.#1395 (DB_RENDER_OVERRIDE depth copies) decodes other bits, so the two decodes don't overlap. If both merge, a draw with both takes the expand, and #1395's copy could write through this PR's plane views and pending notes so that its result reaches guest memory the same way.
#6682 (publish unit-shadow results before an address-based build maps its heaps) also adds a line at the end of
UploadFinishinGuestBufferMemory.cpp. Whichever merges second keeps both, with this PR'sStoreDepthExpandWritesfirst.Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-26T12:53:58Z.
Review: COMMENTED
Reviewed
94c49deb1801efefd7f2a421a8398bfc3d83b4acagainstc9b75825f383e16a85d1859c2a18061a3a7e9beb. Focused tests pass; no actionable finding in the tested paths. Final approval remains pending merge-conflict resolution.The changed decoder, ordered draw-precheck routing, depth/stencil plane copies and pending-write integration are consistent with the tested behavior. Unsupported layouts and states are explicitly refused, and the remaining console/coherence gaps stay documented in the debt note.
Validation: Built both exact revisions with matching third-party commit pins on Windows, NVIDIA GeForce RTX 5070 Ti, driver 616.92. The PR passes 9/9 focused tests with zero skips: graphics, depth clear HLE, out-of-place depth expand, depth expand review, fast clear, HTILE write, plane sampling, depth storage and the inline depth-expand variant. The base passes all 6/6 common tests with zero skips. Both runs require Vulkan, disable shader caching and load VK_LAYER_KHRONOS_validation 1.4.363; loader logs confirm insertion. Neither log contains a VUID- message, so the PR adds none in this comparison. The expand cases verify complete 15360/15360 transfers across direct/indirect, raw/address-based and other covered routes. Source conventions and whitespace checks pass.
Scope: Real source-built NVIDIA Vulkan execution; no full repository suite, AMD/RADV run, game/console test, performance claim or independently rerun mutation control. GitHub now reports merge conflicts on this unchanged head. Resolve them and validate the resulting revision before final approval; the successful pinned-head tests above do not establish the result of a future conflict resolution.
Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-26T18:54:20Z.
Review: APPROVED
Reviewed
89d7d879da49f7a6026d7dfb1880ea8af3d88244against035ac96edd092773a5ba0131453de80084a23533. Approve; the conflict blocking my earlier review is resolved.The merge retains both this PR's
HostImportOverlapsand main'sComparedHostImportCovers. I checked the combined merge diff and the ordered expand/write-back integration, then rebuilt the updated source rather than carrying forward the old-head test result.Validation: Fresh exact-source Windows builds with verified matching third-party pins. On NVIDIA RTX 5070 Ti, the candidate passes all 9 focused graphics/depth tests; the base passes all 6 common tests, with zero skips or failures. Both runs require Vulkan, disable shader caching and load
VK_LAYER_KHRONOS_validation; loader logs confirm actual insertion, and neither log contains a VUID message. The expand tests still verify complete 15,360/15,360-texel transfers through the covered read-back and address-based routes.This supersedes the earlier conflict-pending comment. Validation covers the focused modeled behavior; no new game, AMD/RADV, performance or console measurement is claimed. Documented coherence and unsupported-layout limits remain.
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-05T01:54:25Z.
Review: CHANGES_REQUESTED
@EagleBearerYS one finding from a Windows run on AMD, which the runs so far don't cover (NVIDIA on Windows, RADV and lavapipe on Linux).
Confirmed (P2):
split-mirrored-buffer-readfails on Windows with an RX 9070 XTSetup: head
aca3cf0ca5merged ontomain0eba5db30d(clean merge), Windows 11, WinLibs GCC, Release,BUILD_TESTING=ON, AMD Radeon RX 9070 XT (AMD Software 26.10.2, Vulkan driver 2.0.416),ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, test executables rebuilt before each set.agc_driver_depth_expand_out_of_placeagc_driver_depth_expand_out_of_place_inlineEvery failure whose output I read stops in the same case, at the test's own check of the depth draw (
core/libs/prx/libSceAgcDriver/tests/execution/DepthExpandOutOfPlace.cpp:490), before the write base is compared:In the passing
_inlineruns the same case, with the same addresses, prints15360 of 15360for both the read base and the copy of the write base. Every case before it in the failing runs holds 15360 of 15360. No host import failed in these runs (failed 0in the shutdown line), and the validation layer reports noVUID-message in any of them.I haven't found the cause. In the log above, the texture read of the read base (
DrawnDepth,core/libs/prx/libSceAgcDriver/tests/execution/DepthExpandOutOfPlace.cpp:489-490), made after this case's address-based copies, returns zeros. Presumably something between the depth draw and that read loses the depth surface's contents, or the read takes another image; I haven't confirmed which. I can't tell from these logs whether that is this PR's new stores inUploadFinish(the expanded planes and the read-only V# results) acting on the heap mirror, or amainpath the case's layout reaches. Happy to run a build with extra prints if that helps.What else I ran (same machine and merge)
agc_driver_depth_expand_reviewpasses in every run. The six depth neighbours (agc_driver_depth_storage,_clear_hle,_fast_clear,_plane_sampling,_htile_write,_copy_draw) andagc_driver_graphicspass 7 of 7 on the merge and onmain0eba5db30d, withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: neither log has a missing-layer line or aVUID-message.main'sDrawPrecheck.cpp, all three expand tests abort.check_conventions.py: passes.pr_overlap.py --branch: line conflicts only with #12944 (a member added afterwritesinGuestBufferMemory.hpp, next to this PR'sreads) and #15868 (the debt entry below the HTILE slice entry this PR removes); both are adjacent-line edits.DepthSurface*comparison is guarded bywritten, which comes from the global++depthWritescounter at creation (core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:965) and on every write, andreadshas the same lifetime aswrites. No findings there.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-05T13:59:00Z.
Review: APPROVED
@EagleBearerYS thanks for the print build. I'm withdrawing my change request: I can't reproduce the
split-mirrored-buffer-readfailure any more, on the same machine, driver and trees, and I don't think an unexplained failure I can't repeat should hold the PR back.What I ran today
All on the same Windows 11 machine and RX 9070 XT, with the same AMD driver as the failing runs (32.0.32015.12012),
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, test executables and libraries rebuilt for each tree. Each row is 8 runs ofagc_driver_depth_expand_out_of_placeplus 8 ofagc_driver_depth_expand_out_of_place_inline:diag/6146-amd-split-mirrored(b272a98b22) onmain0eba5db30d,APS5_TRACE_DEPTH_SYNC=1aca3cf0ca5onmain0eba5db30d(the failing runs' base)0eba5db30dmain0540ef0ef2In all 80 diag runs the split cases print 15360 of 15360 at the read base, the read base's depth surface is live at every
[step]from the depth draw on (the three steps before the draw printnone, as expected), and no[depth-retire]or[depth-texture]line appears.Then the gated run on today's
maind23df92b38, withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: the three expand tests, the six depth neighbours from my review andagc_driver_graphicspass, 10 of 10. Neither log has a missing-layer line or aVUID-message. Withmain'sDrawPrecheck.cppthe three expand tests abort and the other seven pass.check_conventions.pypasses.pr_overlap.py --branchfinds only shared lines, no shared exports, with #12944 (GuestBufferMemory.hpp), #15868 (the debt file), #16025 (DepthSurface.hpp) and #16058 (State.cpp); I haven't checked each of those against this PR line by line.The one difference I found
The failing logs from my review report
VK_EXT_memory_budget budget of 12004 MiBfor the device-local heap; every run today reports 15419 MiB. I compared one failing log line by line with a passing one from today: apart from addresses, timings and that budget line, they match up to the split-mirrored case. I tried to recreate the lower budget by holding device memory from another process (the 3.3 GB and 9 GB rows above), but the budget the test sees stayed at 15419 MiB, so I don't know what lowered it that night, and I haven't shown that the budget is related to the failure at all.If the failure comes back on this machine, I'll run your diag build straight away and post the log you asked for.
Approving at
aca3cf0ca5.AI-assisted: yes (Claude Code)