Repository navigation
Conversation
A T# that views one layer of a 2D array (BASE_ARRAY = LAST_ARRAY = N) used to build a storage image of layers 0..N. Writes to each layer then made overlapping images that flushed and re-uploaded each other on every dispatch. Storage lookups now widen a 2D array to the largest layer seen for its surface, bind views over the requested layers, and refresh and mark dirty only those layers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
StorageSurface held the ExtendedChains mutex while StorageArraySurface locked it again, which deadlocks a storage lookup of a 2D array once any mip chain was extended. A write through a 2D shape of an array now marks only its first slice dirty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The widest slice seen for a storage array is kept only while the registered guest range holding its base keeps the same backing, and a view is widened only when the wider image ends inside that range. A shorter array placed at the address of an earlier, longer one no longer builds the longer image. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g its last slice Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CachedStorageSurface and CachedStorageLayers no longer widen a 2D array to the largest slice a storage view named, so AliasCopy, resolves and color targets get an image of exactly the slices they ask for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The main merge kept both sides of the libSceAgcDriver debt conflict; main's measured entry stays.
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 compute shader that writes one layer of a 2D array at a time, through a T# with
BASE_ARRAY = LAST_ARRAY = N, made a separate storage image per layer: the lookup of layer N built an image of layers 0..N (the T# names N as its last layer, not the array size). The images overlap, so every dispatch flushed the previous one's pending results and uploaded its own again (storage refreshwrite-backs). DEATHLOOP (PPSA01670) does this every frame on a 960x540 4-layer array.StorageArraySurface(inStorageSurface): a storage view of a thin 2D array without DCC, FMASK/CMASK or MSAA is served by one image of slices 0 to the largest last slice any view of that surface has named, the wayStorageSurfacealready widens mip chains. It falls back to the view itself when the widened geometry would move the viewed slices.RefreshLayers). The binding gets a view of those slices:StorageView,AtomicView,Atomic64View,ViewandFirstLayerViewtake a layer window, and their view caches are keyed by it. A write marks only those slices dirty (MarkSliceDirty); a write through a 2D shape marks only the window's first slice.agc_driver_storage_array_layers: three rounds of per-layerimage_stores into a 4-layer array. After the first round one pending image holds all four layers, later rounds reuse it, and every layer holds its own values after the flush. It then registers the same address again as a 2-layer allocation and repeats the rounds there: the pending image holds layers 0..1, not the 0..3 of the earlier array, and layers 2 and 3 stay untouched. Before that it repeats the rounds as a 2-layer array at the same address without touching the allocation (samebackingSerial), with the same expectations. Last, it extends a storage mip chain (which switchesStorageSurfaceto its locked path) and repeats the rounds on another array. Onmainit fails with the pending image of the 4-layer array not holding every layer; oncdfc7a986fit fails with "the pending image of the 2-layer array holds layers 0..3", and oncd720c71a4it fails the same way in the unchanged-allocation case.backingSerial, renewed by a new mapping or a protection change), and a view is widened only when the wider image ends inside that range; memory in no registered range is never widened.CachedStorageSurface,CachedStorageLayers) are never widened:AliasCopybuilds its destination withCachedStorageSurfaceand refuses a copy whose shapes differ, so a widened image there threw "an image copy its check allowed was refused: shape" (found by ahmadmuj).agc_driver_storage_array_layersnow also stores into all four layers and then asks both for layers 0..1 at the same address; withShaderResources.cppat53e11f112bit fails with "a copy destination of layers 0..1 got layers 0..3".Related: boykopovar#6202 refreshes only the layers a color target covers; this PR is about storage writes and does not touch the color-target path.
Tested
Head
6d750b25ad(mainb611e634f7merged; the conflict was fix(agc): bind UINT views for float16 stores outside compute shaders boykopovar/AnyPS5#15741's storage descriptor writes inShaderResources.cpp, which now pick UINT storage views withShaderRecompiler::RuntimeAbi::UintStorageImageBinding(binding.layout.binding)instead of the binding 7 to 13 range test. Both writes keep that call and pass this PR'sstorageLayers[index]toAtomic64View,AtomicViewandStorageView). Windows, same machine as below:ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R "^agc.*(array_layer|image_store|storage|depth_plane|image_atomic|image_table|alias_copy|dcc_keys_first_write|copied_writer|clear_hand)" -E usb -V, 3 runs: 96 of 96 pass each time, includingagc_driver_storage_array_layers, 0VUID-, no missing-layer message. Linux (WSL Ubuntu, GCC, tree reconfigured at this head):libsand the tests build; the samectestset, 3 runs: 94 of 94 pass each time, 92 of them skipped (exit 77, no Vulkan driver in WSL).check_conventionspasses.Head
72ac10a202(main1c8c0efc8cmerged; the conflict was incachedStorageTexture, wheremain(perf(agc): hand pending results over to storage images created under clear keys boykopovar/AnyPS5#14868) now detaches a storage image whose metadata moved and hands it toStorageTexture::PrepareCreationinstead of flushing it. The merge keeps this PR's layer-narrowing lookup and widening eviction, detaches asmaindoes, and hands over only an image detached at the key that is finally created: one detached at a wider key, or before narrower images are evicted for widening, is flushed first, as this PR did before). Windows, same machine as below:ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R "^agc.*(array_layer|image_store|storage|depth_plane|image_atomic|image_table|alias_copy|dcc_keys_first_write|copied_writer|clear_hand)" -E usb -V, 3 runs: 90 of 90 pass each time, includingagc_driver_storage_array_layersandagc_storage_clear_hand_over, 0VUID-, no missing-layer message. Linux (WSL Ubuntu, GCC):libsandagc_driver_storage_array_layers_testsbuild; the test is skipped (exit 77), no Vulkan driver in WSL.check_conventionspasses.Head
7d2be0318b:mainwas merged in, with perf(agc): wait on a flush only for writers over the image layers it stores boykopovar/AnyPS5#8887 and feat(agc): sample 1D arrays past maxImageArrayLayers as rows of a 2D image boykopovar/AnyPS5#12246.Texture.hppkeepsappendStoredLayersfrommainnext to this PR'screateView(..., LayerWindow layers = {}); the debt file keeps both the 1D-array entry and the storage array widening entry. The 81 focused AGC tests (^agc.*(array_layer|image_store|storage|depth_plane|image_atomic|image_table|alias_copy|dcc_keys_first_write|copied_writer)) pass three runs in a row on Windows (MinGW, GCC 15.2) withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: noVUID-errors and the layer was found. On Linux (WSL, GCC) they build and 79 pass three runs in a row, but 77 of those skip there, so Linux exercises only 2 of them.check_conventionspasses.Head
8be6c1abe8(mainbb04a4f1eamerged; no textual conflict, butmain's newRepeatStorageSurfacecalledStorageSurface(context, viewed), which this PR gives awidenArrayparameter, so the merge did not build, as the NVIDIA GPU test reported. It now passesfalse, asCachedStorageSurface, the lookup it repeats, does). Windows, same machine as below:ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R "^agc" -V, 3 runs: 1151 of 1151 pass each time, no missing-layer message; each run logs 18VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605, all fromagc_driver_prepared_exportsandagc_driver_srgb8_color_target, andmainbb04a4f1ealogs the same 18 in those two tests, so this PR adds none. Linux (WSL Ubuntu, GCC, tree reconfigured at this head): builds;ctest -R "array_layer|image_store|storage|depth_plane|image_atomic|image_table|alias_copy|dcc_keys_first_write|copied_writer" -E usb, 3 runs: 75 of 75 pass each time, 74 of them skipped (exit 77, no Vulkan driver in WSL), includingagc_driver_storage_array_layers.check_conventionspasses.Head
924af40153(main81267b2204merged; the conflict was boykopovar#8998's UINT storage views for bindings 7 to 13 against this PR's layer window:StorageTexture::StorageViewnow takes both,(mip, firstLayer, uintStorage, layers), keeps boykopovar#8998's format choice, and the two storage descriptor writes inShaderResources.cpppass boykopovar#8998's binding test and this PR's layer window). Windows, same machine as below:ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R "array_layer|image_store|storage|depth_plane|image_atomic|image_table|alias_copy|dcc_keys_first_write|copied_writer" -E usb -V, 3 runs: 72 of 72 pass each time,agc_driver_storage_array_layerspasses, 0VUID-, no missing-layer message. Linux (WSL Ubuntu, GCC): builds;agc_driver_storage_array_layersis skipped (exit 77) in 3 runs, no Vulkan driver in WSL.check_conventionspasses.Head
e1ee11a812(main9c6d153decmerged after boykopovar#9961 landed; the only conflict was the libSceAgcDriver debt file, where boykopovar#9961's new sampled-array-window entry is kept and this PR's storage-widening entry follows it; no code conflict). Windows, same machine as below:ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R "array_layer|image_store|storage|depth_plane|image_atomic|image_table|alias_copy|dcc_keys_first_write|copied_writer" -E usb -V, 3 runs: 68 of 69 pass each time,agc_driver_storage_array_layerspasses, 0VUID-, no missing-layer message; the failure isagc_driver_depth_plane_partial_store(boykopovar#10664), which fails onmaintoo. Linux (WSL): these tests need a Vulkan device and WSL has none, so they skip (exit 77).Head
09450f2499(90ac083960plus a test-only change that prints the base slice in the failure messages;agc_driver_storage_array_layersrerun 3 times at09450f2499on Windows with validation: passes, 0VUID-; on Linux: skipped, exit 77). The set below ran at90ac083960, on53e11f112b, same machine as below.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R "array_layer|image_store|storage|depth_plane|image_atomic|image_table|alias_copy|dcc_keys_first_write|copied_writer" -E usb -V, 3 runs: 68 of 69 pass each time, 0VUID-, no missing-layer message; the failure is againagc_driver_depth_plane_partial_store, as onmain. Linux (WSL Ubuntu, GCC): builds;agc_driver_storage_array_layers,agc_driver_alias_copy_labelandagc_driver_dcc_keys_first_writeare skipped (exit 77) in 3 runs because WSL has no Vulkan driver.check_conventionspasses.Head
53e11f112b(main16ff208dc3merged after boykopovar#10440 landed; inShaderResources.cppthe storage descriptor now picks boykopovar#10440'sAtomic64Viewfor 64-bit atomics and passes this PR's layer window to all three views), same machine as below.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R "array_layer|image_store|storage|depth_plane" -V, 3 runs: 53 of 54 pass each time, 0VUID-, no missing-layer message; the failure isagc_driver_depth_plane_partial_store, which fails the same way onmain16ff208dc3(1 of 53 failed there, 0VUID-, no missing-layer message). Linux (WSL Ubuntu, GCC): builds;agc_driver_storage_array_layersis skipped (exit 77) in 3 runs, no Vulkan driver in WSL.check_conventionspasses.Head
ec41941094onmain2dc85609fc, same machine as below.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R "array_layer|image_store|storage|depth_plane" -V, 3 runs: 53 of 54 pass each time, 0VUID-, no missing-layer message; the failure is againagc_driver_depth_plane_partial_store, as onmain.agc_driver_storage_array_layerswith onlyShaderResources.cppreverted tocd720c71a4fails with "the pending image of the 2-layer array holds layers 0..3". Linux (WSL Ubuntu, GCC): builds;agc_driver_storage_array_layersis skipped (exit 77) in 3 runs because WSL has no Vulkan driver.check_conventionspasses. The DEATHLOOP flush count below is fromcdfc7a986fand was not rerun at this head.Earlier heads:
Windows 11 Pro 26200, AMD Ryzen 7 9700X, NVIDIA GeForce RTX 5070 Ti (driver 616.64), WinLibs GCC, Release. Head
cd720c71a4onmain2dc85609fc.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R "array_layer|image_store|storage|depth_plane" -V, 3 runs atcd720c71a4: 53 of 54 pass each time, 0VUID-, no missing-layer message. The failure isagc_driver_depth_plane_partial_store("repeated lookups of the first layer of an unchanged array proved no refresh"), which fails the same way onmain2fade7ef4eon this machine. On thatmainthe same set also failsagc_driver_storage_array_layers, and logs 0VUID-.ctestatcdfc7a986f(before the allocation bound): 2182 tests; failuresagc_driver_depth_plane_partial_storeandagc_host_import_cut_lifetime(both fail the same way onmain2fade7ef4ehere) andselect_tests(a temp-directory symlink error intools/tests/test_select_tests.py).tools/check_conventions.py --base origin/main: passes.cd720c71a4: builds;agc_driver_storage_array_layersis skipped (exit 77) in 3 runs because WSL has no Vulkan driver, so the GPU path is covered only by the Windows runs.DEATHLOOP (PPSA01670), same machine, behaviour count only (no speed or traffic claim).
maincannot reach this scene yet, so both builds aremain+ boykopovar#10414 + boykopovar#10507 + a port of boykopovar#6192, one without and one with this PR: basefa00d49312, changed26dce2835(this PR's headcdfc7a986fcherry-picked). Same scripted input (PSN dialog and brightness calibration screens), run withAPS5_TRACE_FLUSH=1: the base build logs about 1050storage refreshflushes of each of the four overlapping images of the 0x26a7200000 array in that flush log; the change logs none for it. What remains comes from 2D T#s at the address of each slice of a 2-layer array that the title also reads as an array (in the debt entry). Alternated base/change captures showed no frame-time difference beyond run-to-run noise, so this PR makes no performance claim.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)