fix(agc): render to COLOR_16_16 targets with SWAP_ALT #15670
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15670"
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 B-Howell on 2026-11-04T02:05:43Z.
What
A two-channel colour target with
CB_COLOR0_INFO.COMP_SWAP1 (SWAP_ALT) stores the X and W exports in its two channels.DecodeColorFormatRawalready decodes COLOR_8_8 that way, but COLOR_16_16 (CB format 5) accepted onlyCOMP_SWAP0 and threw:The rule does not depend on the channel width. Mesa's
ac_translate_colorswap(src/amd/common/ac_formats.c, mesaeead8dcf02) picks the swap from the channel count alone; for two channels:So COLOR_16_16 with SWAP_ALT now decodes to the same R16G16 format as with swap 0 (UNORM, SNORM, UINT, FLOAT), with export mapping
0xec(X to the first channel, W to the second) in place of0xe4:The existing SWAP_ALT blend handling then covers it: a separate alpha blend is split across the two channels, and destination-alpha and constant-colour factors are rejected. Those messages now say "two-channel color target" instead of "8_8". Swaps 2 and 3 still throw. The debt entry for the SWAP_ALT blend split now names 8_8 and 16_16.
Tested
Windows 11, RTX 4080 SUPER, NVIDIA 621.01, WinLibs GCC 15.2.0-r7, Release. Commit
0ce86e70adon main1c8c0efc8c.agc_driver_graphicsdecodes 16_16 with swaps 0 and 1 for all four number types and checks the split alpha decision.agc_driver_swap_alt_blendnow draws into a real 16_16 FLOAT SWAP_ALT target as well as the 8_8 one, and compares every texel.agc_driver_graphics,agc_driver_swap_alt_blend,agc_driver_reversed_order_blend,agc_driver_dual_source_blend,agc_driver_uint_color_target,agc_driver_unclamped_normalized_blendandagc_driver_color_logic_oppassed 7/7 in each of 3 runs. The run usedANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, LunarG layer 1.4.363.1 throughVK_ADD_LAYER_PATH, andVK_LOADER_DEBUG=layer. The log of each of the six Vulkan tests showsInsert instance layer "VK_LAYER_KHRONOS_validation"in every run.agc_driver_graphicscreates no Vulkan instance.State.cppandPipeline.cppfrom1c8c0efc8cand the new tests kept.agc_driver_swap_alt_blendfails 3/3 withunsupported color format 5 number type 7 component swap 1.agc_driver_graphicsfails 3/3 withunsupported color format 5 number type 0 component swap 1. The other five pass.VUID-lines and 0SYNC-HAZARDlines, so the change adds no validation errors. Neither log haswas not found but was requested by env var VK_INSTANCE_LAYERS.agc_driver_graphicspasses. The six Vulkan tests skip, because WSL has no Vulkan device.unsupported color format 5 number type 7 component swap 1, with 154 presents, all black.std::bad_allocwhile building an oversized sampled view.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
Description corrected for
d5c9839460: the rejection-only assertions were removed; the production guards remain. The test results above retain their original source pins.AI-assisted update: Codex.
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T13:41:09Z.
Review: APPROVED
@B-Howell thanks. Treating COLOR_16_16 like COLOR_8_8 here looks right to me. Swap 1 gets the same
0xecmapping 8_8 already uses, and swaps 2 and 3 still fail. The SWAP_ALT handling applies with no format-specific change, because the split decision inPipeline.cppand the destination-alpha and constant-colour rejections inState.cppkey oncomponentMapping == 0xec.What I ran: head
d5c9839460merged ontomainb11c7bf84f, Windows 11, WinLibs GCC, Release, AMD Radeon RX 9070 XT, driver 32.0.32015.12012, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:agc_driver_graphics,agc_driver_swap_alt_blend,agc_driver_reversed_order_blend,agc_driver_dual_source_blend,agc_driver_uint_color_targetandagc_driver_color_logic_oppass (6 of 6). I didn't find whereagc_driver_unclamped_normalized_blendis registered, so that one isn't in my set;State.cppandPipeline.cpptaken frommainwith the new tests kept:agc_driver_swap_alt_blendandagc_driver_graphicsfail, the other four pass, the same split as yours;ctest -V, the same six tests onmainand on the merge): noVUID-and noSYNC-HAZARDIDs on either side, and neither log haswas not found but was requested by env var VK_INSTANCE_LAYERS;tools/check_conventions.py --base upstream/mainon the head: all checks passed;tools/pr_overlap.py --branch: no open PR shares lines. Of the 14 it couldn't compare, the four that touchState.cpporPipeline.cpp(#13928, #13929, #15059, #15548) don't change the 16_16 decode or the SWAP_ALT blend code.These are AMD results; your description has the NVIDIA ones. Approving.
Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-05T09:51:19Z.
Review: APPROVED
Head
d5c9839460merged ontomain6d173c1a19(clean merge, local only): code read, red/green check and a run on AMD's Windows driver, which the description doesn't cover yet, with an NVIDIA Blackwell run alongside.Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (
x86_64-ucrt-posix-seh, r3), Release,BUILD_TESTING=ON.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, the description's seven tests (agc_driver_graphics,agc_driver_swap_alt_blend,agc_driver_reversed_order_blend,agc_driver_dual_source_blend,agc_driver_uint_color_target,agc_driver_unclamped_normalized_blend,agc_driver_color_logic_op),ANYPS5_GPUselecting the device (confirmed bySelected GPU):main10de:2c05)1002:164e)VUID-lines and no missing-layer line in any run.agc_driver_swap_alt_blendprints8_8 and 16_16 SWAP_ALT blend tests passedon both GPUs, so the new 16_16 FLOAT target is drawn and compared on AMD's driver too.State.cppandPipeline.cppchanges reversed fails on both GPUs.agc_driver_graphicsstops withunsupported color format 5 number type 0 component swap 1, andagc_driver_swap_alt_blendwith... number type 7 component swap 1. That matches the control in the description.check_conventions.py --base mainpasses on the merge.Read through the change:
COMP_SWAP0 and 1, with mapping0xe4or0xec, for the same four number types as before, the way COLOR_8_8 already does. Swaps 2 and 3 stillfail().0xecchecks inDecodeStateand the split inPipeline.cppkey on the mapping, not the format, so they cover 16_16 without other changes. Only the messages and the debt entry change from "8_8" to "two-channel" / "8_8 and 16_16".d5c9839460the tests no longer require swaps 2 and 3, or the memory-writing split draw, to throw, as requested.One small thing: the description's Tested section still says
agc_driver_graphics"checks that swaps 2 and 3 are rejected". That check was removed ind5c9839460, so that line could go. No code change needed.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-06T18:34:38Z.
Review: APPROVED
@B-Howell re-checked at
696430d1f4, and my approval stands.696430d1f4is a merge ofmain(6bf3a19b81) ontod5c9839460, the head I approved. The PR's own +/- lines are identical at both heads in every file it changes:Graphics/src/Pipeline.cpp,Graphics/src/State.cpp,tests/Graphics.cpp,tests/execution/SwapAltBlend.cppand the debt entry.What I ran
Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0, Release, this head merged onto current
main(merge318e0146e3). The GPU is an AMD Radeon RX 9070 XT (0x1002:0x7550, Vulkan API0x404167, as the test logs report it). Windows reports driver 32.0.32015.12012, read right after the runs; the logs don't print it.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest -V, with the same six tests as at my approval:agc_driver_color_logic_op,agc_driver_dual_source_blend,agc_driver_graphics,agc_driver_reversed_order_blend,agc_driver_swap_alt_blendandagc_driver_uint_color_target: 6 of 6 pass.main'sGraphics/src/Pipeline.cppandGraphics/src/State.cpp.agc_driver_swap_alt_blendandagc_driver_graphicsfail; 4 of 6 pass.was not found but was requested by env var VK_INSTANCE_LAYERS. Both have noVUID-and noSYNC-HAZARDIDs.tools/check_conventions.py --base upstream/main --headon this head: all checks pass.tools/pr_overlap.py --branch: no confirmed line overlap with another open PR. The tool couldn't compare the PRs that conflict withmain.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by mashingaan on 2026-11-08T10:47:48Z.
Review: APPROVED
The swap>1 rejection and the 0xe4/0xec mapping for swap 0/1 match the other two-channel formats, and the tests cover both targets plus the separate-alpha-blend split. No findings.