fix(agc): rasterize a single-sample scan into a multisampled depth target at the pixel center #5915
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5915"
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 SandstromPL on 2026-10-14T15:33:27Z.
What
METAL GEAR SOLID: Peace Walker (PPSA18216) stops at its first presentation with:
mrfelek reported it on #5268, on
main69e7138acwith #5422 and #5439, and posted the registers of that draw (draw A):PA_SC_AA_CONFIGPA_SC_MODE_CNTL_0MSAA_ENABLEclear)DB_Z_INFODB_EQAADB_DEPTH_CONTROLThis is the depth version of #4414. #4414 rasterizes a single-sample scan into a multisampled color target with every sample at the pixel center, but it leaves out draws with a depth target. Such a draw now rasterizes the depth target's sample count with every sample at the pixel center, using the custom sample locations from #2169. A 4x color target next to the depth target works the same way.
radeonsi programs this state when GL multisampling is disabled on a multisampled framebuffer:
MSAA_ENABLEfollows the GL multisample state (si_state.cL1066-L1068).PA_SC_AA_CONFIGstays 0, and the depth buffer keeps its own sample count (L3485-L3512).Two differences from that state:
DB_EQAA.MAX_ANCHOR_SAMPLESto the Z sample count, where the game setsDB_EQAAto 0. This change does not depend onMAX_ANCHOR_SAMPLES.ARB_multisample defines this state: rasterization is single-sample with full coverage, and every sample may take the single-sample depth (L185-L190), with the fragment treated as in multisampling with full coverage (L422-L425). Every sample at the pixel center gives exactly that: each depth and stencil sample is tested and written with the depth at the pixel center. GL also lets an implementation test only a "centermost sample" and set every depth and stencil sample from it (L425-L434), which differs when a pixel's stored samples differ.
Triangles and rectangles are accepted; draw A's depth and stencil fill may well be a rect list. On this path, these throw, most with a new message:
DB_EQAAZ interpolation or overrasterization (bits 18-19 and 24-27). These could change the per-sample depth;ANCILLARY). Vulkan would run it once per sample, with an index the console does not give. Sample-interpolated inputs are accepted, because the recompiler reads them through barycentrics, which give the center value for every sample here.#4414's color-only path does not refuse these, and this PR leaves it unchanged. The primitive check moves out of
singleSampleMsaaRejectioninto a helper that both rules use; that rule's behaviour and messages are unchanged.Not measured on hardware, and recorded in the new debt entry:
Tested
Ubuntu 24.04, GCC 13.3, Release with
BUILD_TESTING=ON, onmain84b01f9cd. Locally, the libusb lines were removed fromCMakeLists.txt, because the libusb submodule isn't checked out here.agc_driver_graphics(tests/Graphics.cpp) gainsmultisampledDepthTests. Unless stated, each case usesPA_SC_AA_CONFIG0,MSAA_ENABLEclear and a 4x Z32 depth target.These now decode, as 4 samples with every location at the pixel center, no sample-location grid and no per-sample shading:
DB_Z_INFO0xa290098b,DB_DEPTH_CONTROL0x777,DB_EQAA0, no color target). The draw precheck accepts it;ANCILLARYinput, when the draw skips its pixel program;PS_ITER_SAMPLEdoes not turn on sample shading.These now throw:
DB_EQAAZ interpolation;ANCILLARYinput with a pixel program;Pinned unchanged (these pass on
maintoo):MSAA_ENABLEset, with sample 0 at the center;On
mainthe test fails at draw A with the message above. With the change it passes, 5 runs out of 5. The existing single-sampleMSAA_ENABLEchecks still pass, inagc_driver_graphicsandagc_driver_msaa_enable_single_sample.Other checks:
cteston the RTX 3050 Ti: 1,159 of 1,161 pass, 12 of them skipping themselves:agc_driver_stencil_ref_exporton this GPU, and the VideoOut flip tests, which need a display. The other 2,patched_librariesandguest_usbd, are Not Run because the libusb submodule isn't checked out. All 401agc_drivertests pass apart from that skip.PA_SC_AA_CONFIGwithMSAA_ENABLEclear, over a 4x depth and a 4x color target. #5882 (merged) handles that state without a depth target, and #6014 adds the depth target.PA_SC_AA_CONFIG, handled by #6196.7b20318e8) changed the line next to this change'sState.cppedit.mainf474fb776after #5907 merged. On that head,agc_driver_graphicspasses 3 runs out of 3 on the RTX 3050 Ti and on lavapipe. It still fails withmain'sState.cpp(the depth target's sample count differs from the rasterizer's).24528f4e5) handles the opposite case: a multisampled rasterizer withMSAA_ENABLEset, drawing into one-sample targets. It rewrote the same depth sample-count check, so this PR is rebased onto it: #5907'sdepthKeepsSampleZeropath runs first, then this PR's single-sample-scan path, then one sample-count check that accepts both. The two rules don't overlap: this one needs a single-sample rasterizer withMSAA_ENABLEclear, and #5907 needs a one-sample depth target. The debt file keeps #5907'sCustom MSAA sample locationsentry, with this PR's entry after it.tools/check_conventions.pyfrommainpasses with this title and body.@mrfelek, thanks for the registers and the runs.
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)ctest; the new checks are host-side decode tests)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by mrfelek on 2026-10-14T16:21:17Z.
Real-title check for the Peace Walker case. METAL GEAR SOLID: Peace Walker (PPSA18216), Linux, RTX 3080 Ti (NVIDIA 615.71.09),
maine34c47921plus #5439, this PR and #5882, with the launcher hand-over from boykopovar/AnyPS5#5268. The game loads (345 file opens) and reaches its first presentation. With this PR the originalthe depth target's sample count differs from the rasterizer's(draw A) no longer throws. The frame then stops at #5882'smultisampled targets rasterized without MSAA_ENABLE are unsupported for points, lines, a depth target or alpha-to-coverage(draw B on #5268:PA_SC_AA_CONFIG0x0020c002,MSAA_ENABLEclear,DB_Z_INFO0xa290098b,CB_COLOR0_ATTRIB0x00012000). Draw C was not reached, since B ends the frame first.AI-assisted; the runs are from my machine.
Imported from boykopovar/AnyPS5. Originally posted by SandstromPL on 2026-10-14T16:45:08Z.
@mrfelek Thanks for the run! That matches the description: draw A gets through, and draw B is next, on #5882's depth-target refusal.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T18:20:54Z.
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)docs/dev/debt/libSceAgcDriver.mdL124docs/dev/debt/libSceAgcDriver.mdL124core/libs/prx/libSceAgcDriver/Graphics/src/State.cppL394-400, L411-412docs/dev/debt/libSceAgcDriver.mdL124Some 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/State.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by mrfelek on 2026-10-14T22:04:09Z.
Checked, as asked in the description. Peace Walker (PPSA18216), Linux, RTX 3080 Ti (NVIDIA 615.71.09),
mainb72378b0fplus #5439, this PR (2c8dda1dd), #5882 (e10ec3904) and #6014 (82d90b0ae), with the launcher hand-over from boykopovar/AnyPS5#5268.the depth target's sample count differs from the rasterizer'sno longer throws.a color target's sample count differs from the rasterizer's(1-sample colour target, no depth, 4-samplePA_SC_AA_CONFIG,MSAA_ENABLEclear).AI-assisted; the runs are from my machine.
Imported from boykopovar/AnyPS5. Originally posted by SandstromPL on 2026-10-15T01:58:10Z.
@mrfelek Thanks for checking! Draw C is handled in #6196.
Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-15T10:05:41Z.
Overlap note: this PR and #5907 (mine) both edit the depth sample-count check in
DecodeState. They conflict when merged together.They handle opposite cases:
They combine without changing either: keep #5907's
depthKeepsSampleZeroand its sample-zero block. Then put this PR's single-sample-scan block after it, and end with:I ran that combination with Onimusha: Way of the Sword (PPSA27836) on
main0afa6a607, Windows, RTX 5070. That title only takes #5907's side (depth 1, raster 2), so this run doesn't exercise this PR's path. Whichever lands second will need this resolution.Imported from boykopovar/AnyPS5. Originally posted by SandstromPL on 2026-10-15T10:34:29Z.
@simonbronk Thanks, agreed! I'd come to the same resolution. I rebuilt it on current
main(e49ec591d) with #5907 (2ce4e57a5) and this PR (2c8dda1dd): yourdepthKeepsSampleZeroand sample-zero block, then this PR's single-sample-scan block, then theRequireabove.The debt file conflicts too. #5907 rewrites the "Custom MSAA sample locations" entry and this PR adds its entry right after it; keeping both lines resolves it.
With that,
agc_driver_graphicspasses with both PRs' tests (Linux, RTX 3050 Ti), andctest -R agcpasses 582 of 583. The one failure,agc_pending_key_stores, fails the same way on plainmaine49ec591d. If this PR lands second, I'll do the rebase.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T11:44:35Z.
Re-checked on the PR merged onto current
main(65d56a297):agc_driver_graphicspasses, and the newmultisampledDepthTestsfail withmain'sState.cpp(the original "depth target's sample count differs" message). Rejections, tests and the debt entry match the description; mrfelek's Peace Walker run covers draw A. Merging oncemainbuilds again (#6784); #5907 overlaps the same check and will need a small rebase if it lands second.Imported from boykopovar/AnyPS5. Originally posted by SandstromPL on 2026-10-16T18:41:49Z.
@adriadam10 Thanks for the re-checks! In case it helps break the loop: GitHub shows no merge queue for
mainand no queue entry for this PR, so nothing will pick it up on its own. Run 38899406464, on the red baseeb901bcf4, is still the only full Build on this head (2c8dda1dd). A fresh Build on currentmainshould give it a green report.Imported from boykopovar/AnyPS5. Originally posted by SandstromPL on 2026-10-16T19:18:06Z.
Rebased onto main
f474fb776now that #5907 is in, as agreed with @simonbronk: #5907’s depthKeepsSampleZero path runs first, then this PR’s single-sample-scan path, then one sample-count check that accepts both. agc_driver_graphics passes 3 of 3 on an RTX 3050 Ti and on lavapipe, and the new tests still fail with main’s State.cpp. The debt file keeps both entries.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T19:47:48Z.
Re-checked the rebased head (4355eb4f1) on
main:agc_driver_graphicspasses and fails without theState.cppchange; #5907'sdepthKeepsSampleZeropath runs first, then the single-sample-scan path, then the single sample-count check. Rejections, tests and the debt entry match the description; mrfelek's Peace Walker run covers draw A. Merging once the full Build on this head is green.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T22:51:13Z.
Rebased onto current
main(57f2a5901): the only conflict was adjacency intests/Graphics.cppwith the multisampled DCC state test froma0c51d5778; both tests are kept,State.cppand the debt file merged cleanly.agc_driver_graphicspasses on the rebased head and fails without theState.cppchange. Merging once the full Build is green.