fix(agc): alpha-to-coverage from a 32_AR MRT0 export without a color target #5521
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5521"
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 codingreapermaps on 2026-10-13T22:17:02Z.
What
Undithered alpha-to-coverage (
DB_ALPHA_TO_MASK = 0xaa01) was refused on draws without a color target on MRT0, and on32_ARMRT0 exports. Those are the draws radeonsi produces for alpha-to-coverage without a color buffer: the color format of MRT0 becomesSPI_SHADER_32_ARso that the alpha still reaches the DB. PPSA12361 (Transport Fever 2: Console Edition) issues them when the camera zooms in on a map and stopped withalpha-to-coverage without a written MRT0 color target is unsupported.DecodeStateaccepts alpha-to-coverage when no color target is written on MRT0, and accepts the32_ARexport format.SPI_SHADER_COL_FORMAT. The decoder masked the export formats to 0 for draws without a color target, so such a draw was refused asformat 0even with a32_ARexport.Which channel of a
32_ARexport carries the alpha is #5110's change, which this PR depends on: its first commit here is #5110 unchanged. Before #5110 the recompiler took the alpha from channel 3 and the coverage of these draws ignored it. Dithered alpha-to-coverage (#4451) is unrelated: this PR does not change whichDB_ALPHA_TO_MASKvalues are accepted.Tested
Windows 11, MinGW-w64 GCC 15.2.0, NVIDIA GeForce MX450 (driver 581.83).
agc_driver_alpha_to_coverage_tests: newDepthOnlyCoveragedraws a depth-only triangle with alpha-to-coverage and a32_ARexport over a cleared depth surface, then counts the pixels a depth test still passes. With export mask0x3, alpha 0.75 writes the depth everywhere and alpha 0.25 writes none. With export mask0xF, alpha 0.25 in channel 1 and 0.75 in channel 3, it writes none: the coverage follows channel 1 and channel 3 is ignored. All alpha-to-coverage tests pass.agc_driver_graphics_tests:32_ARis accepted with a color target; withCB_TARGET_MASK0 and a32_ARexport the state decodes with alpha-to-coverage and no target and passes the precheck; formats 1 and 2, and no MRT0 export without a target, are refused. All graphics tests pass.agc_driver_pixel32_ar_export_testsfrom #5110 passes on this branch.mainat30f961266with #5110.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 MarcZX10 on 2026-10-13T22:24:50Z.
Review: COMMENTED
The
mode == 3ubranch remaps only source components 0 and 1 to raw R and A, but the revisedexportedmask now permitsexp.enbits 2 and 3 too. For a valid 32_AR export withEXP_EN=0xF(or0xC), those source components are never copied intoraw; after the export mapping the corresponding channels become zero/default, and in particular an alpha supplied in source component 3 is lost because A is taken from component 1. The new depth-only fixture appears to use onlyEXP_EN=0x3, so it would not catch this. Could you add a focused mask0xFregression and either preserve the enabled channels consistently with the 32_AR semantics or reject unsupported enable masks?Imported from boykopovar/AnyPS5. Originally posted by codingreapermaps on 2026-10-13T22:59:04Z.
Thanks, you're right, and the overlap bot points at the same line: #5110 already fixes the
32_ARchannel layout, with more sources, and its mask handling answers this. I've rebased ontomainwith #5110 as the first commit and dropped my ownExportVectorchange, so themode == 3ubranch here is #5110's: the enabled channels are masked to0x3and channel 1 goes to alpha, so withEXP_EN=0xFchannels 2 and 3 are ignored, as GFX10 does (ac_nir_lower_ps_late.c).I added the
0xFregression you asked for toDepthOnlyCoverage: alpha 0.25 in channel 1 and 0.75 in channel 3 withEXP_EN=0xFwrites no depth, so the coverage follows channel 1. This PR is now only the decoder side (alpha-to-coverage without an MRT0 color target,32_ARaccepted, the MRT0 export format read fromSPI_SHADER_COL_FORMAT), with Depends on: #5110.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T23:12:25Z.
Thanks, that addresses my specific concern. The new
EXP_EN=0xFdepth-only case checks that the alpha in channel 1 drives coverage while channel 3 is ignored for32_AR, and the PR now records its dependency on #5110. The latest convention check passes; the full Linux/Windows jobs are path-skipped for this diff.Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-14T03:23:31Z.
Windows test of #5521: Windows 10 (19045), MinGW-w64 GCC 15.2, Release,
ninja -j 4, ctest called directly; ctest ran without-V, so the logs of the passing runs do not show which GPU, if any, the tests used (not verified). Tree:main54c2e14dc+ merge of PR head269d806f532c748e4dbfe5a608ae5c3267f71778(local merge30ce9121a, no conflict). Logs:rtx5521_*_N.log,rtx5521_result.txt.3 ctest targets, 3 runs each, exit code 0 in 9 of 9 runs:
agc_driver_alpha_to_coverage,agc_driver_graphics,agc_driver_pixel32_ar_export.Not tested: that the new or changed tests fail without the change (no baseline run), other ctest targets, the AMD GPU unless named above, Linux, a title run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T04:57:14Z.
Rebased on current
main; onlydocs/dev/debt/libSceAgcDriver.mdconflicted (kept both entries). #5110 is closed, so this PR now carries its commit itself.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T09:03:42Z.
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/State.cppL989-992docs/dev/debt/libSceAgcDriver.mdL10