Skip to content

fix(shader): answer image_get_resinfo on 2D MSAA T#s - #19682

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
c1b3r-p3d1a:fix/shader-resinfo-msaa
Nov 21, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
c1b3r-p3d1a:fix/shader-resinfo-msaa

Conversation

@c1b3r-p3d1a

Copy link
Copy Markdown
Contributor

What

image_get_resinfo on a 2D MSAA T# with 2, 4 or 8 fragments returned 0 levels under DIM 2D_MSAA and threw image address has too few coordinate components under DIM 1D. It now returns (width, height, 0, 1), the level component measured on RDNA2 with the hardware oracle in #18467 (recorded in docs/dev/debt/shader.md).

  • SpirvImageEmitter.cpp: the level component of a multisampled dimension query starts at 1 instead of 0 (SPIR-V has no level query on multisampled images).
  • ResourceMaterializer.cpp: a query-only DIM 1D image also gets a 2D MSAA view, gated like the existing query-only 2D/2D-array/3D/cube views (plain, non-depth, no conversion or packing), so read modes are unchanged.

Still throwing, as the debt entry now says: DIM 2D on a 2D MSAA T# (its views are shared with 2D reads), 2D MSAA-array T#s (the driver binds no type-15 texture) and 16-fragment T#s (refused as invalid descriptors). Not measured on the PS5's gfx1013.

Tested

Windows 11, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh r7), Release, rebased on main 135da47.

  • agc_driver_image_resinfo_dimension now also checks 2D MSAA T#s (SW_MODE 64KB_S, 2/4/8 fragments) under DIM 2D_MSAA and DIM 1D against (8, 8, 0, 1). It fails with each fix reverted: levels 0, and image address has too few coordinate components.
  • ctest -R "agc_driver|shader|recompiler": 1258/1267 pass. The 9 failures (agc_driver_f16_conversion_float_mode, float16_misc, float16_modifiers, float16_rounding, fp16_overflow, ldexp_f16_inline_constants, sdwa_ldexp_f16, vop2_modifier_forms, sample_order_grid_reference) were already failing on main on this machine in an earlier run today and do not involve image queries.
  • python tools/check_conventions.py --base origin/main: 0 errors; one warning that the existing debt entry is over 1000 characters (it already was on main).
  • Not run: Linux, a title.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 7700 XT (RDNA3), driver 32.0.32015.7029, Windows 11
  • AI-assisted: yes

A size query on a 2D MSAA texture with 2, 4 or 8 fragments returned 0
levels under DIM 2D_MSAA and threw under DIM 1D. Report one level, as
measured on RDNA2 with the hardware oracle (boykopovar#18467), and give DIM 1D
queries a 2D MSAA view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tablefrogpillow

Copy link
Copy Markdown
Contributor

Verified on three AMD generations on Linux (RADV, Mesa 26.2.6), validation layer 1.4.363 (no VUID-), at 9eb5a30dc2 — first AMD-hardware runs. PR head vs a negative control that keeps this PR's test but reverts ResourceMaterializer.cpp and SpirvImageEmitter.cpp to the merge-base:

Vega (VEGA10, GCN5) RDNA2 (RAPHAEL, gfx1036) RDNA3 (NAVI31, gfx1100)
agc_driver_image_resinfo_dimension — PR head 3/3 3/3 3/3
control (revert) 0/3 0/3 0/3

Without the fix, all three generations fail deterministically:

image_get_resinfo: the 2D MSAA query returned 8x8x0 levels 0, RDNA 2 returns 8x8x0 levels 1

i.e. the 2D MSAA T# resinfo query reports a mip-level count of 0 instead of the hardware's 1. With the fix it answers image_get_resinfo on 2D MSAA T#s correctly across GCN5, RDNA2 and RDNA3; 0 VUID- in every run.

AI-assisted: yes.

@Doorriiaann

Copy link
Copy Markdown
Contributor

An NVIDIA run, next to the AMD runs: RTX 3070 (8 GB), NVIDIA 610.57.04, Ryzen 5 5600X, Debian 13, kernel 6.12.115, GCC 13.3.0 Release, validation layer 1.4.335, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest -R resinfo -V, 3 runs each.

merge-base 135da47 this PR 9eb5a30
agc_driver_image_resinfo_dimension passed 3/3 passed 3/3, with this PR's 2D MSAA case
VUID- lines / layer not found 0 / 0 0 / 0

Negative control: this PR's ImageResinfoDimension.cpp on the merge-base, 3 runs: the test fails 3/3 with AGC graphics: image_get_resinfo: the 2D MSAA query returned 8x8x0 levels 0, RDNA 2 returns 8x8x0 levels 1.

AI-assisted: yes

@github-actions github-actions Bot added shader core/shader docs agc libSceAgc* labels Nov 13, 2026
@JJenkx

JJenkx commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 9eb5a30dc2, merged onto main c9a1545e8c. Setup: Windows 11 Enterprise 22621, AMD RX 6700 XT, AMD driver 26.10.1, MinGW-w64 GCC 15.2 UCRT, Release.

agc_driver_image_resinfo_dimension:

  • GPU, through the shared Windows GPU FIFO with ANYPS5_REQUIRE_VULKAN=1 (merge 7b87522c52): passed in 3 of 3 runs. The binary matched the hash recorded at preparation, and the receipt shows exit 0 and app_count=0.
  • CPU, Vulkan hidden (merge 76f33938b2): skipped (it needs a device), 0 failed.

AI-assisted: yes.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 7085 core/libs/prx/libSceAgcDriver/tests/execution/ImageResinfoDimension.cpp L35-36, L42, L48, L50, L101
PR 22724 core/libs/prx/libSceAgcDriver/tests/execution/ImageResinfoDimension.cpp L35-36, L42, L48, L50, L101

Some 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.

Pull request Shared files not compared
PR 5371 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 6235 docs/dev/debt/shader.md
PR 6280 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 6412 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/shader.md
PR 6488 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 6924 docs/dev/debt/shader.md
PR 7392 docs/dev/debt/shader.md
PR 7395 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 7642 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 7684 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/shader.md
PR 7689 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 8939 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 9387 docs/dev/debt/shader.md
PR 9508 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 9633 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 9749 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 9790 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 9969 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 10193 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 10652 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 11483 docs/dev/debt/shader.md
PR 11551 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 12944 docs/dev/debt/shader.md
PR 13928 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 13929 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 14853 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 14871 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 14964 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 15548 docs/dev/debt/shader.md
PR 15555 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 16260 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 16472 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 16571 docs/dev/debt/shader.md
PR 16631 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 16812 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 16814 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 17611 docs/dev/debt/shader.md
PR 18106 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 18107 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/shader.md
PR 20248 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 20519 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 22424 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 23242 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp

@c1b3r-p3d1a

Copy link
Copy Markdown
Contributor Author

Two new commits:

  • d81d967c76 splits the image_get_resinfo debt entry in docs/dev/debt/shader.md. tools/check_conventions.py flagged it with [debt-length]: 1939 characters, against a limit of 1000.
  • 5c9cc06321 merges main ea0c471cbc.

The text is unchanged except for the new lead-ins. It is now three entries:

  1. DIM 1D on a cube, 2D-array or 3D T#, and the 1D-array case (738 characters);
  2. what this PR answers and what still throws on 2D MSAA and 2D MSAA-array T#s (616);
  3. the RDNA2 hardware-oracle measurements behind it (889).

agc_driver_image_resinfo_dimension passes on the merged head (Windows, RX 7700 XT, WinLibs GCC 15.2). check_conventions.py --base origin/main passes with no findings.

AI-assisted: yes.

@domx4q

domx4q commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Ran the resinfo test and the MSAA image tests on NVIDIA's proprietary Linux driver with the Khronos validation layer at the current head; the earlier NVIDIA run in this thread was on 9eb5a30dc2.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684, Ada), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head 5c9cc06321 merged onto main f2d10b6999 with --no-ff, clean merge. Main baseline is a Release build of f2d10b6999 on the same machine.

WAYLAND_DISPLAY=wayland-1 XDG_RUNTIME_DIR=/run/user/1000 DISPLAY=:0 ANYPS5_REQUIRE_DISPLAY=1 \
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R 'resinfo|^agc_driver_image_msaa|^agc_driver_msaa_layout$' -V
main f2d10b6999 this PR
Result 3/3 passed 3/3 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 2 2
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- none none

agc_driver_image_resinfo_dimension runs this PR's version with the 2D MSAA cases on the PR side and main's version on the main side; both pass (image resinfo dimension tests passed). agc_driver_image_msaa_address_on_plane (GPU) and agc_driver_msaa_layout (host, no Vulkan instance) pass on both sides. Every device selection picked the RTX 4090.

Negative control: this PR's build with main's ResourceMaterializer.cpp and SpirvImageEmitter.cpp fails agc_driver_image_resinfo_dimension deterministically (2 of 2 runs) with AGC graphics: image_get_resinfo: the 2D MSAA query returned 8x8x0 levels 0, RDNA 2 returns 8x8x0 levels 1. Neither run logs a VUID-.

No new VUID- errors; all focused tests pass on Ada, and the changed test fails without the fix.

AI-assisted: yes (Claude Code)

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the read code and supplied checks support merging.

What I ran

Reviewed head 5c9cc0632165d052c989ee24bc80270e2e7a8bbc using the pinned repo_read.py reader. No commands or tests were run by me; the environment and toolchain were not independently verified.

Results

Check Result Note
Changed code review passed Four changed files read
Automated tests not run Results below are author-reported
Negative control not run Not independently reproduced

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author reports the execution check on RDNA3 and the hardware behavior measurement on RDNA2; neither was run by me. Linux and PS5 gfx1013 behavior were not verified. The review bundle contained no excluded changed files; all four files listed in the manifest as reviewed were read: ImageResinfoDimension.cpp, ResourceMaterializer.cpp, SpirvImageEmitter.cpp, and shader.md.

To get this to a good state

Nothing is required.

@kiwe147

kiwe147 commented Nov 21, 2026

Copy link
Copy Markdown

Tested head 5c9cc06321, applied with git apply (with -C1, context shifted) on main fd4aeed483 together with the other 29 PRs of one batch (#18156, #21208, #22013, #22795, #23226, #23385, #24324, #24533, #24582, #24690, #24693, #17553, #19619, #20085, #21081, #22123, #22529, #22572, #22662, #23479, #23787, #24568, #15330, #21249, #21630, #21713, #22040, #23490, #24394). All applied without conflicts and the whole tree built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. GPUs: NVIDIA GeForce RTX 3080 (driver 621.24) and the AMD Radeon iGPU of the CPU (gfx1036, driver 32.0.21036.18). No validation layer. iGPU run: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU="AMD Radeon", agc_/video tests only.

tests RTX 3080 iGPU
agc_driver_image_address_dimension, agc_driver_image_resinfo_dimension (2 tests, matched by name to the test file this PR changes) all pass all pass

Whole batch: the full ctest -j 12 (6540 tests) on the RTX 3080 has 5 failing tests; the 4 that also fail on main fd4aeed483 are agc_driver_stencil_plane_memory, agc_driver_msaa_dcc_unwatch, agc_storage_write_back_host_retile, and pr_overlap_names, which needs a newer Python than my 3.10. Intermittent in this run (pass when rerun alone, or known flaky): agc_driver_store_over_untracked. Traced to other PRs of the batch, each by reverting it and testing again: #17553 (guest_memory); none is in this PR's area. The 2143 agc_/video tests on the iGPU have 2 failing: agc_driver_stencil_plane_memory, agc_driver_store_over_untracked (agc_driver_stencil_plane_memory also fails on main).

This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

@oneandonlydean
oneandonlydean merged commit 3fc5088 into boykopovar:main Nov 21, 2026
15 checks passed
oneandonlydean pushed a commit that referenced this pull request Nov 27, 2026
RuntimeImageModes offers the multisampled view a query-only 2D image needs,
as #19682 did for DIM 1D, so DIM 2D now answers (width, height, 0, 1) instead
of throwing.

A query-only slot also accepts a 16-fragment T#, which every other access
still refuses as an invalid descriptor, and DescribeSurface models a
16-fragment multisampled colour footprint so that query can be bound where
the device samples colour attachments at 16 samples.

A 2D MSAA-array T# keeps throwing: the driver binds no type-15 texture, and
MultisampleTarget requires single-layer targets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants