Repository navigation
fix(agc): sample a multisampled target whose format differs only in red/blue order - #7253
Conversation
…ed/blue order Sampling a native multisampled color target through a texture of another format was refused even when the two formats store the same bytes in the other channel order. Rush 2 and Wave Race 64 render a 3840x2160 8x target as 8_8_8_8 with the alternate component swap (B8G8R8A8_UNORM) and sample it through an 8_8_8_8 UNORM T# (R8G8B8A8_UNORM), and stopped on "sampling multisampled color target ... (vk format 44) as a ... texture ... guest format 56 (vk 37) is not implemented". For the B8G8R8A8/R8G8B8A8 pairs of the same numeric type the texture is now the target's own image with red and blue exchanged in its component mapping, composed with the T#'s swizzle. Other format differences are still refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.
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.
|
|
Full CI on 90c3b61 (merged into main 922dc89): the Linux job fails The swap itself looks right to me. I think the check is too tight for an 8-bit target.
A 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):
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. |
The case drew 0.5 green, which lies halfway between two UNORM8 codes, so a device that rounds 127.5 up (llvmpipe, LLVM 20.1.2) failed the half-code tolerance with red and blue correctly swapped. It now draws 64, 128 and 32 of 255 from its own pixel program and names the loaded and expected codes when a sample differs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @oneandonlydean, that's what it was. I reproduced it locally on llvmpipe (Mesa, LLVM 20.1.2, through 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. 7c4bc9a (test only):
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.
AI-assisted: yes (Claude Code) |
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;
main922dc89.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). 7c4bc9a fixes 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 test(agc): skip the multisampled target test without storage image multisampling #7191 addresses. So the case is checked on NVIDIA only.Titles, 60 s each with scripted pad input. Base is
main5859889 with fix(agc): take RADV's fill-memory kernel as a buffer fill #6543 and feat(agc): take a full DCC fill of a resident multisampled target as its fast clear #7250 (b4e35279a) merged; feat(agc): take a full DCC fill of a resident multisampled target as its fast clear #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 (fix(shader,agc): support multisampled 2D array descriptor image shape and runtime views #6635, fix(agc): sample multisampled targets in read-only layout #6971, feat(agc): preserve initial native multisample color contents #6973, feat(agc): snapshot resident multisample color bytes #6987, feat(agc): publish completed native color snapshots #6989, feat(agc): publish native color before guest memory reads #6995, feat(agc): publish native color for read-only shader buffers #7002) and fix(agc): refuse buffer aliases of native MSAA targets #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