feat(shader): offer a 2D MSAA mode to GCN image loads #21961
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21961"
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 adam25136 on 2026-11-16T23:15:06Z.
What
GCN MIMG instructions have no DIM field, so a GCN image instruction is decoded as 2D (2D array with DA), and the T# type picks one of the runtime modes the recompiler offers for it (for example 1D, 3D or cube; see the
GCN image dimensionsentry indocs/dev/debt/shader.md). In inFAMOUS Second Son, compute shader0x2f2fa2500loads fragment 0 of the title's 2-sample depth buffer this way. No 2D MSAA mode was offered, so a GCN shader that loads a multisampled depth or colour target was refused withimage descriptor is incompatible with the static runtime image interface ... dim 6.image_loadtakes for its 2D MSAA dimension (IntrinsicsAMDGPU.td L1119, L1403-L1406, the commit the existing entry cites).image_load_miphas no multisampled form (L1407-L1410), so a mip load is not offered the mode.SpirvImageEmitter.cpp's GCN address remap counts the extra component of a multisampled mode, so the fragment index becomes theSampleoperand of the image fetch, through the multisampled read path PS5 (RDNA) shaders already use.fmaskCompatibleandcubeFaceCompatibleare both set, which means every use is a 32-bit load without a mip, sample flags or packing (the same pair the RDNA plane mode of a multisampled image requires). All modes of an image are emitted into one shader, so a mode that could not serve every use would fail the whole compile.describeGcnSurface(PS4 multisampled textures are not implemented); inFAMOUS stops there (see Tested). This is the recompiler half; the driver half needs the GCN multisampled surface layout.GCN multisampled loadsentry, including that the fragment index is used as the host image's sample index while guest FMASK is not modelled.Tested
Windows 10 Pro 22H2 (19045), NVIDIA GeForce RTX 5080 (driver 621.14), WinLibs GCC 15.2.0 (r7), CMake 4.3.2, Release, this branch on
mainbc84729655.main's ownagc_driver_upload_cache_read_only_flush_testsdoes not build with MinGW (setenv; #19899 fixes it), so the builds went on past it.agc_shader_memory_tests(ctestagc_shader_memory_coherent_atomic_loads) pass:fmaskCompatiblefalse), is not a plain load (cubeFaceCompatiblefalse), sits in a table, or has DA does not;image_loadprogram through that T# compiles to anOpImageFetchof a multisampled image, with x and y from the first two address registers and theSampleoperand from the third;image_load_mip) and a sample through that T# are still refused.-DANYPS5_ENABLE_SPIRV_TOOLS=ON, where the recompiler runs SPIRV-Tools' validator on each module it compiles.tools/select_tests.pyselects for the 4 changed files (ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1), onmainand on this branch: no test fails only on the branch, and both runs skip the same 19. Three fail on both:agc_driver_bda_device,agc_driver_stencil_plane_memory, andagc_driver_upload_cache_read_only_flush(not built).agc_driver_store_over_untrackedalso failed inmain's run. In earlier runs on3c9ddc9668ande2e155da47it failed on both sides from run to run (a pending storage result was stored over bytes the CPU wrote to untracked memory).frame_capture_minimize, which passed on both here, failed in 2 of 4 branch runs on3c9ddc9668and 0 of 4 onmainthere, each time aPermissionErrordeleting a temporary file.VK_LAYER_KHRONOS_validation1.4.367 (throughVK_ADD_LAYER_PATH) withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,VK_LOADER_LAYERS_DISABLE=~implicit~,ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1,ctest -V, onmainand on this branch. The 50 tests run were those matchinggcn|multisample|msaaplusagc_shader_memory_coherent_atomic_loads, and all pass. Each log has 49Insert instance layer "VK_LAYER_KHRONOS_validation"lines, no "was not found" line and noVUID-message. 43 of the 50 create a Vulkan instance. 7 create none,agc_shader_memory_coherent_atomic_loadsamong them, so the layer sees none of the new rows; SPIRV-Tools validates the module the address row compiles.main3c9ddc9668merged locally with #18235, #17711 (keepingmain's text where it conflicts inlibSceGnmDriverForNeoMode/Export.cpp), #18184 and two local changes the title needs to get this far, not open as PRs yet: the DiscMap export the closed #10531 implemented, and the all-"any" case ofsceVideoOutConfigureOutputMode_asked about on #15134. One start ran with this branch and one without it (ase228d90fca, the same diff before its rebase). Without it, the start ends with thedim 6refusal of compute shader0x2f2fa2500quoted above. With it, that refusal is gone, and the start ends at the same dispatch withAGC graphics: PS4 multisampled textures are not implemented.python tools/check_conventions.py --base origin/main --title "<this title>" --body <this description>:All conventions checks passed.python tools/pr_overlap.py --branch: 89 of the 1,589 open PRs share files or exports with this branch. It compared 50 with no overlap and could not compare 39 that conflict withmain(exit 2). Checked by text, no hunk of those 39 contains, changes or adds a line of this branch's hunks (lines that repeat in the file or are under 12 characters not counted). The exceptions are #5371 and #16260: each adds a test call near this branch's inShaderMemory.cpp'smain(), and that call merges with ours without a conflict (git merge-fileonbc84729655's file).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)AI-assisted: Claude Code found the refused shader in an inFAMOUS Second Son run, wrote the change and its tests, ran the tests, and drafted this description; separate review agents checked it.
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T17:03:22Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected changes add a GCN 2D MSAA image-load mode and remap the fragment address component to the SPIR-V sample operand; I found no verified blocking defect.
What I ran
Reviewed head
b1bc3a90f5353870184081307441fe959cde9827usingrepo_read.py. No tests or builds were run.Read
review/description.md,review/commits.md,review/manifest.json,review/diff.patch,ResourceMaterializer.cpp,SpirvImageEmitter.cpp, the changed ranges and relevant context inShaderMemory.cpp, anddocs/dev/debt/changes/fix-gcn-msaa-image-loads.md. The test file’s full text was excluded as too large for the review folder; only changed ranges and relevant context were read.review/files.jsonwas not available through the reader.Results
Findings
Blocking
None verified in the inspected changes.
Non-blocking
None.
Not verified
Tests, builds, and runtime behavior were not independently verified. The full
ShaderMemory.cppfile andreview/files.jsonwere not read. Hardware behavior and the driver-side multisampled surface implementation are outside the inspected change; the description reports that binding still throws.To get this to a good state
Nothing is required.