Skip to content

fix(shader): read a 2D MSAA T# through DIM 2D as its sample 0 - #7803

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
thuanquang:fix/msaa-2d-sample-zero
Oct 23, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
thuanquang:fix/msaa-2d-sample-zero

Conversation

@thuanquang

@thuanquang thuanquang commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What

METAL GEAR SOLID: Peace Walker (PPSA18216) stops at the opening movie's last copy (#5268). A pixel shader reads its 4-sample 1440x816 RGBA8 target through a plain DIM 2D image_sample, and the recompiler refuses the T#:

image descriptor is incompatible with the static runtime image interface: descriptor format 56 decodes to {class 1, dim 6, ...}; ... T# 02754d00 c3800000 00cbc167 e1b20fac 00000000 00700020 00000000 00000000

What RDNA returns for a DIM 2D read of a 2D MSAA T# was the open question (@mrfelek, @SandstromPL). On an RX 6700 XT (gfx1031), through HIP, it is sample 0 (measurement on #5268):

  • image_sample (implicit LOD), image_sample_lz and image_load without a mip, through a T# built like the title's (format 22), return sample 0 in 1024 of 1024 lanes on a 256x256 surface spanning 16 64 KiB blocks, where a TYPE 9 (2D) T# over the same memory matched sample 0 in only 60.
  • image_sample_l at LOD 0 to 3, through an S# with MAX_LOD 15.99 and each mip filter, returns sample 0 in 256 of 256 lanes of a 16x16 surface through a T# built the same way. With a point mip filter, the same S# at LOD 1 and 2 reads another level of a 3-level TYPE 9 T# over the same memory, so the LOD takes effect.
  • A bilinear sample blends the neighbouring pixels' sample 0 (240 of 240), never the 4-sample average.
  • image_load_mip DIM 2D with mip N returns sample N.
  • A wider run (data) gives the same for image_sample, image_sample_lz and image_load at 2, 4 and 8 samples, for formats 22, 29, 56, 60, 64, 71 and 77 in SW_64KB_R_X and the 32-bit formats in SW_64KB_Z_X. Its image_sample_l rows used an all-zero S#, which clamps the LOD to 0 (correction).
  • An 8- and 16-bit run (data) gives the same at 2, 4 and 8 samples in SW_64KB_R_X and SW_64KB_Z_X for 8_UNORM, 8_UINT, 16_UNORM, 16_UINT, 16_FLOAT, 8_8_UNORM, 8_8_UINT and 5_6_5_UNORM (8_SINT and 16_SINT at 4 samples in SW_64KB_R_X). It also measures image_sample_l at LOD 1, 2 and 3 through an S# with MAX_LOD 15.99, with a control showing that S# reads mip 1 of a TYPE 9 T#, for those texels and for 32_FLOAT and 8_8_8_8_UNORM (the title's format) in SW_64KB_R_X.
  • Measured at LOD 0 only: image_sample_l for formats 29, 60, 64, 71 and 77 and for the 32-bit formats in SW_64KB_Z_X, and implicit-LOD image_sample everywhere. 64- and 128-bit texels in SW_64KB_Z_X, and SW_64KB_S_X and SW_64KB_D_X, do not address samples on this GPU (every sample index reads the same texel), so they are not covered.

