Skip to content

feat(agc): sample a multisampled color target through its 2D MSAA texture - #4820

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
nicolasabosch:feat/agc-sample-msaa-color
Oct 14, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
nicolasabosch:feat/agc-sample-msaa-color

Conversation

@nicolasabosch

@nicolasabosch nicolasabosch commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What

A shader that loads from a 2D multisampled image no longer stops at DescriptorBindingBuilder::Populate multisampled image resources have no descriptor image shape when the image is a color target that draws rendered on the host. Part of #3036.

  • DescriptorBindingBuilder gives a 2D multisampled image the new shape DescriptorImageShape::Image2DMultisample. Multisampled arrays still throw.
  • DecodeTextureResource decodes T# type 14 as TextureDimension::k2DMsaa. The sample count is 1 << LAST_LEVEL, with BASE_LEVEL 0 and MAX_MIP equal to LAST_LEVEL, as ac_build_gfx10_texture_descriptor writes them (Mesa src/amd/common/ac_descriptors.c, 1e2c42b6). A descriptor that differs throws. The surface decodes with one mip level.
  • A sampled multisampled T# is bound as a view of the multisample target at its address (MultisampleTargetTexture), when the target has the same format, size and sample count. The target's image gets VK_IMAGE_USAGE_SAMPLED_BIT when the device can sample its format at that sample count. Nothing is read from or written to guest memory.
  • These throw: a T# over a target of another size, format or sample count; a T# no draw rendered to; storage access; a target whose CMASK fast clear no draw has applied; a device that cannot sample the format; a lookup outside a recorded draw or dispatch; a draw that samples the target it renders to.
  • A uniform fill of the target's color memory that no draw has applied yet (fix(agc): clear a multisampled target on a uniform fill of its color memory #2132) is applied before the target is sampled.
  • Resources that sample a multisample target are not kept for reuse, because the lookup records the barrier between the target's writes and the read.

No instruction semantics change: the SPIR-V for image_load on a 2d_msaa image (OpImageFetch with the sample operand) is already on main.

Open pull requests that tools/pr_overlap.py has listed against this one as main moved, none of which implements this: #4767 (FMASK decompress on multisampled targets) changes MultisampleTarget and applies pending CMASK fast clears to the host image, the state this change refuses to sample, so whichever merges second adjusts that check; #4790 (FMASK images from a metadata snapshot) changes the same lookup in ShaderResources.cpp; #4451 adds an adjacent line in CMakeLists.txt.

Not covered, still throwing as before: FMASK, compressed samples, EQAA, multisampled depth, multisampled arrays, and multisampled textures that are not host-rendered targets.

Tested

