fix(shader): take the 32_AR export alpha from channel 1 as GFX10 does #5110
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5110"
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 nikowolf123 on 2026-10-13T11:56:15Z.
What
A pixel export to an MRT whose
SPI_SHADER_COL_FORMATis 32_AR (3) took its alpha from export channel 3 (EN mask0x9). That is the layout before GFX10, and8e6614500added it without a source. On GFX10 the alpha is export channel 1, and the PS5's gfx1013 is GFX10. Every AMD compiler for GFX10 puts it there:emit_ps_color_exportin ac_nir_lower_ps_late.c#L400-L411:unsigned index = s->options->gfx_level >= GFX10 ? 1 : 3;. The MRTZ path (L246-L252) follows the same rule, and that file is already the project's source for the MRTZ layout.enabled_channels = 0x3; values[1] = values[3];, and0x9before GFX10.EXP_FORMAT_32_ARputs the alpha inexports[1]with mask0x2.The RDNA 2 ISA guide documents the EXP EN mask but not how the SPI packs each color format, so it does not settle this case.
Because of this, a console shader's
exp mrt0 v0, v1, off, offlost its alpha, which stayed at the 1.0 default. Mesa picks 32_AR for two kinds of COLOR_32 target (ac_shader_util.c#L744-L752):When channel 3 was also enabled, its value was used as the alpha.
SpirvModuleEmitter.cpp,ExportVector: a 32_AR export now reads channels 0 and 1, and channel 1 becomes the alpha component. Channels 2 and 3 are ignored, just as 32_R and 32_GR already ignore the channels they don't carry. Green and blue stay 0, and an export without channel 1 keeps the 1.0 alpha default, as the other formats do.docs/dev/debt/shader.md: records the layout and those defaults as not measured on hardware.tests/execution/Pixel32ArExport.cpp(agc_driver_pixel32_ar_export): draws 32_AR exports with EN0x3,0xband0xf, as wave32 and wave64. The registers are decoded byDecodeColorBufferandDecodePixelStageInfo. There are two linear targets: COLOR_32 FLOAT ALT_REV (R32_SFLOAT, mapping0xe7), and COLOR_32 FLOAT blended with SRC_ALPHA / ONE_MINUS_SRC_ALPHA over 0.75. Every stored value is compared bit for bit: exporting (0.5, 0.25) stores 0.25 in the first target and blends to 0.6875 in the second. Onmain, every row fails. The ALT_REV target stores 1.0 for EN0x3and channel 3 (0.0625) for EN0xband0xf. The blended target stores 0.5 instead of 0.6875 for EN0x3, and blends with the channel 3 alpha for EN0xband0xf.Tested
Ubuntu 26.04 under WSL2, GCC 15.2.0, configured like CI (Release, Ninja,
-DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON, ccache), lavapipe from Mesa 26.0.8 withVK_ICD_FILENAMES=<lvp_icd json> ANYPS5_REQUIRE_VULKAN=1 GALLIUM_OVERRIDE_CPU_CAPS=avx, onmainc8eb1f52d:ctest -R '^agc_driver_pixel32_ar_export$'fails onmainwith the emitter unchanged:wave32 the 32_AR export with EN 0x3 of (0.5, 0.25, 2, 0.0625) into the COLOR_32 FLOAT ALT_REV (alpha only) target stored 0x3f800000 at pixel (0, 0), expected 0x3e800000. With the comparison changed locally to report every mismatching row instead of stopping at the first, all 16 rows (4 exports, 2 targets, wave32 and wave64) fail onmain. With the fix the unchanged test passes in under 0.5 s, also with--repeat until-fail:3.ctest -R 'agc_shader|agc_driver|shader' -j6: onmainwith only the new test added, 381 of 382 pass and the new test fails. With the fix, 382 of 382 pass.ctest -j6 --timeout 120on the commit: 1044 of 1044 pass. The skips are the existing lavapipe subgroup skips.tools/check_test_registration.pyandmain'stools/check_conventions.pypass, including--title/--body.main84e2a8c0b(no conflicts): the new test passes 3 of 3 runs, andctest -R 'agc_shader|agc_driver|shader'passes 382 of 382.Native Windows 11, WinLibs GCC 15.2.0, NVIDIA GeForce RTX 5080 (driver 616.92), on the same commit: the new test passes 3 of 3 runs, and
ctest -R 'agc_shader|agc_driver|shader|recompiler'passes 381 of 381.Not measured on AMD hardware, neither gfx1013 nor any PC RDNA 2 GPU. The sources above are compilers, not measurements.
tools/hw-oracleruns compute kernels only and cannot reach the SPI color export path (HW_ORACLE.md). A reviewer with a gfx103x GPU could confirm it with a RADV draw into an R32_SFLOAT target blended with SRC_ALPHA, or into an alpha-only target.RADV_DEBUG=shadersshould show anexp mrt0with the alpha in the second channel and the last two channelsoff, and the image should follow that alpha.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 oneandonlydean on 2026-10-14T02:33:25Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed