fix(agc): serve views of arrays past maxImageArrayLayers from their viewed slices #6772
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6772"
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 XairRrR on 2026-10-16T11:22:52Z.
What
A PS5 texture array may hold up to 8192 layers; Vulkan devices allow fewer (
maxImageArrayLayersis 2048 on NVIDIA). A storage view of such an array created the whole array's image anyway:vkCreateImagewith more layers than the device allows is invalid (VUID-VkImageCreateInfo-arrayLayers-02256), and a shader store into a layer the device did not back faults the GPU.Uncharted: Legacy of Thieves Collection (PPSA05684, #4001) binds a 16x16
R8G8B8A8_UNORMarray (kStandard64KB, 2 mips) of up to 7809 layers as a storage image, in windows of a few hundred to 2048 slices (for example layers 1536..3200, created as a 3201-layer image). A few minutes into its orphanage chapter the device was lost:Xid 109 CTX SWITCH TIMEOUT, thenVK_EXT_device_faultreportedwrite invalidat a page-aligned address. The validation layer named the cause (arrayLayers (3201) exceeds the maxArrayLayers (2048)).ArrayLayerWindow(TextureTiling.cpp) describes the viewed slices[baseArray, depthOrLastArray]as an array of their own, starting at the first viewed slice, when the whole array is past the limit. A non-XOR swizzle does not depend on the slice index, so those slices detile exactly as in the whole array.cachedStorageTextureuses it for every storage view andcachedTexturefor every sampled view; a 3D volume is not an array and a 2D image is one layer whatever its last array field holds, so both pass unchanged. A view whose slices alone exceed the limit, a view of an XOR swizzle whose equation mixes in the slice, and any otherTextureorStorageTextureimage past the limit throw instead of creating an invalid image. The sampled lookup throws before it reads the surface: the same menu samples that array through image-table T#s whose views span 2689 to 8065 slices, and reading and snapshotting the whole surface (~8 MB) before theTextureconstructor refused it cost ~55 ms per frame on the async queue.#6481 checks sampled image-table entries against the device's image limits before reading them; this serves the views that fit from their slices (sampled and storage) and refuses the rest at the lookup. If #6481 lands first, its layer check should see the windowed descriptor (
ArrayLayerWindow) so a fitting view of a larger array is not refused.Tested
agc_driver_graphics:ArrayLayerWindowrebases a 3201-layer view at slice 1536 to 1665 slices atbase + 1536 * layerByteswith the same slice layout, keeps an array within the limit, rebases a linear array, refuses a window wider than the limit, an XOR swizzle and a cube, and passes a volume deeper than the limit and a 2D image with a large last-array field unchanged.agc_driver_image_array_window_past_layer_limit: a compute shader samples (image_sample_lz) and loads (image_load) slices 8100-8102 of an 8103-layer 1D array and reads exactly those slices; before this change the sampled lookup threw "a texture array with more layers than maxImageArrayLayers is not implemented". A view of all 8103 layers is refused with the window's error on a device whose limit is lower.agc_driver_graphics,agc_driver_image_one_dimensional_array,agc_driver_image_gather_one_dimensional_array,agc_driver_image_store_array_through_volume,agc_driver_array_layer_target,agc_driver_layered_volume_draw,agc_driver_depth_plane_sampling,agc_driver_depth_plane_guest_layers; conventions and test registration checks pass.agc_tests pass exceptagc_driver_store_over_untracked, which fails on unchangedmainon this machine too.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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T11:31:29Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppL1103core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppL1103Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/ARCHITECTURE.mddocs/dev/ARCHITECTURE.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/TextureTiling.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/TextureTiling.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/ARCHITECTURE.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/ARCHITECTURE.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/ARCHITECTURE.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/TextureTiling.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/TextureTiling.cppcore/libs/prx/libSceAgcDriver/tests/TextureTiling.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/include/TextureTiling.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/TextureTiling.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/ARCHITECTURE.mddocs/dev/ARCHITECTURE.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/ARCHITECTURE.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T11:46:35Z.
Review: APPROVED
Reviewed the storage-array windowing path. The code limits the requested slice window to
maxImageArrayLayers, derives its guest base from the original array geometry, and rejects thick/non-array and slice-dependent XOR cases before creating the view. The layout regression checks the rebased address, slice count and mip offset, and the validation report identifies the original oversized Vulkan image. I found no blocking issue.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-16T18:59:31Z.
@XairRrR thanks for this. One regression: storage views of 3D volumes deeper than 2048 texels now throw. They worked before this PR.
Cause:
StorageArrayWindowreturns early only whendepthOrLastArray < maxArrayLayers(core/libs/prx/libSceAgcDriver/Graphics/src/TextureTiling.cpp:439). For ak3Ddescriptor,depthOrLastArrayis depth minus one, not a last array slice:DescribeSurfacemakes the imageimageDepth = depthOrLastArray + 1withimageLayers = 1. Vulkan requiresarrayLayersto be 1 for a 3D image and limits its depth bymaxImageDimension3D(4096 on lavapipe), not bymaxImageArrayLayers(2048). A volume 2049 to 4096 deep is therefore a valid image, but it now fails at the nextRequire.cachedStorageTexturecallsStorageArrayWindowfor every storage image binding, so by reading this covers any storage use of such a volume, not only the case I ran. The PR description lists "a volume" among the refused cases, and the new unit test checks that rejection (reject(... volume ..., "not a 1D or 2D array")), but a volume this deep was not an invalid image.Minimal fix: let volumes pass through unchanged.
core/libs/prx/libSceAgcDriver/Graphics/src/TextureTiling.cpp:439
core/libs/prx/libSceAgcDriver/tests/TextureTiling.cpp:408
Repro: I copied tests/execution/ImageStoreArrayThroughVolume.cpp and changed
Depthfrom 2 to 2049, with an 8 MiB guest block to hold it. It is the same compute store of a 2D-array view through a linear 3D volume descriptor, and it checks the same 32 stored texels and that the bytes past the volume are unchanged.3f171d03eEverything else checked out:
StorageArrayWindowstubbed to return its input ("must start at its first viewed slice").16a0f509a,agc_driver_graphicspasses 3/3. It still merges cleanly (git merge-tree) with main atc84249186.I did not check whether any shipped title binds a 3D storage volume this deep. The validation layer isn't installed here, so I make no VUID claims, including for the 2D-array view of the 2049-deep image on the merge-base files.
Setup: Linux, lavapipe Mesa 26.2.4 (LLVM 23.1.1),
ctest -V --no-tests=error -R '^agc_driver_graphics$', probe run directly, head dfeb3d8e5a11d7d4bf242eb9ec9e53b64e554635.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-16T19:45:00Z.
@Dextroid17 thanks, you're right: a volume's
depthOrLastArrayis its depth, bounded bymaxImageDimension3D, so a 2049-4096 deep volume was a valid image and must not be refused. Pushed 7d5a75149 with your two suggestions:StorageArrayWindowreturns ak3Ddescriptor unchanged, and the test now checks that a volume deeper than the limit keeps its descriptor (the "not a 1D or 2D array" rejection is tested with a cube instead). The creation guards inTexture/StorageTexturecheckgeometry.imageLayers, which is 1 for a 3D image, so they were not affected.agc_driver_graphicsfailed with the early return reverted) and passes with the change.cteston this branch: all pass exceptagc_driver_store_over_untracked(#5671, fixed by #6385).check_conventions.pypasses.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-17T14:43:24Z.
Intel and AMD Windows data, from GPUs on both sides of the limit.
Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
ANYPS5_NO_SHADER_CACHE=1, serial CTest,main47a266cf9. Intel UHD Graphics 770 (8086:a780, 32-wide subgroups), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550, 64-wide subgroups), driver 32.0.31041.1004, withVkCacheemptied first.Reported
maxImageArrayLayers: UHD 770 2048 (as on NVIDIA, so arrays past it take the new path), RX 9070 XT 8192 (the PS5 maximum, so the new path is never needed there).7d5a75149merged intomain: the 16 tests built fromtests/Graphics.cppandtests/TextureTiling.cpp, ×3There is no without-run: this PR's
TextureTiling.cpptest doesn't compile againstmain.Full CTest (
--parallel 4) with six open PRs merged intomain(#6638, #6604, #6014, #6773, #6772, #6725): the same failures asmainalone on both GPUs, nothing new.mainalone: UHD 770 1392 of 1398, RX 9070 XT 1396 of 1398. The failures are image tables (#6647) andsample_multisample_target(#6971) on Intel, andquad_pixel_mask(#6255) andlayered_volume_vertex_no_gpl(#4768) on AMD.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-17T18:08:17Z.
Pushed a95b44a61: sampled views now use the same layer window as storage views (
StorageArrayWindowis renamedArrayLayerWindow).While testing the earlier head on Uncharted: Legacy of Thieves Collection (PPSA05684), the main menu lost about a third of its frame rate. It samples a 16x16 array of up to ~8000 layers through image-table views of 2689 to 8065 slices. The sampled lookup read and snapshotted the whole surface (~8 MB) before the
Textureconstructor refused it, about 17 times a frame. Now a view that fits is served from its slices, and one that does not is refused before anything is read. New test:agc_driver_image_array_window_past_layer_limit. Menu fps and the updated test list are in the description.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-19T00:26:26Z.
Rebased onto current
mainand added 04bc0eea5.main's newagc_depth_copy_kept_bytes(fromea02128b5) builds its storage image onmockContext(), which leftmaxImageArrayLayersat 0. That made this PR's layer check reject the 8x8 image. The mock now reports 2048 layers, as real devices do. Allagc_tests pass exceptagc_driver_bda_device, which also fails on plainmainon this machine. The conventions check passes.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-19T21:06:31Z.
Rebased onto
main7866e7d97(f408eb711). #7258 (merged) addedViewedArrayWindow, which narrows a sampled view that starts past slice 0 to its viewed slices when the swizzle allows. This PR'sArrayLayerWindowonly acts on arrays pastmaxImageArrayLayers, and it runs first incachedTextureand for storage views. The two now sit side by side inTextureTiling.cpp, and both sets of tests are kept. For a sampled view past the limit, the two give the same window. Where they differ, this PR refuses a slice-dependent XOR swizzle rather than keeping the whole array. If you'd rather keep a single function for sampled views, I can drop the sampled call from this PR and leave it to storage views. All 798agc_tests pass (Linux, RTX 4070 Ti SUPER), and so does the conventions check.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T08:55:26Z.
Re-checked after the rebase onto
mainwith #7258:ArrayLayerWindowonly acts on arrays pastmaxImageArrayLayersand sits next toViewedArrayWindowwithout overlapping it; both sets of tests are kept and the merge is clean. Merged.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-20T18:44:31Z.
agc_driver_image_array_window_past_layer_limitis red on my RADV stack since this merged — first full-suite run after the merge reachedmain(it came in through the stacked-merge window ending atb85d972f4).image_sample_lz on a window of a 1D array past maxImageArrayLayers: thread 7 component 0 is 107.000000/255, expected 147/255— deterministic across reruns, cold GPU (junction 30 °C), and unchanged with the shader cache cleared and withANYPS5_NO_SHADER_CACHE=1.AMD RX 9070 XT (RADV GFX1201), Mesa 26.2.4, CachyOS, kernel 7.2.9. @adriadam10's pre-merge recheck above was green — on which stack? If that was a different GPU or Mesa, this may be NAVI4x- or Mesa-version-specific, in the pattern of #7766/#7784 (which pass on AMD's Windows proprietary driver and fail on RADV here).
For transparency on the diagnosis path: the test did not exist on
mainbefore the merge (I first misread it as a fresh main regression and ran a bisect; the A/B at the pre-merge anchor exposed the test binary as stale from a later tree, since the target didn't exist at that checkout — so "newly arrived red", not a regression). No open issue mentions it; happy to file one with this data or run any narrower repro.