fix(agc): load and query cube descriptors of two to five slices as RDNA2 does #26012
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26012"
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 brumskysb on 2026-11-23T04:16:40Z.
What
A cube texture descriptor whose
BASE_ARRAYtoDEPTHrange holds two to five slices was refused for everything but sampling: the materializer threwa cube descriptor with fewer than six slices is implemented only for sampling; loads, stores and dimension queries through it stop at its last slice. RDNA2 does not stop there for a mip-0 load or a dimension query. Facefreads sliceBASE_ARRAY + fwhileBASE_ARRAY + f <= DEPTHand returns 0 past it, andimage_get_resinforeportsDEPTH - BASE_ARRAY + 1in its depth component (measured on gfx1036 in #11507).Resources.hpp,ResourceTracker.cpp): an image recordsshortCubeCompatible, set when every access to it is a mip-0image_load, animage_get_resinfoor a sampler access. It is part of the shader info, so the disk cache encodes it:FormatVersion96 to 97 and theImageResourcefield count 51 to 52.ResourceMaterializer.cpp): the refusal keeps its shape but now also requires!shortCubeCompatible, so a short cube is accepted for mip-0 loads and dimension queries and still refused for stores, atomics and loads at a mip.ShortCubeFaceLimitreturnsDEPTH - BASE_ARRAY + 1for a short cube and 0 otherwise.SpirvDescriptors.cpp,SpirvImageEmitter.cpp): the face limit reaches the shader the way the other per-descriptor limits do — a pipeline specialization constant (PipelineSpecialization::CubeFaceLimitBase, 8448, pushed byDescriptorBindingBuilder) for AOT shaders. Registration modules recompute it in SPIR-V from the descriptor's dwords 3 and 4, with the same predicate asdescriptorIsShortCube(TYPE is cube,BASE_ARRAY < DEPTH, fewer than five slices beyond the base). A mip-0 load of a layer at or past the limit returns 0 in all four components, andimage_get_resinforeplaces its depth component with the limit. A limit of 0 means "not a short cube" and leaves the access untouched, so one compiled shader serves both.Two head changes since the first reviews:
f069cd1947, per @coderabbitai's MAJOR).DescriptorBindingBuilderpushes the face-limit constant only for direct descriptors, so a table image admitted by the old gate would query with the wrong slice count and read data pastDEPTH. The admission now additionally requires no runtime image table, matching sibling descriptor-dependent rules;agc_shader_memorypins both the direct admission and the table refusal.a5bc45e203(post #23519/#23688). The disk-cache bump is nowFormatVersion97 to 98 withfieldCount<ImageResource>52 to 53, taking main's current numbers; the earlier merge-in had a double 51->52 bump that failed the encoder'sstatic_assert, fixed here.ImageSampleShortCube.cppturns the oldimage_loadrefusal into loads of every face at two rows for all six measured ranges, addsimage_get_resinfofor the same six, and keeps a refusal leg for a load at a mip.ShaderMemory.cppchecks that the runtime mode accepts a loaded five-slice cube, thatShortCubeFaceLimitis 5 for it, that a mip load is still refused, and — unchanged — that a stored three-slice cube is refused.docs/dev/debt/changes/fix-agc-short-cube-loads.md.Since the rebase, two more commits:
38884fe07(per @coderabbitai finding 2): a direct image whose only access isimage_get_resinfothrough aDim2Daddress keptshortCubeCompatibleafter the merge clearedcubeFaceCompatible, but no offered runtime mode matched a cube descriptor - the query path threw at mode matching.RuntimeImageModesnow offers the query-only twin of the cube face mode for exactly that access set (direct, non-storage, no table). Covered by unit caseverifyShortCubeQueryMode, a DIM-1 resinfo leg inImageSampleShortCubeand a plain-2D control inImageResinfoDimension.59ed84ad1: the table refusal is narrowed to the accesses that actually need descriptor words. A table-selected image whose only access is sampling keeps the existing six-face behavior (the slice limit is irrelevant there); loads and dimension queries through a table record stay refused, since the record carries noBASE_ARRAY/DEPTHto build a limit from.agc_shader_memorypins both halves.Validation on the new head
59ed84ad1:agc_shader_memory,agc_driver_image_sample_short_cube,agc_driver_image_resinfo_dimension,agc_driver_image_gather_face_on_cube,agc_driver_image_store_face_on_cube,agc_driver_image_sample_cube_offset- 6/6 PASS, 0VUID-lines, validation layer loaded (lavapipe). Thedebt_fold --checkcube-fragment collision predates this PR and is unchanged by these commits.Tested
VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.json,ANYPS5_GPU=llvmpipe,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Khronos validation layer 1.4.363.1; the loader logsInsert instance layer "VK_LAYER_KHRONOS_validation"),ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1. The rule was measured on gfx1036 in #11507 (hugodearaujo); this test was not run on that hardware.agc_driver_image_sample_short_cube: a compute shader samples and loads a 64x64 R32_FLOAT cube of 8 slices at every face centre for the six measuredBASE_ARRAY/DEPTHranges — 432 lane checks overimage_load(6 ranges, 2 rows, 6 faces, 6 lanes) plusimage_get_resinfo(extent, depth component, level count) — and a(0, 4)image_load_mipthat must still be refused. 1 of 1 passes, 0.18 s. Withmain's production files it fails with the refusal above; with the resinfo depth mutated toL + 1it fails withimage_get_resinfo cube with BASE_ARRAY 0 and DEPTH 4: depth component 6, expected 5while the load legs still pass.ctest -Vonmain742022e89dand on this headfb84f9ee3c, same machine:agc_driver_image_plane_address_on_cube,agc_driver_image_sample_cube_derivatives,agc_driver_image_sample_short_cube,agc_driver_image_store_face_on_cube,agc_driver_vop3_cube_clampandagc_driver_image_resinfo_dimension— 6 of 6 pass on both. Neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS, the loader inserts the layer once per test, and neither has aVUID-line.f069cd1947(clean tree; everyagc*_teststarget, the relinker, the guest-memory fixtures, the draw-recapture tool, and the cube execution testsImageGatherFaceOnCube/ImageSampleCubeOffset/ImageStoreFaceOnCubeconfigured): 2146 tests, 0 failed, 0 not run, 0VUID-lines, 0 missing-layer messages. Runs onfb84f9ee3cand the pre-rebase head stand; the rebase re-ran everything.descriptorIsShortCube.agc_shader_memoryandagc_shader_disk_cachepass (0.36 s and 2.10 s): the runtime mode, the new flag and the format bump are covered.tools/check_conventions.py --base origin/mainpasses.tools/debt_fold.py --checkpasses, and rendering the debt file with the fragment present and absent differs in exactly the one entry.tools/pr_overlap.pylists 71 open PRs on these files, almost all of them on the lines every newImageResourcefield must touch (the disk cache format version and field count); the substantive ones are #23111 onResourceMaterializer.cpp, #23666 and #22724 onSpirvImageEmitter.cpp, #22724 onShaderMemory.cpp, #16953 and #19096 onDescriptorBindingBuilder.cppand #14871/#16321 on the two new declarations. None of them changes cube ranges.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)Summary by CodeRabbit
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T04:25:13Z.
Review: COMMENTED
Reviewed — comments
The reviewed changes add short cube load and dimension-query handling at the pinned head, but I could not complete the required review of every changed file or run the reported checks.
What I ran
Read the prepared diff and targeted source ranges at head
fb84f9ee3c3f396fb455f54ac8cea8dea65dad4busingrepo_read.py. No test commands were run.Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
I read
review/description.md,review/commits.md,review/manifest.json, andreview/diff.patch, plus targeted ranges fromResourceMaterializer.cpp,ResourceTracker.cpp,SpirvImageEmitter.cpp, andShaderMemory.cpp. The full text ofShaderMemory.cppis excluded from the review bundle; only its changed region was read throughrepo_read.py. Other changed files were not read in full, including the execution test, disk-cache files, descriptor binding and descriptor emitter files, declarations, and debt entry. The author's reported test results were not independently verified.To get this to a good state
Nothing is required. Optional: complete review of the remaining changed files and independently run the reported checks before making a formal approval decision.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T23:55:19Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected code supports the described short-cube behavior, with the registration-module route still unverified.
What I ran
Reviewed head
31be364eb373060381b0a9f0147524188d448c74. No build or tests were run in this review. Read the prepared description, commits, diff, manifest, the included changed files, and the excludedShaderMemory.cppchanges through the pinned reader.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
files.jsonwas not available in the review folder; the file listing identifiesShaderMemory.cppas excluded for size, and its changed section was read at the pinned head.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-26T23:59:15Z.
Review: COMMENTED
Actionable comments posted: 1
30963c80-3acc-4467-9cef-c3e86c838f61Reviewing files that changed from the base of the PR and between
864e6397fdand31be364eb3.core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/execution/ImageSampleShortCube.cppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hppcore/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/PipelineSpecialization.hppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvMemory/SpirvDescriptors.hppcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvDescriptors.cppdocs/dev/debt/changes/fix-agc-short-cube-loads.mdIncluded 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 coderabbitai[bot] on 2026-11-27T04:40:33Z.
Review: COMMENTED
Actionable comments posted: 1
df78bebf-ccbb-450e-8b41-125d1e98ddc8Reviewing files that changed from the base of the PR and between
31be364eb3andf069cd1947.core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppdocs/dev/debt/changes/fix-agc-short-cube-loads.mdIncluded 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 MarcZX10 on 2026-11-27T04:52:43Z.
Review: COMMENTED
Reviewed — comments
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
f069cd19476cc8bf9d4d865dbd6ec89cc0ec3238. I inspected the prepared diff and targeted code withrepo_read.py; I did not run tests or a build.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/tests/execution/ImageSampleShortCube.cpp:155.Not verified
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded from the review bundle because it exceeded the size limit. I read its changed lines viarepo_read.py.ImageSampleShortCube.cpp, the resource metadata and materialization code, descriptor binding and SPIR-V emission code, disk-cache changes, and the debt note.To get this to a good state
Nothing is required. Optional: strengthen the mip-load rejection assertion to identify the intended rejection path.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-29T07:30:09Z.
Review: COMMENTED
Actionable comments posted: 1
a90b272c-fa24-4f5c-b646-76ce1f17c86fReviewing files that changed from the base of the PR and between
f069cd1947and59ed84ad16.core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/execution/ImageResinfoDimension.cppcore/libs/prx/libSceAgcDriver/tests/execution/ImageSampleShortCube.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppdocs/dev/debt/changes/fix-agc-short-cube-loads.mdIncluded 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 MarcZX10 on 2026-11-29T07:36:14Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing in the inspected changes blocks merging; I found no verified blocking defect, but one changed file was excluded and I did not run checks.
What I ran
Reviewed head
59ed84ad166efe60d980bd4983418b2791a3717eusing the prepared diff and pinned repository reader. No commands or tests were run.Results
Findings
Blocking
None verified in the code read.
Non-blocking
None.
Not verified
ShaderMemory.cppwas excluded because it was too large for the review folder; its changed lines were not read. The debt note was included in the prepared folder listing but its contents were not read. No tests were run independently; test results in the PR description are author-reported. I read the diff and manifest,ImageSampleShortCube.cpp,ImageResinfoDimension.cpp,Resources.hpp,ResourceMaterializer.hpp,DescriptorBindingBuilder.cpp,ResourceMaterializer.cpp,ResourceTracker.cpp,PipelineSpecialization.hpp,ShaderDiskCache.cpp,ShaderDiskCache.hpp,SpirvDescriptors.hpp,SpirvDescriptors.cpp, andSpirvImageEmitter.cpp. The other changed files were not read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T12:46:20Z.
Review: COMMENTED
On Linux Mesa lavapipe with Khronos validation 1.4.369, the same
agc_shader_descriptor_phisandagc_driver_gcn_scalar_buffer_baseCTest cases passed on main and the change. The change also passedagc_driver_image_resinfo_dimensionandagc_driver_image_sample_short_cube. The loader inserted the requested validation layer in each run, and the logs contained no missing-layer diagnostic or VUID. These runs used the software Vulkan device on this host.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.