fix(shader): answer image_get_resinfo past the last mip level as RDNA2 does #22724
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22724"
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 MichonGoddijn231849 on 2026-11-18T05:27:35Z.
What
image_get_resinfopassed the guest mip straight toOpImageQuerySizeLod. Vulkan leaves that undefined for a lod at or past the view's level count. AMD's driver then returned the halved size of the last level, e.g. 1×1 for mip 4 of an 8×8 T# with 4 levels, and 32×16 for mip 1 of a single-level 64×32 one. RDNA2 hardware returns 0 for width, height and depth or layers there, and the level count as usual.SpirvImageEmitter.cpp(QueryDimensions): the level count is read first, the size is queried at the guest mip when it is below the level count and at level 0 otherwise, and the three size components are zero past the last level. The fourth component is the level count as before. Multisampled queries are unchanged.test:
ImageResinfoDimension.cppgainsCheckMips, which queries mips 0 to 5, 15 and 0xffffffff of:The expected values are the hardware's (below). The query program takes its mip from a literal (
MipCode), andDescriptortakes an optional level count; the existing cube/3D/2D-array checks keep their single-level descriptors.debt: a new
shader.mdentry (fragmentdocs/dev/debt/changes/fix-resinfo-mip-past-last-level.md).Source of the semantics:
tools/hw-oracleon gfx1036 (AMD Windows driver 32.0.21045.16010). The test's three T#s on hardware:A wider differential sweep against
agc_oracle_runnercovered 1D, 2D, 3D, 2D-array and 1D-array T#s of 1×1 to 100×1×12 with up to 7 levels, base levels 0 to 2 and array bases 0 and 2. It gave the same rule everywhere: before this change AMD returned a computed size for every mip at or past the level count. NVIDIA's driver already returned zeros there.Tested
Windows 11 Pro 10.0.26200,
ctest --test-dir build -R agc_driver_image_resinfo_dimension -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer, validation layer 1.4.363, once per GPU:VUID-image_get_resinfo: mip 4 of a 2D T# with 4 levels returned 1x1x0 levels 4, RDNA 2 returns 0x0x0 levels 4VUID-Each log shows
Insert instance layer "VK_LAYER_KHRONOS_validation"and none showswas not found but was requested. The other execution tests that query dimensions also pass on both GPUs:image_cache_bits,image_texel_status,image_volume_address_planar_texture,ds_swizzleandimage_address_dimension, 6/6 with the resinfo test.pr_overlap.py --branchfailed closed on 14 open PRs that conflict withmain; I compared their diffs by hand:QueryDimensions, for guest levels the host view lacks, so they and this PR need a textual merge. They report size 1 for those levels and do not zero a mip past the T#'s last level, which is what this PR fixes.OpImageQueryLevelselsewhere.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)🤖 Generated with Claude Code
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T06:21:49Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected shader change guards out of range mip queries and the included tests cover representative 2D and array cases; the full review remains incomplete because one changed file was only read around its modified code.
What I ran
Reviewed head
84562572a5f6dbb3fd6f52d43342caa089353250using the prepared review bundle and pinned-head reader. No tests or build commands were run in this review.Results
Negative control
Not run; no test environment was available in this review.
Findings
Blocking
None identified in the inspected code.
Non-blocking
None.
Not verified
The remainder of
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas not read; only the modified SPIR-V parsing and query-checking area was inspected. The reported Windows GPU test runs and hardware-oracle measurements were not independently verified. The other changed files read in full werecore/libs/prx/libSceAgcDriver/tests/execution/ImageResinfoDimension.cpp,core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp(changed function), anddocs/dev/debt/changes/fix-resinfo-mip-past-last-level.md. The description, commits, manifest, and diff were also read. No files were excluded from the prepared review bundle beyond the noted oversizedShaderMemory.cpp.To get this to a good state
Nothing is required. Optional: run the reported execution tests on the target GPUs and inspect the remaining
ShaderMemory.cppcontext before treating this review as complete.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T06:38:45Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and the changed test cases support merging.
What I ran
Reviewed head
e5eac4e26f6fce16bc1a50c2d150515164f73f93using the prepared diff andrepo_read.pysource reads. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
ShaderMemory.cppwas excluded from the review bundle because it was too large; its changed lines were not read. No tests were run independently. Runtime behavior and the GPU results described in the PR were not independently verified.To get this to a good state
Nothing is required.