fix(agc): rasterize a multisampled depth target without MSAA_ENABLE at the pixel center #6014
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6014"
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-14T19:19:53Z.
What
#5882 is merged (
7b20318e8). This branch was built on #5882's heade10ec3904, whichmainnow contains, so this PR has only its own commit. GitHub's commit list may still show #5882's two commits until the next push. billythemenace2 asked for this follow-up.With #5915 (draw A), #5882 and #5439, METAL GEAR SOLID: Peace Walker (PPSA18216) stops at draw B of its first presentation:
mrfelek posted the registers of draw B:
PA_SC_AA_CONFIGPA_SC_MODE_CNTL_0MSAA_ENABLEclear)DB_Z_INFODB_EQAADB_DEPTH_CONTROLCB_COLOR0_ATTRIBOnly 0x711 binds the depth/stencil target, through its stencil test. That is the draw #5882 refuses. mrfelek posted its stencil registers too:
DB_STENCIL_INFO0x20000181 (an 8-bit stencil plane);DB_STENCIL_CONTROL0x333 andDB_STENCILREFMASK0x00ff0000: the fail, depth-fail and pass ops replace with the test value 0, write mask 0xff;0x622ae6ae) in all four pixels.So every sample of the 4x target that draw B covers gets stencil 0, which mrfelek reads as a stencil clear.
With #5439, #5915, #5882's
e10ec3904and this PR, merged by hand the way it is now restacked, mrfelek's run gets past draw B. The first presentation then stops at draw C, a one-sample color target under the same stale 4xPA_SC_AA_CONFIG. #6196 handles that.#5882 rasterizes a multisampled target without
MSAA_ENABLEwith the target's sample count and every sample at the pixel center, and it refuses a depth target. A depth/stencil target with the same sample count now goes the same way. Its samples are at the pixel center too, so each depth and stencil sample is tested and written with the depth at the pixel center.GL allows this when multisampling is disabled. Every sample may take the single-sample depth (ARB_multisample L185-L190), and the fragment may be treated as in multisampling with full coverage (L422-L425). #5915 uses the same rule for a single-sample rasterizer.
These throw:
DB_EQAAZ interpolation or overrasterization (bits 18-19 and 24-27). Draw B'sDB_EQAAhas neither.#5915 also refuses a pixel program reading the sample index, because it widens a single-sample rasterizer to the depth target's count. Here the rasterizer already has that count, so #5882's rules for a multisampled target apply unchanged.
Not measured on hardware, and recorded in #5882's debt entry, which this extends:
PA_SC_AA_SAMPLE_LOCS_PIXEL_*) withoutMSAA_ENABLE. As in #5882, this is inferred from RADV.Tested
Ubuntu 24.04, GCC 13.3, Release with
BUILD_TESTING=ON, on #5882's heade10ec3904(basemainfa539dd9b). Locally, the libusb lines were removed fromCMakeLists.txt, because the libusb submodule isn't checked out here.agc_driver_graphics(tests/Graphics.cpp) gainsmsaaEnableClearDepthTests. It uses draw B's posted registers, including the stencil registers and sample locations.DB_DEPTH_CONTROL0x711D32_SFLOAT_S8_UINT, with its stencil test decoding toALWAYS,REPLACEwith reference 0 and write mask 0xff). It puts every sample at the pixel center and passes the draw precheck.DB_DEPTH_CONTROL0x710DB_EQAAZ interpolation (bit 18 or 19) or overrasterizationDB_EQAAZ interpolation with no depth target#5882's own refusal test is updated for the shorter message. With #5882 alone, the new test fails at draw B with the message above. With this commit it passes, 5 runs out of 5.
Other checks:
cteston the RTX 3050 Ti: 1,201 of 1,203 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 420agc_drivertests pass apart from that skip.mainwith #5915 (draw A) and #6196 (draw C): fullctestgives 1,214 of 1,216, with the same 12 skips and the same 2 Not Run, andagc_driver_graphicsruns all three new test functions.e10ec3904clearssampleLocationGridin the block this PR extends, so a depth target drawn this way gets no grid either.main5d9dcc42dthe branch merges cleanly, both on its own and with each of #5915, #6196, #5907 and #5939 (#6015 has merged since). The overlap check finds one conflict, with #6563. It rewrites the entry just above this PR's indocs/dev/debt/libSceAgcDriver.md, so the two adjacent lines conflict, whileState.cppandtests/Graphics.cppmerge automatically. Whichever PR merges second keeps both entries.tools/check_conventions.pyfrommainpasses with this title and body.@mrfelek, thanks for the run and for the stencil registers. The test now uses them.
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-14T21:55:26Z.
Peace Walker (PPSA18216) with this PR: draw B passes, draw C is next
Linux, RTX 3080 Ti (NVIDIA 615.71.09). Build:
mainb72378b0fplus #5439 (f2b135327), #5915 (2c8dda1dd), #5882 (e10ec3904) and this PR (82d90b0ae), with the launcher hand-over from boykopovar/AnyPS5#5268.PA_SC_AA_CONFIG,MSAA_ENABLEclearPA_SC_AA_CONFIG,MSAA_ENABLEclearThe frame then ends at draw C with
a color target's sample count differs from the rasterizer's. With a local print of the values: colour 1 sample, rasterizer 4, depth 0,PA_SC_MODE_CNTL_00x2 (MSAA_ENABLEclear),PA_SC_AA_CONFIG0x0020c002,DB_EQAA0x00010002,CB_COLOR0_ATTRIB0, slot 0. (The registers for A, B and C are in the table on #5268.)Note: this PR is built on #5882's earlier head d9d8fb737. On #5882's current head (
e10ec3904, which addsresult.sampleLocationGrid = false;) it conflicts inState.cpp(theRequire(filled && ...)block),tests/Graphics.cppanddocs/dev/debt/libSceAgcDriver.md. For this run I kept this PR's depth checks and #5882's new line.AI-assisted; the runs are from my machine.
Imported from boykopovar/AnyPS5. Originally posted by mrfelek on 2026-10-14T22:00:40Z.
Draw B registers (Peace Walker, PPSA18216)
The first presentation gets past draw B with #5915, #5882 and this PR (details in my earlier comment); the frame then ends at draw C. Registers read at draw B (the
DB_DEPTH_CONTROL0x711 draw), same build and machine:DB_STENCIL_INFODB_DEPTH_CONTROLDB_STENCIL_CONTROLDB_STENCILREFMASKDB_STENCILREFMASK_BFDB_RENDER_CONTROLPA_SC_CENTROID_PRIORITY_0/_1PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_0toX1Y1_3(0x2fe to 0x30d)0x622ae6ae, 0, 0, 0, repeated for each of the 4 pixelsMy reading of the fields (please check):
DB_STENCIL_INFOhas an 8-bit stencil format; the stencil function is ALWAYS (DB_DEPTH_CONTROLbits 8 to 10 = 7) with Z test and write off; fail, Z-pass and Z-fail ops are all REPLACE_TEST (3) with test value 0 and write mask 0xff; the sample locations are the same standard 4x pattern, (-2,-6), (6,-2), (-6,2), (2,6), for all four pixels. So the test's assumptions of a stencil plane, ALWAYS, and the uniform pattern hold, and this draw looks like a stencil clear to 0.AI-assisted; the runs are from my machine.
Imported from boykopovar/AnyPS5. Originally posted by SandstromPL on 2026-10-15T01:57:30Z.
@mrfelek Thanks for the run and for the draw B registers! I've restacked this PR onto #5882's current head
e10ec3904. Only this PR's commit moved, and it applies there without conflicts. The conflicts you saw came from merging the older copy of #5882's commit (d9d8fb737) next to the rebased one. The test now uses your stencil registers and sample locations: they decode toALWAYS,REPLACEwith reference 0 and write mask 0xff, with every sample at the pixel center. Draw C is up as #6196, also stacked on #5882.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:13:19Z.
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.
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.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.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/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/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/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.mdcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/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.mddocs/dev/debt/libSceAgcDriver.mdcore/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.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T21:06:04Z.
Checked the decode of a multisampled depth/stencil target without MSAA_ENABLE:
agc_driver_graphicspasses on the PR merged onto main and fails with theState.cppchange reverted. The remaininglibSceAgcDriverscope is green apart fromagc_driver_tessellation, which segfaults on main too. The throws (other sample count,DB_EQAAZ interpolation/overrasterization, sample-mask export, points, lines, alpha-to-coverage) match the tests, the debt entry marks the pixel-center result as inferred, and @mrfelek's Peace Walker run covers draw B. Merging once the full Build is green.Imported from boykopovar/AnyPS5. Originally posted by SandstromPL on 2026-10-17T12:20:10Z.
@adriadam10 #6014 dropped out of the Build batches after 02:44Z without being merged, and I couldn't tell why. Run 38994273700, with #6014 first at
4ef2af62e, was green on every job at 02:43Z. In the smaller run 38994264368, Linux failed onlyagc_driver_store_over_untracked. The first failure matches #6383, which #6385 fixed onmainat 02:58Z.The head hasn't changed, it still merges cleanly into current
main, and #5915 (draw A) is merged now. If anything else is needed, I'll do it. Otherwise, could you add it back when you next run the queue?AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-17T14:43:20Z.
Intel and AMD Windows data: no failures from this change.
Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
ANYPS5_NO_SHADER_CACHE=1, serial CTest,main47a266cf9. Intel UHD Graphics 770 (8086:a780, 32-wide subgroups), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550, 64-wide subgroups), driver 32.0.31041.1004, withVkCacheemptied first.This head
4ef2af62emerged intomain: the 16 tests built fromtests/Graphics.cpp, ×3, pass on the RX 9070 XT. On the UHD 770,agc_pipeline_library_clear_waits_for_buildfailed once in its first three runs (clearing during a library build leaked Vulkan objects). It did not recur in 20 more runs with this PR, 20 onmainand 10 on the RX 9070 XT. It looks intermittent and isn't tied to this change.Full CTest (
--parallel 4) with six open PRs merged intomain(#6638, #6604, #6014, #6773, #6772, #6725): the same failures asmainalone on both GPUs, nothing new.mainalone: UHD 770 1392 of 1398, RX 9070 XT 1396 of 1398. The failures are image tables (#6647) andsample_multisample_target(#6971) on Intel, andquad_pixel_mask(#6255) andlayered_volume_vertex_no_gpl(#4768) on AMD.AI-assisted: yes (Claude Code)