fix(agc): make a new storage image when the DCC keys at its key address change pipe alignment #28468
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28468"
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 zeezey on 2026-11-30T21:07:54Z.
What
The storage image cache finds an image by its surface key (address with the pipe and bank XOR, extent, mip count, array layers, dimension, tile mode, base array and storage format). When the descriptor names DCC keys, it then checks only their address (
MetadataMovedinShaderResources.cpp), so it reused an image for keys at the same address whatever their pipe alignment.The alignment decides how many keys the image marks uncompressed after a write.
DccKeyCountgives pipe-aligned SW_64KB_R_X keys of a one-mip, one-layer 4-byte surface the console's metadata extent: 4096 keys for a 128x128 surface. Other keys get one per 256 bytes: 256 for that surface. So at the same address:Both ways in take this lookup: guest storage images (
META_PIPE_ALIGNED, texture descriptor word 6 bit 19) and resident color targets (DCC_PIPE_ALIGNED,CB_COLOR_ATTRIB3bit 30). It takes keys at one address whose pipe alignment changes between uses of a surface with the same key, as when memory is reused for another surface of the same size, format and tile mode.This was found while writing the tests of #28350, the DCC keys change that follows #28311. One of its tests shared a target and a key block between pipe-aligned and unaligned keys, and the bytes after the unaligned keys changed. That test now uses separate memory; this PR fixes the cause on
main.Two commits:
fix(agc): make a new storage image when the DCC keys at its key address change pipe alignment.MetadataMovedalso counts keys at the image's key address with the other pipe alignment as moved. Its callers then treat the image as they already treat one whose keys moved to another address:cachedStorageTexture) detaches the image and makes a new one from the descriptor. The results still pending in the old image are stored by the existing creation path (StorageTexture::PrepareCreation) before the new image uploads.RepeatStorageSurface(the shape memo) returns no image, and the draw takes that lookup.pendingLookupSource) no longer copies from a pending image made for the other alignment. The pending results are stored to guest memory first, by the storage lookup in host-imported memory or by the read'sFlushPendingotherwise.StorageImageServesKeystakes only a key address. It gives the same answers as before, since it now passes the image's own alignment. Its callers are the attachment memo, draw recipes, the sampled texture cache hit, and the cached resource set's revalidation and own-image refresh.Those memos miss when the alignment changes, so the draw or dispatch reaches the storage lookup:
sameColorTargetincludesdccPipeAligned);CB_COLOR_ATTRIB3;META_PIPE_ALIGNED.The check does not ask whether the alignment changes the key count, so a surface whose uses disagree on the alignment from one use to the next stores its image and makes a new one at each change. That includes surfaces whose key count is the same either way (other tile modes, formats, mips or layers) and read-only samples.
Unchanged: an image whose keys are at another address still serves a descriptor whose keys read uncompressed there, whatever their alignment; it marks only its own keys (as on
main, that read counts the other address's keys with the image's own alignment).test(agc): reuse one surface and key block while the DCC keys change pipe alignment, tests only. The newagc_driver_dcc_key_pipe_alignmentkeeps one 128x128 DCC 8_8_8_8 UNORM SW_64KB_R_X surface and one key block while the keys' pipe alignment changes between steps. It runs two orders, pipe-aligned first and unaligned first:APS5_NO_RESIDENT_TARGETS) marks its own range;Its fragment also registers the draw-pipeline and plan-verify runs (
agc_add_draw_pipeline_test) and anAPS5_NO_HOST_IMPORT=1run, so the sampled step's snapshot path is covered as well.On
mainwithout the fix, all four fail with the same eight failures in every run: step 2 of each order of draws and of dispatches, in both kinds of memory. Pipe-aligned first fails withchanged 3840 of the 7936 bytes after its 256 DCC keys; unaligned first fails with256 of its 4096 DCC keys are uncompressed. Each failing order stops at that step. The two sample cases pass onmain: they guard the sampled-read change and do not reproduce the bug.No new switch.
Overlaps (
tools/pr_overlap.py --branch):ShaderResources.cpp, 673-676 and 2333-2335 on the newestmain(76d0a4a7dc). It removesMetadataMoved, addsStorageImageServesMetadata, which compares the keys' alpha placement, and makesStorageImageServesKeyscheck the address only.StorageImageServesKeystake the address and the alpha placement, and checks the alpha placement beside eachMetadataMovedcall. It now conflicts withmain, so the tool cannot compare it; its diff changes the same lines.The tool could not compare 41 other open pull requests that share
ShaderResources.cppbut conflict withmain; their diffs were searched forMetadataMoved,StorageImageServesKeys,ServesKeysAtanddccPipeAligned. Three only move or reshape calls of the two functions and keep their meaning: #10743, #12575 and #22647.#28198 and #28118 both add the keys' alpha placement to the identity this PR adds the pipe alignment to, and each conflicts textually with this branch only there. Whichever lands later rebases. On #28198 the alignment check moves into
StorageImageServesMetadata. On #28118,StorageImageServesKeyshas to keep setting the image's own alignment on the resource it builds, or a pipe-aligned image stops serving its own keys and the memos above miss silently.Tested
No title was booted. The branch is these two commits on
main2af8e79edf;mainbelow is2af8e79edfitself, built the same way on the same machine. Thatmainincludes #13796 (44c4996fc5), which changesSurfaceKeyand the image creation incachedStorageTexture(the storage image's dimension) and the layered views, not the lines this PR changes; the fix was built and tested on top of it. The branch also merges into the newestmain(76d0a4a7dc) without conflicts.Windows 11 Pro 10.0.26300, Intel Core i7-14700K, NVIDIA GeForce RTX 4090 (driver 621.24), Vulkan validation layer 1.4.363. Every Windows run used
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layerandctest -Vwith no output size limit. Other agents' builds ran on the machine at the same time.The bug on
main:mainwith only the test commit, the four new tests 20 times in a row on Windows (one test at a time): 0 of 20 runs passed, all four tests failing in every run as described above (changed 3840 of the 7936 bytes after its 256 DCC keysand256 of its 4096 DCC keys are uncompressed). With the fix: 20 of 20 runs passed on Windows and 20 of 20 on Linux (WSL 2, lavapipe; environment below), the layer inserted in all 80 test runs on each, noVUID-. In these repeats the slowest test took 0.8 s on Windows and 3.2 s on Linux.Complete
ctest, Windows (--parallel 8, no filter, compared test by test from the JUnit output):VUID-SYNC-HAZARDmainThe branch adds the 4 new tests, which pass (about 1 s each). No other test differs; no failure on either side.
The area, Windows: the 344
agc_tests of DCC keys, storage, clears, resident and color targets, sampled reads, blends, merges, packed formats, pixel interlock, image stores, fill covers, draw recipes, attachments and surfaces, withagc_driver_graphicsand the new tests, once (--parallel 4): 341 passed, 3 skipped (agc_driver_msaa_dcc_compared_import_2,_4,_8), none failed, noVUID-. Linux: the same set (345 tests there, run once): 314 passed, 31 skipped, none failed.Switches, Windows: the area set once under each switch the changed lookups read:
APS5_NO_TEXTURE_CACHE,APS5_NO_TEXTURE_HASH,APS5_NO_CLEAR_HAND_OVER,APS5_NO_RESIDENT_TARGETS,APS5_NO_SAMPLED_FROM_STORAGE,APS5_NO_STORAGE_DEDUPE,APS5_NO_OWN_IMAGE_REFRESH,APS5_NO_TARGET_MEMO,APS5_NO_SHAPE_MEMO,APS5_VERIFY_SHAPE_MEMO,APS5_NO_DRAW_RECIPE,APS5_DRAW_PIPELINEwithAPS5_NO_PASS_ATTACHMENT_MEMO,APS5_CPU_DCC_KEYS,APS5_NO_KEY_FAST_PATH,APS5_NO_HOST_IMPORTandAPS5_NO_KEEP_NEW_STORAGE, each=1. The four new tests pass under every one. Every test that failed on the branch was run onmainunder the same switch and fails there too:mainAPS5_NO_TEXTURE_CACHEAPS5_NO_RESIDENT_TARGETSAPS5_NO_HOST_IMPORTAPS5_NO_DRAW_RECIPEAPS5_NO_SAMPLED_FROM_STORAGEAPS5_NO_TARGET_MEMOAPS5_NO_KEY_FAST_PATHAPS5_DRAW_PIPELINE+APS5_NO_PASS_ATTACHMENT_MEMOAPS5_CPU_DCC_KEYSAcross the 16 runs the layer was inserted in 5,136 of 5,504 test runs, with no
VUID-,SYNC-HAZARDor "was not found". CI runs the suite without these switches, apart from single tests registered with one (such as this PR's_draw_pipelineand_no_host_importruns).Linux: WSL 2 (Ubuntu 24.04 userland), llvmpipe (LLVM 20.1.2, Mesa 25.2.8), g++ 13.3, validation layer 1.4.335, the same environment plus
VK_LAYER_PATH; completectest(--parallel 4, no filter; the layer counts from thectest -Vlogs):VUID-mainThe 4 new tests pass and the same 220 tests skip. The 8 failures are the same on both sides; on
maineach was run five more times alone: seven fail every time (agc_driver_depth_fewer_samples,agc_driver_gcn_multisample_color_fill,agc_driver_image_d16_load,agc_driver_image_filter_mode_three,agc_driver_flat_aperture_lds_bounds,agc_driver_upload_cache_read_only_flush,agc_driver_write_back_guest_newer), andagc_driver_msaa_resolve_publication_orderpassed 3 of 5 (flaky).NVIDIA gate (
tools/vulkan_validation_gate.py,main2af8e79edfagainst this commit,--gpu NVIDIA --repeat 5, RTX 4090): 238 tests of the area (DCC keys, storage and sampled caches, color, linear, depth and MSAA targets, packed formats, image stores and loads, cold DCC textures, resident targets, draw recipes and their variants), alternating 5 runs on each side: 2,380 test runs, 0 failed, 0 skipped, the layer inserted in every run, noVUID-orSYNC-HAZARDon either side and no new diagnostic. Both sides log the sameUndefined-Value-ShaderOutputNotConsumed-DynamicRendering(165 messages per side, from the same 4 tests in each of the 5 runs) andVALIDATION-SETTINGS(once per run, 5 in all). Status complete, exit 0. The new tests are not in it, since the gate compares tests that both sides have; they ran with the validation layer in the complete suites and the repeats, with noVUID-.tools/check_conventions.pywith this title and body: passed.tools/debt_fold.py --check: passed.Checklist
main2af8e79edfand merges cleanly into currentmain76d0a4a7dc(see Tested); 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
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T21:10:33Z.
Review: APPROVED
Reviewed — looks good
The change treats pipe alignment as part of storage-image reuse at the same DCC key address, and the added tests exercise draw, dispatch, and sampled-read paths.
What I ran
Reviewed head
e674481f5cbab7e2ecc9df4039439aa5ebea11fa. I inspected the prepared diff and included files, then usedrepo_read.pyfor the changed source hunks, affected callers, andServesKeysAtimplementation. I did not run tests or builds; the test results in the PR description are author-reported.Commands used:
Results
Negative control
Not run; no tests were run in this review.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
ShaderResources.cppwas read at the changed hunks and relevant callers, not in full. The two test files were read in full.files.jsonlists three reviewed files and no excluded files. Runtime behavior, console behavior, and the author-reported test results were not independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T21:19:30Z.
Review: COMMENTED
Actionable comments posted: 1
64e6c086-a3d5-4118-b17c-354e42246e1cReviewing files that changed from the base of the PR and between
76d0a4a7dcande674481f5c.core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_dcc_key_pipe_alignment_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/DccKeyPipeAlignment.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T10:40:44Z.
Review: APPROVED
I read the diff at
e674481f5c. Windows 11, GCC 15.2, merged intomainatb97867d3ce6together with other open PRs (so not an isolated build), withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1andVK_LAYER_KHRONOS_validationon an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).agc_driver_dcc_key_pipe_alignmenttests: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has aVUID-orSYNC-HAZARDline.main's): all four fail on both GPUs, for example "256 of its 4096 DCC keys are uncompressed".Not checked: a title.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T11:58:00Z.
Review: COMMENTED
Ran the shared
agc_driver_gcn_scalar_buffer_basetest on main and the patched tree on the same Linux llvmpipe device with Vulkan required, shader cache disabled, and validation layer 1.4.369. It passed on both trees. The loader inserted the layer and neither log reported a missing layer or aVUID-entry. The patch also passedagc_driver_dcc_key_pipe_alignmentand its no-host-import variant with the same validation settings.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.