Windows 11, NVIDIA RTX 4070 Laptop GPU, WinLibs GCC 15.2.0 r7, Release, ANYPS5_ENABLE_SPIRV_TOOLS=ON, at e7cf856f0, which has main e51428bf2 merged in.

  • New agc_driver_sample_multisample_target: draws a triangle into a 16x16 RGBA16F 4x target, then a compute shader loads every sample through the T# with image_load on 2d_msaa. All 1017 samples farther than 1/32 pixel from an edge match the triangle's coverage at SampleLocations(state); the other 7 are only checked to hold the drawn or the cleared color. 14 pixels are partly covered. With the expected sample order rotated by one the test fails. It then fills the target's color memory with half-float ones and every sample loads as (1, 1, 1, 1); without the fill being applied at the lookup that check fails. It also checks the refusals for a T# of 8 samples over the 4x target and for a T# no draw rendered to.
  • agc_multisample_guest_access (extended): the 4x target binds as a sampled texture in its layout, a second lookup returns the same texture, and the refusals for another sample count, another width, no target and storage access.
  • agc_driver_graphics (extended): type 14 decoding, including the T# PPSA99006 passes (021f2000 03800000 804a004a e1b20fac 00000000 00400020 00000000 00000000), and its rejections.
  • Full ctest -j 8: 1029 passed, 8 skipped, 0 failed, out of 1037.
  • At 4e6a15edd (merged with main 30f961266): the sampled lookup skips targets retired when their allocation was unmapped, as attachment acquisition already does since fix(agc): retire fully unmapped multisample targets #4474. Reported with a fixture and the one-line correction by Amoenus in feat(agc): sample a multisampled color target through its 2D MSAA texture #4820 (comment). agc_multisample_guest_access now samples after each remap: without the line it fails (sampling a multisampled target whose allocation was unmapped did not throw), with it it passes 5 of 5, and a target acquired at the same address is sampled through a new texture. Full ctest -j 8 there: 1103 passed, 8 skipped, 0 failed, out of 1111. The title was not rerun at this commit.
  • PPSA99006 01.000.010 (catalog build, relinked with --windows --to-intel), at e7cf856f0 with main e51428bf2: one 46 s run does not stop. The title's log reports 600 frames (mean 19.98 ms, max 25.07 ms) and 902 present calls with 0 failures. Before fix(agc): size multisample guest guards by fragment blocks #4199 was merged the title stopped at the guard range (a CPU read of 0x21f400000+0x90000 overlaps multisampled color target 0x21f200000+0x240000) after the two lookups of its first 4x canvas.
  • The same title with this branch merged locally into the later main 7e181fcc3: 3 of 3 runs stop before present 300 with buffer descriptor uses an unsupported type. With perf(agc): present and keep pending only the drawn slice of an array color target #4935 merged as well, 3 of 3 runs of 26 s do not stop, and a frame dumped with APS5_DUMP_FRAMES shows the title's menu with its game thumbnails. Why this branch alone stops there was not investigated.
  • With a saved 2048 game in the title's download0, it stops at this change's own refusal, sampling the 91x145 multisampled texture 0x220c00000 of 4 samples, which no draw rendered to, is not implemented: the title clears that canvas (clear-msaa4-color in its log) and samples it without drawing into it.
  • Linux, Intel Xe (ANV), reported by nicolasfalesy in feat(agc): sample a multisampled color target through its 2D MSAA texture #4820 (comment) on main 37dd48308: the descriptor shape stop is gone and 3 of 3 runs then stop at image descriptor is incompatible with the static runtime image interface, where the title's resolve shader (image_load on 2d_msaa) is given a T# of type 2D. That stop did not occur in the Windows runs above; not investigated.
  • Windows, AMD Radeon 860M, reported by LeandroLP23 in feat(agc): sample a multisampled color target through its 2D MSAA texture #4820 (comment) on main 9ba9ac1c8: ctest -R '^agc_' 461 of 461, and the title runs 60 s at about 13 FPS.
  • The same machine, reported by LeandroLP23 in feat(agc): sample a multisampled color target through its 2D MSAA texture #4820 (comment) on main dacd78525, three 60 s runs per build: this branch alone does not stop in any of them (window FPS 11.67 to 12.49); with perf(agc): present and keep pending only the drawn slice of an array color target #4935 as well, 3 of 3 do not stop (24.42 to 25.86).
  • Windows, RTX 3080, reported by babyhuey in feat(agc): sample a multisampled color target through its 2D MSAA texture #4820 (comment) on main ea2bbefb: the descriptor shape stop is gone and the title then stops after 7.7 s at runtime image descriptor is invalid, on a T# whose type field is 0; the tests of this change pass 5 of 5 there.
  • The stops after this change differ by machine and main (an unsupported buffer descriptor type here on 7e181fcc3, an invalid image descriptor on the RTX 3080, a 2D T# in the resolve shader on Intel, none on the Radeon 860M on dacd78525). Here the stop goes away with perf(agc): present and keep pending only the drawn slice of an array color target #4935; whether the RTX 3080 and Intel ones do is not known.

Not tested here: Linux, AMD and Intel GPUs, lavapipe, sample counts other than 4, and formats other than RGBA16F in the execution test. The Linux and AMD results above are the reporters' own.

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
  • Unblocks: PPSA99006 ProsperoPuzzles (PPSA99006) on Windows / NVIDIA: MSAA blockers #4427
  • GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, driver 616.92, Windows 11 (26300). The AMD, RTX 3080 and Intel results above are the reporters' own.
  • AI-assisted: yes

🤖 Generated with Claude Code

@nicolasfalesy

Copy link
Copy Markdown
Contributor

Tested with ProsperoPuzzles (PPSA99006, catalog release, --to-intel) on Linux (Arch, Intel Xe on Mesa 26.2.2 ANV, Release), this PR (e7cf856) merged onto main 37dd483, 3 runs of 60 s.

[videoout] presentation failed: image descriptor is incompatible with the static runtime image interface: descriptor format 1 decodes to {class 1, dim 3, conversion 0, packed 0, cube 0, depthBits 0, unorm16 0, srgb 0}; modes: {class 1, dim 6, ...} {class 2, dim 6, ...} {class 3, dim 6, ...} ... {class 1, dim 6, conversion 0, packed 156, ...}; T# 021ea000 c0100000 804980ff 91b00204 00000000 00400000 00000000 00000000

So the shader's static interface for this binding is now the 2D MSAA shape (dim 6) in every mode, while the T# the title binds at that draw decodes as dim 3. Whether that T# is a plain 2D view of the MSAA target or a different resource I haven't traced; the full T# is above in case it helps. Happy to rerun on a new head.

Tested with Claude Code assistance.

@nicolasabosch

Copy link
Copy Markdown
Contributor Author

@nicolasfalesy thanks for the runs, that is a result I did not have: nothing here was tested on Linux or on Intel.

That stop is a separate one from what this PR changes. The T# in your log (021ea000 c0100000 804980ff 91b00204 ...) is type 9, a plain single-sample 2D texture, and it reaches the title's resolve shader, whose four loads are image_load on 2d_msaa. So the shader's image interface is multisampled in every mode and the recompiler refuses a 2D descriptor for it. I saw the same message once on Windows, early on and with a local guard patch, and not since: the Windows runs listed in the description do not hit it. I have not traced why the two differ, so I can't say whether it is the driver path, the order of the title's draws or the main under it.

What the hardware returns when a 2d_msaa load is given a single-sample T# is an instruction-semantics question, so it needs a source or a hardware measurement and its own change; I have not started one. I added your report to the description so the PR does not read as if the title ran on Linux.

If you rerun, the later main matters: on 7e181fcc3 this branch alone stops earlier for me (buffer descriptor uses an unsupported type), and #4935 is what gets past that on Windows.

AI-assisted: yes (Claude Code).

@babyhuey

Copy link
Copy Markdown
Contributor

Windows 11 run (RTX 3080, NVIDIA 591.86, WinLibs GCC 15.2, Release): head e7cf856 merged onto main ea2bbef (clean merge), ProsperoPuzzles (PPSA99006, catalog release), default flags.

  • main: exits 0xC0000409 after 6.0 s on DescriptorBindingBuilder::Populate multisampled image resources have no descriptor image shape.
  • With this PR, that throw is gone. It exits 0xC0000409 after 7.7 s on runtime image descriptor is invalid (ResourceMaterializer.cpp:496).
  • The throw doesn't print the descriptor. A temporary local print gave 0e5d8000 00600002 00000033 00005204 00000000 00000000 00000000 00000000. Its type field (dword 3, bits 31:28) is 0, so this doesn't look like the type 9 T# from the Linux run above. I haven't traced which resource slot it comes from.
  • These pass 5/5 (--repeat until-fail:5): agc_driver_sample_multisample_target, agc_multisample_guest_access, agc_driver_graphics, agc_sparse_buffer_holes, agc_descriptor_pool_reset_failure and agc_compute_descriptor_layout_flags. There are no warnings in the 14 files this PR touches.

@LeandroLP23

Copy link
Copy Markdown
Contributor

Ran this on AMD hardware, since the GPU tests in CI run only on lavapipe: Windows 11 (26300), Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release. Head e7cf856f0 merged onto main 9ba9ac1c8.

  • ctest -R '^agc_' -j 1, test shader cache emptied: 461/461. main is 460/460 on the same machine.
  • ProsperoPuzzles (PPSA99006), relinked with --windows --trap-sdk-syscall-stubs, 60 s run:
    • main: DescriptorBindingBuilder::Populate multisampled image resources have no descriptor image shape, exit after 15 s.
    • With this PR: runs the full 60 s, window title ProsperoPuzzles | FPS: 13.18.

AI-assisted: yes (Claude Code)

@nicolasabosch

Copy link
Copy Markdown
Contributor Author

@babyhuey @LeandroLP23 thank you both, and @nicolasfalesy again. The AMD run is the first one on that vendor, and I added all three reports to the description.

A request for @babyhuey and @nicolasfalesy, if you have the time: could you rerun with #4935 merged as well?

The reason is a hypothesis, not something I have verified on your setups. After this PR the title stops in a different place on each machine: runtime image descriptor is invalid with a type 0 T# on the RTX 3080, a type 9 T# reaching the 2d_msaa resolve shader on Intel, and buffer descriptor uses an unsupported type here on main 7e181fcc3. All of them are a descriptor the title hands over that looks wrong. This title's display buffers are slices of two-slice targets, and without #4935 the driver marks the whole array image pending after each draw, including the slice no draw rendered, whose memory is where the title uploads its per-draw data. Stale units of that slice are then stored back over it. That would explain descriptors that differ from run to run, and here the stop goes away with #4935 (3 of 3 runs). If yours go away too it is one bug; if not, they are separate and I was wrong to group them.

@LeandroLP23, the 13 FPS matches what I measured before #4935 (33 to 48 ms per frame on an RTX 4070); with it the title holds 16.7 ms here. An AMD number with #4935 would be useful, but only if it is convenient.

AI-assisted: yes (Claude Code).

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the diff, built it merged onto current main and ran the scoped ctest for libSceAgc/libSceAgcDriver: agc_driver_sample_multisample_target, agc_driver_graphics, agc_multisample_guest_access and the recorder tests pass. Without the non-test changes the new tests do not compile (k2DMsaa, samples are missing), so they depend on the change. Refusals (other size/format/sample count, no draw, storage access, arrays) all throw. The Windows results from @babyhuey and @LeandroLP23 cover the vendors we can't run here; merging once the full Build is green.

@LeandroLP23

Copy link
Copy Markdown
Contributor

@nicolasabosch Thanks. I can't run it right now. If someone else with an AMD GPU can, please go ahead; otherwise I'll post the AMD number with #4935 merged as well later today or tomorrow.

@LeandroLP23

Copy link
Copy Markdown
Contributor

@nicolasabosch AMD numbers, same machine as before: Windows 11 (26300), Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release. Both builds are on main dacd78525. PPSA99006 01.000.010 was relinked with --windows --trap-sdk-syscall-stubs, and every run is 60 s from a fresh run directory, with no save in download0.

Build Runs without a stop Window FPS at 60 s [PPZ] mean, frames 1-600 [PPZ] mean, frames 601-1200
#4820 (e7cf856f0) 3 of 3 12.49, 11.99, 11.67 84.62, 85.76, 83.41 ms not reached
#4820 + #4935 (9d53a588f) 3 of 3 25.86, 24.42, 25.22 41.46, 41.93, 45.43 ms 39.62, 38.81, 40.05 ms (max 84 ms)

With #4935 the frame time roughly halves here, but it stays near 40 ms rather than 16.7 ms. On this machine #4820 alone did not stop in any run: the buffer descriptor uses an unsupported type stop you see on 7e181fcc3 did not appear in these three.

AI-assisted: yes (Claude Code)

@nicolasabosch

Copy link
Copy Markdown
Contributor Author

@Amoenus thank you for the fixture and the correction. It is applied in 4e6a15edd: the sampled lookup now skips targets whose allocation was unmapped, the same check attachment acquisition has since #4474.

I reproduced it here before applying it, with main 30f961266 merged: agc_multisample_guest_access now samples after each remap, and without the line it fails (sampling a multisampled target whose allocation was unmapped did not throw); with it it passes 5 of 5 on an RTX 4070 Laptop, and a target acquired at the same address is sampled through a new texture. I did not run your fixture itself. Full ctest -j 8: 1103 passed, 8 skipped, 0 failed, out of 1111.

Noted on #5445: once it lands, the lookup after a remap may import uniform memory instead of refusing, so that assertion of the test changes there and the new-contents one stays.

AI-assisted: yes (Claude Code).

@dantdmdarealguy

Copy link
Copy Markdown
Contributor

Windows 11 Pro, Intel Core i9-14900K, 128 GB, NVIDIA GeForce RTX 5080 (driver 32.0.16.1714), WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON. Head 4e6a15eddd and its merge base 30f961266a, each built in the same build directory. ProsperoPuzzles (PPSA99006 01.000.010, catalog release), eboot.bin and sce_module/libc.prx unwrapped, relinked from each build with relinker --windows --registry, original eboot.bin kept in app0, fresh run directory per build.

Tests

  • Head: agc_driver_sample_multisample_target, agc_multisample_guest_access, agc_driver_graphics and patched_libraries pass 3 of 3 (--repeat until-fail:3). agc_driver_sample_multisample_target with ANYPS5_REQUIRE_VULKAN=1 selects NVIDIA GeForce RTX 5080 vendor=0x10de device=0x2c02 subgroup=32 and prints its pass line, so it did not skip.
  • Head: ctest -R "^agc_": 485 of 486 pass, 1 skipped (agc_driver_stencil_ref_export), 0 failed.
  • Base: agc_multisample_guest_access, agc_driver_graphics and patched_libraries pass; agc_driver_sample_multisample_target doesn't exist there.
  • The incremental head build has no warnings. tools/check_conventions.py --base 30f961266a and tools/check_test_registration.py pass.

ProsperoPuzzles, 60 s runs

  • Base, 3 of 3 runs exit 0xC0000409 after 6.7 to 7.2 s:
    what():  DescriptorBindingBuilder::Populate multisampled image resources have no descriptor image shape
    
  • Head, 3 of 3 runs last the full 60 s with no exception, then close with exit 0 on WM_CLOSE. The menu draws all 50 game cards with their thumbnails. Window title FPS at 57 s: 33.31, 31.86, 38.47; the title's overlay shows 39 FPS.
  • Head, a fourth run: Cross (Return) opens 2048 and four slides play at 59.95 FPS. In a fifth run with that save in download0, Cross resumes the saved game (score 1,560, 151 moves) at 60 FPS. Neither run threw. The which no draw rendered to refusal from the description, seen there with a saved 2048 game, did not occur here.
  • The head logs have no failed, not implemented or error lines.

Screenshots on the head (the base exits before the first screenshot at 15 s):

Menu at 57 s, 2048 after the slides, resumed save

Menu at 57 s

2048 after four slides

Resumed save

Verdict: works on Windows with an RTX 5080. The stop is gone, and the title runs and plays without #4935 on this base.

@oneandonlydean oneandonlydean self-assigned this Oct 14, 2026
nicolasabosch and others added 3 commits October 14, 2026 23:59
…ture

A shader that loads from a 2D multisampled image whose T# names a color
target rendered on the host is bound to a view of that target's image.
Other multisampled textures keep throwing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mpled target

A uniform fill of a multisampled target's color memory is held until the
next draw. A shader that samples the target first now sees the fill.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Rebased onto main: kept your multisample sampling next to the recent MSAA fill and alpha-to-coverage changes; build and agc tests pass.

@oneandonlydean
oneandonlydean force-pushed the feat/agc-sample-msaa-color branch from 4e6a15e to 84f6364 Compare October 14, 2026 11:03
@github-actions

github-actions Bot commented Oct 14, 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
#4767 core/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hpp L51
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L382
#5939 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L166-167

@johnohhh1

Copy link
Copy Markdown
Contributor

Independent Linux/RTX 5070 title validation after this PR merged. I compared the exact merge 8b8bfe0b6e69c0ccdf4fdb932a8c807df5b24783 with its first parent 38c0bfa33a85541dd35a219aaaeadf49d4bc9c31, without other pending PRs.

Ubuntu 26.04.1 x86-64, GCC 15.2.0, bundled Release build with testing/SPIR-V Tools enabled; NVIDIA GeForce RTX 5070, driver 595.99.02.

Title: ProsperoPuzzles, PPSA99006, content version 01.000.010, developer release. Package SHA-256: 9c7c7b57a885b1ecbd694ee32f7f68847ae909d99600b4c6a73c06605affd313. Both builds used the same unwrapped homebrew inputs, fresh conversions and separately staged matching system libraries.

  • Before: aborts with SIGABRT after 2.25 s, before any presented frame: DescriptorBindingBuilder::Populate multisampled image resources have no descriptor image shape.
  • After, menu: lasts the full 45 s without that exception; captured frames show the game library and thumbnails.
  • After, 2048: another 45 s run accepts Cross plus four directional moves. The captured board shows score 8 and four moves; the title writes its save/stat files.
  • After, resume: a 30 s relaunch logs launch game=g2048 resumed=1 and restores that board. The final board PNG and save/stat file hashes match those from the played run. These bounded game runs were deliberately stopped with SIGINT and returned 0.
  • Full builds pass on both revisions. All 10 selected baseline suites and 11 selected merge suites pass without skips, including the added agc_driver_sample_multisample_target. Serial CTest, Vulkan required, explicit NVIDIA ICD/device, 30-second per-test maximum; longest selected test is 5.02 s. Conventions, whitespace and test-registration checks pass.

This verifies Linux title progress and the sampled MSAA regressions at the recorded merge, not all 50 puzzles or later main. SDL dummy audio was used; audible output was not tested. Project shader cache was disabled, NVIDIA driver caching stayed at defaults, and no performance comparison or native PS5 measurement is claimed.

AI-assisted testing/report: Codex. The implementation and its original author are unchanged.

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

Labels

agc libSceAgc* build shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants