fix(agc): sample a multisampled target whose format differs only in red/blue order #7253
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7253"
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 milescoviello on 2026-10-17T19:49:55Z.
What
MultisampleTargetTexturesamples a native multisampled color target only through a texture of the exact format it was rendered in. Any other format is refused.Rush 2 (PPSA69423) and Wave Race 64 (PPSA69424) render a 3840x2160 8x target as
8_8_8_8with the alternate component swap, which decodes toB8G8R8A8_UNORM. They then sample it through an8_8_8_8UNORM T#,R8G8B8A8_UNORM:Both formats store four bytes per sample. A B8G8R8A8 target holds blue, green, red, alpha in that byte order, so reading it as R8G8B8A8 returns blue as red and red as blue.
For the B8G8R8A8/R8G8B8A8 pairs of the same numeric type (UNORM, SRGB, SNORM, UINT, SINT), the texture is now the target's own image. The image keeps its format and gets a component mapping with red and blue exchanged, composed with the T#'s swizzle (
swapRedBlue). Every other format difference is still refused. Storage views of the target are unchanged.Tested
Linux (Ubuntu 24.04, GCC 13.3, Release), RTX 4070 Ti, NVIDIA 595.99.02;
main922dc8999.agc_driver_sample_multisample_target: a new case draws into a 16x16 4x8_8_8_8target with the alternate swap and loads every sample through an8_8_8_8UNORM T#. Drawn samples must read the drawn color with red and blue exchanged, within half a unorm step.The case draws exact UNORM8 codes (64, 128 and 32 of 255) from its own pixel program and checks within half a code. My first version drew 0.5 green, halfway between two codes; llvmpipe rounds 127.5 up and failed it with red and blue correctly swapped (CI report).
7c4bc9a0bafixes the test. On llvmpipe (LLVM 20.1.2) and NVIDIA it now passes 3 of 3 each.With
main'sMultisampleTarget.cppit fails withsampling multisampled color target ... (16x16, 4 samples, vk format 44) as a 16x16 texture of 4 samples and guest format 56 (vk 37) is not implemented. With this change it passes 3 of 3.ctest
^agc_(662 tests, NVIDIA): all pass.On the Intel Arrow Lake VM (Mesa 26.1.6 ANV) this test binary stops before the new case. It fails on its multisample storage-image check, as on
main, which #7191 addresses. So the case is checked on NVIDIA only.Titles, 60 s each with scripted pad input. Base is
main5859889b2with #6543 and #7250 (b4e35279a) merged; #7250 takes the per-frame DCC fast-clear fills of the same targets.check_conventions.pypasses.pr_overlap.pylists the multisample work that changesMultisampleTargetTexture's neighbourhood (#6635, #6971, #6973, #6987, #6989, #6995, #7002) and #6498 in the same test file. None of them changes how a texture's format is matched. I'll rebase onto whichever lands first.Not checked on Windows, on AMD, or on a console.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T20:34:22Z.
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.
main)core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppL678-679, L687core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppL303, L305-306core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppL678-679, L687Some 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.
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T21:39:51Z.
Full CI on
90c3b61c6(merged into main922dc8999): the Linux job failsagc_driver_sample_multisample_targeton llvmpipe (Mesa, LLVM 20.1.2). The steps before the new case pass, and the new case fails its value check:The swap itself looks right to me. I think the check is too tight for an 8-bit target.
Drawnis{0.25, 0.5, 0.125, 1.0}, and the green 0.5 lands exactly halfway between two UNORM8 codes (0.5 × 255 = 127.5). Vulkan only says the float-to-UNORM conversion should round to nearest, so a device may store 127 or 128. In float32:0.5f / 255.0fA device that rounds 127.5 up fails the check even when the red/blue swap is correct. If the device truncates instead, 0.25 → 63 and 0.125 → 31 also fail the check. So this tolerance only passes on a device that rounds to nearest and rounds 127.5 down.
Suggested fix (test only):
{64/255, 128/255, 32/255, 1}. Alternatively, allow 1/255 per channel. R and B differ by 32 codes, so an unswapped read still fails either way.Requiremessage, so a failure on another driver shows whether it's rounding or a real channel-order problem.One more possibility: llvmpipe could ignore the view's component swizzle on a multisampled fetch. The new message would separate the two cases (R and B unswapped vs off by one code). If it turns out to be the swizzle, we'll need another approach for that driver, so please mention it if you see it.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-17T21:54:29Z.
Thanks @oneandonlydean, that's what it was. I reproduced it locally on llvmpipe (Mesa, LLVM 20.1.2, through
ANYPS5_GPU=llvmpipe): the case fails 3 of 3 on90c3b61c6and passes on NVIDIA.With your message change and the old color, llvmpipe reports:
Red and blue are swapped correctly. The device rounded green's 127.5 up to 128, one float ulp past the half-code tolerance, as you worked out. So the view swizzle works on llvmpipe's multisampled fetch.
7c4bc9a0ba(test only):Unorm8PixelCode).Drawtakes the pixel code as an optional parameter, so the other cases still drawDrawn.The tolerance stays at half a code. With exact codes a device has nothing to round, and red and blue are 32 codes apart, so an unswapped read still fails.
agc_driver_sample_multisample_targetpasses 3 of 3 on llvmpipe and 3 of 3 on NVIDIA (RTX 4070 Ti, 595.99.02).check_conventions.pypasses, and the branch still merges cleanly withmainc0a7468f6f.AI-assisted: yes (Claude Code)