This change reads it that way:

  • Recompiler (ResourceMaterializer.cpp): a 2D MSAA T# decodes as Dim2D when the access is a direct sampled image read only through image_load without a mip and image_sample, _lz or _l (the reads cubeFaceCompatible tracks, taken for sampled images only), without a depth compare, R128, FMASK or depth-bits format. The shader then uses the existing 2D runtime mode, so sampling, filtering and LOD stay native. Storage, atomics, image tables, depth compares, gathers, bias, gradients, offsets and image_load_mip keep the existing refusal. The gate has no element-size check: the 8- and 16-bit run covers the narrower texels.
  • Driver: an Image2D binding over a 2D MSAA resource gets a one-sample copy of sample 0 (MultisampleTargetFirstSample). After the usual Sampled() checks (CMASK/HTILE, fast clears, pending storage writes, barrier), a fragment pass (FirstSampleCopy, texelFetch of sample 0 into a one-sample attachment of the target's format) refreshes the copy before each such binding. The pass reads the target's sampled view in the layout that view reports (Texture::Layout()), and creates its shader modules through CreateShaderModule, the path fix(agc): key shader modules by the pipeline library mode #6436 made for every module the driver creates. Float, UNORM, SNORM and sRGB formats go through a float pass; UINT and SINT formats go through usampler2DMS and isampler2DMS passes, which copy the bits. It works for a live target, a red/blue-swapped one, and a texture no draw rendered to (createFilled). A Vulkan resolve would not do: it averages float and UNORM samples. A multisampled depth surface read this way throws.

The debt entries state the gaps first. The reads are measured on gfx1031, not the console's gfx1013. Implicit LOD above 0, explicit LOD above 0 for texels over 16 bits other than formats 22 and 56 in SW_64KB_R_X, and other formats and swizzle modes are not measured. 64- and 128-bit SW_64KB_Z_X texels are not covered. Float, UNORM, SNORM and sRGB values pass through a shader and a color attachment, which Vulkan does not require to keep exact.

Tested

Windows 11 26200, AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002 and 32.0.21045.16010, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, ANYPS5_REQUIRE_VULKAN=1. Rebased onto main 9d6adeb550: this head (0a3ea213e1) is one commit on it; the one conflict was in tests/ShaderMemory.cpp, where main added a verifyArrayVolumeStoreMode() call in main() on the line where this change adds verifyMultisamplePlaneReadMode(); both calls are kept, and the rest of the patch is unchanged. On this head, with AMD driver 32.0.21045.16010, the six focused tests below pass 3 of 3, and a validation layer run of the six (same environment as the validation layer run below) passes with no VUID- error and no was not found but was requested line. The full AGC suite on this head (ctest -R ^agc_ -j 1): 902 of 905 pass; the three failures, agc_driver_sample_order, agc_driver_sample_order_grid_reference and agc_driver_sample_order_recipe_depth_locations, fail on main on this machine as well (seen on main d6eafa54d). The rebase before it, onto 001d132f47 (head e0f6ea8ed6), had one conflict in MultisampleTarget.cpp, where #8847 (sRGB twin formats) added View(VkFormat) and Serves(), made ResolvePass() per format and destroys the twin view in release(), next to this change's FirstSample() and its two release() lines; both are kept, and with AMD driver 32.0.21045.16010 the six focused tests below passed 3 of 3 on it. The rebase before that, onto 8b3a6ba88d (head 0ad8aa3278), had one conflict: main added imageCoordinates() in ResourceMaterializer.cpp where this change adds multisamplePlaneRead(), and both are kept. main's new GCN-only address-count check runs before this change's sample-0 rule, so GCN shaders behave as on main. On that head, with AMD driver 32.0.21045.16010, the six focused tests below passed 3 of 3; with main's ResourceMaterializer.cpp on it, agc_shader_memory failed with descriptor format 56 decodes to {class 1, dim 6, ...} as below. Before that, the rebase onto 2f161d4f33 (head 9ac1a20ce4) had one conflict: main added its SampleOrder shader block in core/libs/prx/libSceAgcDriver/CMakeLists.txt where this change adds the FirstSample block, and both are kept. On that head the six focused tests below passed 3 of 3, and the validation layer run (A: main 2f161d4f33 with #9115's libSceNpTrophy2-only commit, which none of these tests load; B: 9ac1a20ce4) has no VUID- line and no was not found but was requested on either side; A has five of the six, since agc_uncounted_passes comes with this change. Before that, the rebase onto 7ab4b2e56 had one conflict too: #7966 added a depth1D check on the lines where this change adds firstSample, and both checks are kept.

  • agc_shader_memory, new verifyMultisamplePlaneReadMode: a sampled Dim2D access to the title's T# selects the float 2D runtime mode, and 2D MSAA T#s with 8- and 16-bit texels select the 2D mode of their numeric class (4x 8_UNORM and 4x 16_SINT in SW_64KB_R_X, 2x 8_UINT and 8x 16_FLOAT in SW_64KB_Z_X). A 4x 16_UINT SW_64KB_Z_X T#, which is read as depth bits, an access outside the measured set (cubeFaceCompatible false), a depth compare and a storage access are refused.
  • agc_driver_sample_multisample_target, new CheckFirstSampleReads: DIM 2D image_load, image_sample_lz and image_sample_l at LOD 1 through the 4x target's TYPE 14 T# return each pixel's sample 0, bit for bit, as the target's DIM 2D_MSAA image_load reads it. It checks every pixel of:
    • the drawn RGBA16F target, where some pixels' sample 0 differs from another of its samples, so a resolve would fail the check;
    • a BGRA8 target read through an RGBA8 T# (the red/blue swap);
    • zeroed memory no draw rendered to;
    • a drawn 4x 8_8_8_8_UINT target and 8_8_8_8_SINT color memory no draw rendered to, with negative channels, through the UINT and SINT passes. These two cases run only where sampledImageIntegerSampleCounts includes 4 samples (Vulkan requires only 1); elsewhere the test prints DIM 2D reads of 4x 8_8_8_8_UINT and 8_8_8_8_SINT targets not tested: sampledImageIntegerSampleCounts lacks VK_SAMPLE_COUNT_4_BIT and goes on. The RX 6700 XT runs them.
  • Red on main 7f596df48 with only this PR's tests: agc_shader_memory fails with descriptor format 56 decodes to {class 1, dim 6, ...}, the title's refusal, and agc_driver_sample_multisample_target with the same refusal for its RGBA16F target (format 71).
  • With only the recompiler half: agc_shader_memory passes, and the GPU test fails one step later, at the driver: guest texture dimension disagrees with the shader's declared image shape (shape 1, dimension 6).
  • Green: both pass 3 of 3 on 7f596df48, and after rebasing onto main fb0dc118f.
  • Head 5b7894778 (on main 7ab4b2e56): agc_shader_memory, agc_driver_sample_multisample_target, agc_driver_native_msaa_vertex_input, agc_driver_graphics, agc_uncounted_passes and agc_sample_dumps pass 3 of 3.
  • Head aae3228a5 (on main b85d972f4): agc_shader_memory, agc_driver_sample_multisample_target, agc_driver_native_msaa_vertex_input, agc_driver_graphics, agc_uncounted_passes and agc_sample_dumps pass 3 of 3, and once more after the controls below were restored and rebuilt.
  • Controls on aae3228a5, each built and run on its own, then restored:
    • the UINT pass reading sample 1: agc_driver_sample_multisample_target fails with a DIM 2D image_load of pixel (9, 11) read 00000000 00000000 00000000 00000000, sample 0 is 00000012 000000be 00000042 00000081 from a drawn 4x 8_8_8_8_UINT target;
    • the SINT pass writing its channels in reverse order: it fails with a DIM 2D image_load of pixel (0, 0) read ffffff81 ffffffbe ffffffff 00000012, sample 0 is 00000012 ffffffff ffffffbe ffffff81 from 8_8_8_8_SINT color memory no draw rendered to;
    • RGBA8 UINT and SINT taken through the float pass: the test passes on this driver, which copies those bits through the float pass. Only the validation layer catches it: VUID-vkCmdDraw-format-07753 (the view's numeric type must match the shader's sampled type), reported 10 times, the layer's default limit for one message, and 2 Undefined-Value-ShaderFragmentOutputMismatch warnings;
    • an element-size check in the gate (GetFormatInfo(format).byteSize >= 4u): agc_shader_memory fails at the 8_UNORM row with descriptor format 1 decodes to {class 1, dim 6, ...};
    • the gate without its depth-bits check: agc_shader_memory fails with a 2D read of a 16_UINT SW_64KB_Z_X 2D MSAA T#, read as depth bits, was accepted;
    • the integer cases' device check forced to report no 4-sample integer sampling: the test prints the line above, skips only those two cases, runs the rest and passes.
  • On an earlier head (e7ab9e7c1 on main fb0dc118f), the full ctest --parallel 4 --timeout 120: 1605 tests, 9 fail, none of which reads a multisampled texture:
  • Khronos validation layer (vulkan-sdk-1.4.363.0), VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1, ctest -V, same RX 6700 XT, on main 7ab4b2e56 and on 5b7894778, this change rebased onto it. agc_shader_memory, agc_driver_sample_multisample_target, agc_driver_native_msaa_vertex_input, agc_driver_graphics and agc_sample_dumps pass on both, and the new agc_uncounted_passes passes on 5b7894778 (6 of 6). Neither log has a was not found but was requested line or a VUID- error. The same environment reports the float-pass control above, so the layer was loaded.
  • python tools/check_conventions.py --base origin/main with this title and body passes.
  • In the title (@mrfelek, Linux, RTX 3080 Ti, main + fix(libc): give the scripting heap hooks blocks from libc's own heap #6842 + this PR at b216fe3a3): Peace Walker gets past the read main refuses, starts mgspw and reaches the title screen, with no image descriptor is incompatible in the log and no abort in 9 minutes on the title screen and its attract movies. Whether the picture at the copy matches a resolve was not compared.
  • With fix(agc): draw line lists and strips into a multisampled target with MSAA_ENABLE clear #8871 (@mrfelek, Linux, RTX 3080 Ti, main cecb540a6 + this PR 9ac1a20ce + fix(agc): draw line lists and strips into a multisampled target with MSAA_ENABLE clear #8871 593f4ab86, without local changes): Peace Walker plays through New Game into the beach tutorial at about 60 FPS, with no driver error in the log.
  • Apple M2 Max on MoltenVK (@jotitadev, head b216fe3a3 with the storage-multisampling gate moved below the sample-0 checks locally): the sample-0 and BGRA8 checks pass, and fail with the recompiler change reverted. MoltenVK has no shaderStorageImageMultisample. The gate has sat there since 09c3d719f, so devices without storage multisampling run those checks and skip only the fill, store and swizzle cases. The UINT and SINT cases are newer than that run.
  • Linux, RX 9070 XT on RADV (@blawesom, their rebase 7ecc1293f of head b216fe3a3): the full suite has no failures from this PR.
  • Linux, NVIDIA RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), head 9ac1a20ce on main a6dcea927 (@jotitadev): agc_driver_sample_multisample_target fails on both with ShaderResources.cpp and ResourceMaterializer.cpp reverted (image descriptor is incompatible with the static runtime image interface, the DIM 6 T#) and passes with this PR; lavapipe runs the multisampled storage-image path that MoltenVK skips. agc_uncounted_passes passes on both, and the rest of the ^agc suite matches main (NVIDIA 859/862, lavapipe 861/862, only failures main already has there).
  • Not tested: the console (gfx1013).

From the reviews of this change:

  • The copy pass is recorded through a new Recorder::RecordUncounted. When the recorder counts occlusion over a whole batch (the fallback without segment queries), it ends that query around the copy and starts a new one, and the batch's sample count sums them. agc_uncounted_passes checks it: two counted 64-sample draws around one uncounted draw give 128. Without the pause, it reads 192.
  • agc_driver_sample_multisample_target also checks that:
    • a read after the target is drawn again in another color returns the new sample 0 (if the copy is made only once, that read returns the old color);
    • with a BGRA8 and an RGBA16F 4x target live at one address, the RGBA16F read takes the matching target (if the lookup stops at the first mismatch, it throws);
    • the image_sample_l at LOD 1 uses an S# that allows it (MAX_LOD 15.99, point mip filter); the copy has a single level.
  • From the pre-merge review: FirstSampleCopy::Record takes the source view's layout instead of assuming GENERAL; the UINT and SINT passes are tested and the reads are compared bit for bit; 8- and 16-bit texels are measured and pinned in agc_shader_memory; both debt entries state the gap first and stay under 1000 characters.
  • Still not covered: the copy is redone on every binding even when the target did not change; the gate reuses cubeFaceCompatible, which fix(shader): store through DIM 2D image_store to a cube T#'s BASE_ARRAY face #6799 extended to mip-less stores (the gate still takes sampled reads only); and the GPU test reads through compute dispatches only, without bilinear filtering.

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: PPSA18216 METAL GEAR SOLID: Peace Walker - Master Collection Version (PPSA18216) #5268
  • GPUs tested: AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002 and 32.0.21045.16010, Windows 11 26200
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Oct 19, 2026
@github-actions

github-actions Bot commented Oct 19, 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 6498 core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp L956-964
PR 6973 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L628
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp L956-959
PR 6987 core/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hpp L69
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L628
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp L956-959
PR 6989 core/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hpp L69
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L628
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp L956-959
PR 6995 core/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hpp L69
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L628
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp L956-959
PR 7002 core/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hpp L69
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L628
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp L956-964
PR 8223 core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp L892-893
PR 8429 docs/dev/debt/shader.md L49
PR 8792 docs/dev/debt/shader.md L49-50

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 907 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 1368 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 1395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 1896 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 2434 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 4448 docs/dev/debt/libSceAgcDriver.md
PR 4449 docs/dev/debt/libSceAgcDriver.md
PR 5021 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
docs/dev/debt/shader.md
PR 5058 docs/dev/debt/libSceAgcDriver.md
PR 5371 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/shader.md
PR 5431 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 5925 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6044 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6186 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6187 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6188 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6192 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6194 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6202 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6209 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6223 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6235 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 6273 docs/dev/debt/libSceAgcDriver.md
PR 6280 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 6300 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 6412 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 6481 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6488 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/shader.md
PR 6501 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6539 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 6548 docs/dev/debt/libSceAgcDriver.md
PR 6549 docs/dev/debt/libSceAgcDriver.md
PR 6628 core/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp
PR 6642 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6743 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 6788 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6804 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6808 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6820 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6867 docs/dev/debt/libSceAgcDriver.md
PR 6868 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6924 docs/dev/debt/shader.md
PR 6970 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6971 core/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6977 docs/dev/debt/libSceAgcDriver.md
PR 7048 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7085 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 7201 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7256 docs/dev/debt/libSceAgcDriver.md
PR 7275 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7307 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7410 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 7449 docs/dev/debt/libSceAgcDriver.md
PR 7457 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7464 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7465 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7484 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/debt/shader.md
PR 7550 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 7604 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7618 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7622 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 7642 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7677 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7684 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/shader.md
PR 7689 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 7705 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7800 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7844 docs/dev/debt/libSceAgcDriver.md
PR 7910 docs/dev/debt/libSceAgcDriver.md
PR 7978 docs/dev/debt/libSceAgcDriver.md
PR 8014 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 8077 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/shader.md
PR 8246 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8319 docs/dev/debt/libSceAgcDriver.md
PR 8365 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 8484 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 8489 docs/dev/debt/shader.md
PR 8542 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 8552 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8564 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 8592 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 8740 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 8874 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8898 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 8998 core/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 8999 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 9020 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 9176 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9287 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9289 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9335 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 9356 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 9387 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9400 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9431 docs/dev/debt/libSceAgcDriver.md
PR 9432 docs/dev/debt/libSceAgcDriver.md
PR 9508 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9514 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 9521 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 9592 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9672 docs/dev/debt/libSceAgcDriver.md
PR 9673 docs/dev/debt/libSceAgcDriver.md
PR 9674 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9675 docs/dev/debt/libSceAgcDriver.md
PR 9676 docs/dev/debt/libSceAgcDriver.md
PR 9748 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/libSceAgcDriver.md
docs/dev/debt/shader.md
PR 9891 docs/dev/debt/libSceAgcDriver.md
PR 9892 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 9893 docs/dev/debt/libSceAgcDriver.md
PR 9895 docs/dev/debt/libSceAgcDriver.md
PR 9897 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 9898 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10026 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10046 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 10193 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/libSceAgcDriver.md

@thuanquang
thuanquang force-pushed the fix/msaa-2d-sample-zero branch from 2a725c5 to b216fe3 Compare October 19, 2026 08:30
@github-actions github-actions Bot added build shader core/shader docs agc libSceAgc* needs rebase Conflicts with main, rebase needed labels Oct 19, 2026
@blawesom

Copy link
Copy Markdown
Contributor

Rebase handoff — rebased onto current main cleanly (authorship unchanged).

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; conventions pass; full suite green apart from the four known main regressions (#5444 Mesa, #7584 BDA, #7766, #7784), none from this PR.

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/7803
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 7ecc1293f.

@jotitadev jotitadev 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.

Apple GPU / MoltenVK run. On Apple, agc_driver_sample_multisample_target is skipped as a whole, so the new sample-0 cases never run: MoltenVK doesn't expose shaderStorageImageMultisample, and the existing gate in main() returns before the first draw. The new cases don't seem to need storage multisampling. With the gate moved after them (local, test-only), they pass on both drivers, and they fail with the PR's driver and recompiler changes reverted.

Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0) and MoltenVK main + SPIRV-Cross #2704. Head b216fe3, PR diff applied cleanly.

Tested: the tree is main a373e85 + mugurc's macOS series (ci/macos-series-2) + the PRs needed to build on macOS (#6667, #6668, #7524, #6969, and two files of #7332), not plain main (it doesn't build on macOS yet). Applied together in the same build: #7666, #7811, #7799 and #7803, plus a test-only patch that lets nine AGC fixtures load the Vulkan loader on macOS (branch jotitadev:fix/agc-tests-vulkan-loader-macos). Base on that tree: 40 ^agc failures with MoltenVK 1.4.2 and 26 with MoltenVK main + #2704, plus agc_driver_pooled_buffer_range and agc_performance_overlay, which only run because of the loader patch.

  • With the PR, unchanged: agc_driver_sample_multisample_target reports multisampled target sampling not tested: storage image multisampling unavailable (skip). agc_shader_memory passes 3 of 3.
  • With the storageImageMultisample check moved below the std::puts("DIM 2D image_load, image_sample_lz and image_sample_l reads ...") line, the draw, LoadSamples and the first two CheckFirstSampleReads calls (the drawn 4x target, and zeroed memory no draw rendered to) run and pass on both drivers. Then the test skips at the moved gate. I also copied the BGRA8 block (DecodeSwappedTarget, CheckSwappedSamples and its CheckFirstSampleReads through an RGBA8 descriptor, format 56 as in the title) above the gate. All three first-sample checks pass, 3 runs of 3 on each driver. So the FirstSampleCopy pass works on Metal, including the check that sample 0 differs from the average.
  • With ResourceMaterializer.cpp reverted (test kept, gate moved), the test fails on both drivers with the refusal from the description, here for the test's format-71 target: image descriptor is incompatible with the static runtime image interface: descriptor format 71 decodes to {class 1, dim 6, ...}. agc_shader_memory fails the same way for format 56.
  • Full ^agc suite with the stack (gate moved): the base failures on each driver, nothing new and nothing gone.

Moving the gate below the first-sample checks (and the BGRA8 block with them) would let devices without storage multisampling, such as MoltenVK, cover this path. The store cases further down still need the gate.

GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704)

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@mrfelek

mrfelek commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

@thuanquang ran it in the title on Linux / NVIDIA.

Setup:

Result: the game gets past the read that main refuses.

  • In my earlier resolve runs, that read comes about 15–20 s after a cold start, when the game opens stagedat.pdt and samples the 1440x816 4-sample targets at 0x2754d0000 (your T#) and 0x277fc0000.
  • With this PR the game passes that point, starts mgspw and reaches the title screen.
  • image descriptor is incompatible doesn't appear anywhere in the log, and nothing aborted in 9 minutes on the title screen and its attract movies.

What I haven't checked: whether the picture at that moment matches my resolve's. My frame dumps from both processes went to the same file names, so the frames around the read were overwritten. If you need that comparison, I can rerun with frames saved around the read in both builds.

AI-assisted; the runs are from my machine(s).

@thuanquang
thuanquang force-pushed the fix/msaa-2d-sample-zero branch from b216fe3 to cbe3805 Compare October 19, 2026 12:52
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@adriadam10 adriadam10 self-assigned this Oct 19, 2026
@thuanquang
thuanquang force-pushed the fix/msaa-2d-sample-zero branch from cbe3805 to 09c3d71 Compare October 19, 2026 19:22
@thuanquang

Copy link
Copy Markdown
Contributor Author

@jotitadev thanks for the MoltenVK runs. The gate now sits below the sample-0 and BGRA8 checks (09c3d719f), so devices without shaderStorageImageMultisample run them and skip only the fill, store and swizzle cases. On the RX 6700 XT the test passes, and with the gate forced on, the sample-0 and BGRA8 checks run and pass before the skip.

@mrfelek thanks for running it in the title. I've added your result to the description.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 21, 2026

@jotitadev jotitadev 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.

Adds NVIDIA and lavapipe (native Linux). Worth noting lavapipe runs agc_driver_sample_multisample_target in full here, where on Apple through MoltenVK the whole test skips (no shaderStorageImageMultisample), so this is a red→green on a device that actually executes the multisampled storage-image path.

Tested

Ubuntu 26.04, GCC 15.2.0, Release, BUILD_TESTING=ON, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1, device selected with VK_ICD_FILENAMES, serial CTest, on main a6dcea927 (this PR applies cleanly on it; head 9ac1a20ce).

agc_driver_sample_multisample_target NVIDIA RTX 3070 (595.99.02) lavapipe (Mesa 26.0.3, LLVM 21.1.8)
main a6dcea927 + the PR's test only (ShaderResources.cpp and ResourceMaterializer.cpp reverted) fail fail
this PR pass pass

With the two production files reverted and the test kept, both devices exit non-zero in ShaderRecompiler::Recompile with:

image descriptor is incompatible with the static runtime image interface: descriptor format 71 decodes to {class 1, dim 6, ...}; modes: {class 1, dim 3, ...} ...

That is the DIM 6 (2D MSAA) T# that main cannot match to any of the DIM 3 (2D) runtime modes; with the full PR the recompiler reads it through DIM 2D as sample 0 and both devices pass. agc_uncounted_passes, the test this PR adds, also passes on both.

The rest of the guarded ^agc suite is unchanged from main on both devices: NVIDIA 859/862, lavapipe 861/862, i.e. main + the one agc_uncounted_passes this PR adds. The only remaining failures are the pre-existing ones main already has here (sample_order family on NVIDIA, multisample_retirement on lavapipe).

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02, Linux) and lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 22, 2026
@thuanquang
thuanquang force-pushed the fix/msaa-2d-sample-zero branch from 9ac1a20 to 0ad8aa3 Compare October 22, 2026 11:55
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 22, 2026
@thuanquang
thuanquang force-pushed the fix/msaa-2d-sample-zero branch from 0ad8aa3 to e0f6ea8 Compare October 22, 2026 20:34
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 22, 2026
A DIM 2D image_load or image_sample of a 2D MSAA T# returns sample 0 on
RDNA2 (RX 6700 XT, measured through HIP; bilinear blends sample-0 texels).
The recompiler now reads such a direct sampled access as a 2D image, and
the driver binds a one-sample copy of the target's sample 0, refreshed by
a fragment pass before each binding. Peace Walker (PPSA18216) stops on
this read at the end of its opening movie.

Co-Authored-By: Claude <noreply@anthropic.com>
@thuanquang
thuanquang force-pushed the fix/msaa-2d-sample-zero branch from e0f6ea8 to 0a3ea21 Compare October 23, 2026 05:30
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 23, 2026
@milescoviello

Copy link
Copy Markdown
Contributor

@thuanquang another title with this refusal, which this PR doesn't reach yet: Ghost of Tsushima Director's Cut (PPSA02225), Linux, RTX 4070 Ti (615.71.09), warm, 20 GiB.

The stop. A GoT stack on main 30ecc1b with this PR's 0a3ea213e1 merged stops at 485 s in its opening cinematic with the same message:

shader 0x20054f4e00 stage 5: image descriptor is incompatible with the static runtime image interface: descriptor format 22 decodes to {class 1, dim 6, ...}; modes: {class 1, dim 3, ...} (9 modes, all dim 3); T# 1544ed00 c1600000 021bc1df e1810924 00000000 00700010 00000000 00000000

That's a 2-sample 2D MSAA T# (TYPE 14, format 22) read through DIM 2D, the case this PR handles. The same stop appears without the PR.

Why the PR's path doesn't take it. A local diagnostic in inspectImageDescriptor printed multisamplePlaneRead's fields for every DIM 2D or 3D read of a 2D MSAA T#. The print is capped at its first 40 reports. These are the combinations among them in one run, T# words 0 to 3:

T# image dim table cubeFaceCompatible count
1544ed00 c1600000 021bc1df e1810924 2D 0 0 5
15477700 c1400000 021bc1df e1b10204 2D 0 0 4
1546eb00 c0500000 021bc1df e1810924 2D 0 0 4
1544ed00 ... and 1546eb00 ... 3D 0 or 1 1 2 to 4 each
1544ed00 ..., 1546eb00 ..., 15477700 ... 2D 0 or 3 1 2 each

depthCompare, r128 and atomic64 were 0 in all of them. So the title reads these targets through image tables (table is 0, 1 or 3, never NoTable), and in its most common shape also with ops that clear cubeFaceCompatible. multisamplePlaneRead requires both table == NoTable and cubeFaceCompatible, so none of these reads get the sample-0 decode.

One table entry, 00000091 c1600000 021bc1df e1810924, has a base address of 0x91, so some of these may be stale elements the shader doesn't sample.

I can't measure what RDNA returns for gather or the other ops behind cubeFaceCompatible = 0 on a 2D MSAA T#. Whether table elements can take the same sample-0 path (each element would need its own first-sample copy on the driver side) is your call. I can run a branch on this title whenever you want, warm or cold.

AI-assisted: yes (Claude Code)

@thuanquang

Copy link
Copy Markdown
Contributor Author

@milescoviello Thanks, that pins it down. This PR stays at the reads it has hardware data for: a non-table DIM 2D image_load without a mip, and image_sample, _lz or _l with no other sample flags (the reads that keep cubeFaceCompatible, ResourceTracker.cpp Merge). Your table also explains why it can't take Ghost of Tsushima's reads as they are:

  • Other ops. cubeFaceCompatible drops for image_load_mip, image_sample with bias, gradient, offset, compare or clamp flags, gathers, and packed or by-element reads. Each of those needs its own measurement of what RDNA returns for a 2D MSAA T# first. The PR body has one so far: image_load_mip with mip N returns sample N. If you can list which image instructions and sample flags those shaders apply to these T#s (the mnemonics from the recompiler's IR dump are enough, no shader binaries), I'll measure those on the RX 6700 XT through HIP, as for the others.
  • Table elements. The driver makes the one-sample copy per bound resource (MultisampleTargetFirstSample). A table element would need the same copy made per element when the table is resolved, which is a separate change.

So I'd keep this PR as it is and do both as a follow-up once the ops are known, and I'll ask you to run that branch on GoT.

@milescoviello

Copy link
Copy Markdown
Contributor

@thuanquang agreed: keep this PR as it is, and do the table elements and the other ops as a follow-up. I'm running GoT now with the shader cache off and APS5_DUMP_IR=20054f4e00, so that shader compiles in the run and its IR is printed. I'll post the image instructions and sample flags it applies to these reads (mnemonics only) when it's done, and I'll run the follow-up branch on GoT when you have one.

AI-assisted: yes (Claude Code)

@milescoviello

Copy link
Copy Markdown
Contributor

@thuanquang here are the ops. The IR dump never fired for that shader in a warm run, so I tagged two local diagnostics with the shader being prepared or materialized. One prints each 2D MSAA T# read through a non-MSAA dimension. The other prints each op that clears cubeFaceCompatible on a DIM 2D image. The run was GoT's opening on the same stack with this PR, and it stopped at 646 s with the same refusal.

Reads of 2D MSAA T#s through a non-MSAA dimension (T#s 1544ed00 ..., 1546eb00 ..., 15477700 ...; TYPE 14, 2 samples): 25 shaders. Two of them (0x20001dfd00, 0x20001e7200) read them through DIM 3D. The rest read them through DIM 2D.

What clears cubeFaceCompatible on DIM 2D images in those shaders, with mnemonics from the decoder table:

op sample flags count shaders
image_sample_a (0xa0) Adjust 419 20
image_sample_lz_o (0x37) LevelZero, Offset 228 19
image_sample_d (0x22), two gradients Derivative 22 1 (0x2000106500)

None had a mip, packed or by-element read. Four of the shaders clear it with none of these, so their reads keep cubeFaceCompatible: 0x200011bb00, 0x20052a7600 and the two DIM 3D ones.

A correction to my earlier comment about the shader that stops, 0x20054f4e00. Its read isn't a table element. The tracker sees that image with no table, and the stop comes from RuntimeImageMode, the direct path; a table decode would record a poison instead of throwing. Its only op that clears cubeFaceCompatible is image_sample_a, at pc 0x70 and 0x7c. So for the stop itself, image_sample_a is the read to measure. The table elements matter for the other shaders.

AI-assisted: yes (Claude Code)

@adriadam10
adriadam10 merged commit 83694b3 into boykopovar:main Oct 23, 2026
13 of 14 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Re-checked the interdiff: the first-sample copy now binds the source at its real layout, the 8/16-bit T# modes and the 16_UINT depth-bits refusal are pinned in verifyMultisamplePlaneReadMode, and the UINT/SINT execution case compares bits against sample 0. Rebase over the depth 1D/first-layer changes is correct; hardware semantics from your gfx1031 measurements in #5268, with runs from @mrfelek (PPSA18216), @jotitadev and @blawesom; merged.

@thuanquang

Copy link
Copy Markdown
Contributor Author

@milescoviello thanks for the op list and the correction on 0x20054f4e00. A branch to try on GoT: thuanquang:fix/msaa-2d-sample-zero-sample-ops, two commits on this PR's head 0a3ea213e1.

Measured on an RX 6700 XT (gfx1031) through HIP, for a 2-sample 2D MSAA T# (format 22, 16x16, SW_64KB_Z_X and SW_64KB_R_X, wrap addressing, X channel) read through DIM 2D:

  • image_sample_lz_o returns sample 0 at the offset texel: 12288 of 12288 lanes in each swizzle mode, offsets (0,0), (±1,0), (0,±1), (1,1), (-8,7) and (7,-8), point and bilinear.
  • image_sample_d with 2D gradients returns sample 0 at level 0 for every gradient tried (0 to 16 texels per pixel, a 4:1 ratio, point or linear mip filter): 13824 of 13824 lanes in each swizzle mode. A 3-level plain 2D control over the same memory does change level with the same gradients.

609685f12c reads those two ops that way, for 2-sample T#s only. Only format 22 was measured; GoT's 32_UINT and 8_UINT T#s go through the same rule without their own measurement, and the debt entry says what isn't covered.

0fd51df716 is a stopgap for image_sample_a, the op in 0x20054f4e00. LLVM has no encoding for it on gfx1031, gfx1030 or gfx1013, so it isn't measured; the commit takes its result as image_sample's (sample 0), since the recompiler already reads it as image_sample with the S# dword-3 bits 12-29 ignored. Those bits may well change the read on the console: PPSA01317 builds them from a wave ballot (6e5d708). So it should get past the stop, but the result may be wrong where those targets are read; please compare that part of the image. It's a separate commit so it can be dropped.

Still refused on the branch: the two DIM 3D shaders (0x20001dfd00, 0x20001e7200), image table elements, and these ops on 4- or 8-sample T#s. These reads also go through this PR's one-sample copy of the target, refreshed before each binding, so expect some extra GPU work there; I haven't measured it.

@milescoviello

Copy link
Copy Markdown
Contributor

@thuanquang thank you for measuring those two so quickly. I'm building GoT's stack with your two commits now (cold cache, then a full run), and I'll post where it stops and how the frames around those targets look. If 0x20054f4e00 gets past its read, I'll compare that part of the image against the frames before it.

AI-assisted: yes (Claude Code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build docs shader core/shader unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants