fix(agc): draw line lists and strips into a multisampled target with MSAA_ENABLE clear #8871
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8871"
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 thuanquang on 2026-10-21T03:49:50Z.
What
Before: a line list or strip (
VGT_PRIMITIVE_TYPE2 or 3) drawn withPA_SC_AA_CONFIG.MSAA_NUM_SAMPLES> 0 andPA_SC_MODE_CNTL_0.MSAA_ENABLEclear threwAGC graphics: multisampled targets rasterized without MSAA_ENABLE are unsupported for points, lines or alpha-to-coverage. METAL GEAR SOLID: Peace Walker (PPSA18216) draws line lists and strips into its 4x target this way: mrfelek's in-game run (#5268 comment, row "local: lines") needed a local change that drops this refusal (8e5e1682, theState.cpphunk, which keeps only the alpha-to-coverage condition). The title reaches these draws only past the opening movie's 2D read of the 4x target (#7803, or mrfelek's local resolve).After: such lines take the path triangles and rectangles already take in this state (#5882, #6014, #6196): the target's sample count with every sample at the pixel center. Under a one-sample color target (PPSA18216's draw C) the line is drawn as a one-sample line, as with a 1x
PA_SC_AA_CONFIG. The refusal now reads the primitive the draw rasterizes (RasterPrimitiveOf) instead ofVGT_PRIMITIVE_TYPE: a point list that a geometry program turns into triangles or lines decodes as those triangles or lines with every sample at the pixel center, and rasterized points and alpha-to-coverage still throw. A one-sample depth target under this configuration, and a single-sample scan into a multisampled depth target, still refuse line and point lists (VGT_PRIMITIVE_TYPE1-3).One draw class goes from drawn to refused (found by @oneandonlydean). Since #8856 (
ee81c5112d, in this base) a geometry program's point output is drawable (State.cppL1094 acceptsVGT_GS_OUT_PRIM_TYPE0), andmain's refusal here readsVGT_PRIMITIVE_TYPE, so a geometry program that makes points from a triangle list into a multisampled target withMSAA_ENABLEclear is drawn onmainand refused by this change, which reads the rasterized primitive. Rasterized points stay refused in this state on purpose: the evidence below covers lines only, and what the console rasterizes for a point under a multisampled configuration withoutMSAA_ENABLEis not measured. A point or line list into such a geometry program was already refused onmain, and a vertex-path point list still throws earlier (L1221,point-list vertex rendering requires point-size output support).Why every sample of a covered pixel (not measured on a PS5)
PA_SC_MODE_CNTL_0) describesMSAA_ENABLEas "Enable MultiSample AA in DX10 and below. Used for lines in DX10.1 and above" (also quoted in #5882), i.e. the bit is D3D'sMultisampleEnablefor lines.MULTISAMPLEdisabled rasterizes every primitive as single-sample with full coverage (ARB_multisample L185-L190). radeonsi programmed exactly this register state for it,PA_SC_AA_CONFIGat the framebuffer's sample count withMSAA_ENABLE= 0 (si_state.c at 7bb3d6ac, L926-L933, L3482-L3525), until ea5b7de1 (2019) zeroedPA_SC_AA_CONFIGthere so thatgl_SampleMaskInreads 1.On #5882's reason for keeping lines refused ("an aliased line on the hardware is not a Vulkan rectangular line"):
mainalready draws every one-sample line list and strip with the host's line rule (debt entry "Line-strip geometry output": 1 pixel wide,PA_SU_LINE_CNTLnot read, the console's line rules not measured), and already draws lines into a multisampled color target with every sample at the pixel center whenPA_SC_AA_CONFIGis 1x (the "draw raised to a multisampled target" branch,State.cppL1314, has no topology check). With every sample at the center, a 4x line list and a 4x line strip cover the pixels the host's one-sample lines cover (measured below), so this adds no difference that one-sample lines do not already have.How
State.cpp: the refusal in theMSAA_NUM_SAMPLES > 0/MSAA_ENABLEclear block testsRasterPrimitiveOf(result)(a rectangle for a rect list, the output primitive of a geometry or mesh program, triangles for tessellation, else the topology) instead of the topology, and keeps points and alpha-to-coverage.DecodeStatedecodes the shader stages (L1140) and the topology (L1143-L1166) before this check (L1222), so the check sees a geometry program's output and did not have to move. Line lists and strips reach the existing pixel-center code.tests/Graphics.cpp: draw B withVGT_PRIMITIVE_TYPE2 and 3 decodes as lines into the 4x depth and color pair with every sample at the pixel center and passes the precheck; draw C with 2 and 3 decodes as one sample; a point list into a geometry program that outputs triangle strips (VGT_GS_OUT_PRIM_TYPE2) now decodes as triangles (RasterPrimitiveOf= triangle) into the same 4x pair with every sample at the pixel center, wheremainthrew; the three alpha-to-coverage rows take the new message; a triangle, line and point list (VGT_PRIMITIVE_TYPE4, 2 and 1) into a geometry program that outputs points (VGT_GS_OUT_PRIM_TYPE0) into the same 4x pair are refused with this check's message (the triangle-list row decodes onmain); the one-sample depth target rows (msaaEnableClearOneSampleTargetTests) refuse a line strip (VGT_PRIMITIVE_TYPE3) as well as a line list, without and with a one-sample color target.tests/execution/MultisampleCenteredLines.cpp(new GPU test,agc_driver_multisample_centered_lines): builds the registers of a line list and of a line strip (VGT_PRIMITIVE_TYPE2 and 3,PA_SC_AA_CONFIG0x0020c002,PA_SC_MODE_CNTL_02, a 16x16 4x RGBA16FCB_COLOR0, no depth target), decodes them withDecodeState, checks that the decoded state has 4 samples all at the pixel center, and draws exactly that state; it then draws the same decoded state into a one-sample RGBA8 target. It loads every sample and requires every pixel to be covered in all 4 samples or none, every pixel the one-sample lines draw away from the endpoints to be covered in the 4x target, and the 4x target to cover at least 20 pixels and at most twice as many as the one-sample lines. It prints how many pixels away from the endpoints differ: Vulkan lets a non-strict host use another line rule at one sample than at four, so equality is reported, not required. It skips withoutshaderStorageImageMultisampleorVK_EXT_sample_locationsat 4 samples. Onmain,DecodeStatethrows the refusal quoted above, so the test fails there (RED below).VGT_PRIMITIVE_TYPE1-3, move to what a one-sample depth target refuses). That statement now also says a one-sample depth target's line and point lists throw even when a geometry program turns them into triangles: that block still reads the topology, while the 4x pair decodes such a draw. That entry has 3275 characters onmainsince #7729 rewrote itsPS_ITER_SAMPLEsentences, and 3371 with this change. Changing only these two statements keeps the rebase small for #8121, which rewrites the same entry, where cutting the entry here would turn it into a rewrite.Not changed: rasterized points stay refused (mrfelek's title run below hit no point refusal), except that a geometry program's points from a triangle list, drawn on
mainsince #8856, are now refused as well (above);PA_SC_LINE_CNTLandPA_SU_LINE_CNTLstay unread, as for one-sample lines.Tested
Windows 11 26200, MinGW-w64 GCC 15.2.0 (WinLibs), Release build, AMD Radeon RX 6700 XT (gfx1031, driver 32.0.21045.16010, installed 2026-10-21 22:00; runs before that used 32.0.21045.5002). This branch is one commit (
0efe28a839) onmain2c4b116da9. It is593f4ab868(rebased after #7729 merged) with oneandonlydean's review applied: the three geometry point rows and the debt clause, no source change. On0efe28a839the six focused tests pass 3 of 3; with the point term dropped,agc_driver_graphicsfails at the first new row (controls below); withmain2c4b116da9'sState.cpp, the triangle-list row decodes, soagc_driver_graphicsfails withexpected graphics rejection: multisampled targets rasterized without MSAA_ENABLE are unsupported for points or alpha-to-coverage(run with that row moved first in its function, so thatmain's line refusal does not stop the test before it). The validation layer run below is on593f4ab868:State.cppis the same, and the new rows only decode state inagc_driver_graphics, which creates no Vulkan instance.593f4ab868was rebased after #7729 merged. The one conflict was the debt entry "A one-sample target under a multisampled rasterizer without MSAA_ENABLE", where #7729 rewrote thePS_ITER_SAMPLEsentences; this change still edits only its two points-and-lines statements. On593f4ab868the six focused tests below pass 3 of 3, and the validation layer run (A:main2c4b116da9, the five that exist there; B: this head, all six) has noVUID-line and nowas not found but was requested; the centered-lines test prints the same 27 and 35 pixels as below. Before that, the branch was one commit (5fa781bbc) onmain7ab4b2e56. RED and the controls below ran on the same change onmainb85d972f4. After rebasing, GREEN and the validation run were repeated on 5ac77fd50, which is 0f8e9be7d without its last debt-sentence edit. 5fa781bbc is 0f8e9be7d with the line-strip rows of the one-sample depth target refusal added after review (no source change);agc_driver_graphicspasses 3 of 3 with them. The focused tests areagc_driver_graphics,agc_driver_multisample_centered_lines,agc_driver_sample_multisample_target,agc_driver_native_msaa_vertex_input,agc_driver_msaa_enable_single_sampleandagc_driver_covered_centroid_state.RED,
mainb85d972f4'sState.cppwith this PR's tests,ctest -Von the six tests: 3 of 6 fail.agc_driver_graphicsandagc_driver_multisample_centered_linesfail withAGC graphics: multisampled targets rasterized without MSAA_ENABLE are unsupported for points, lines or alpha-to-coverage;agc_driver_covered_centroid_statefails withAGC graphics: unexpected failure: AGC graphics: multisampled targets rasterized without MSAA_ENABLE are unsupported for points, lines or alpha-to-coverage(its alpha-to-coverage row expects this PR's message). The other three pass.GREEN, this branch,
ctest --test-dir build -R '^(agc_driver_graphics|agc_driver_multisample_centered_lines|agc_driver_sample_multisample_target|agc_driver_native_msaa_vertex_input|agc_driver_msaa_enable_single_sample|agc_driver_covered_centroid_state)$' -V: 6/6 pass in each of three runs, and the new test prints in every run:Controls on this branch, each reverted after its run (
agc_driver_graphics,agc_driver_covered_centroid_stateandagc_driver_multisample_centered_linesfor the first three):!result.alphaToCoverage, the condition 8e5e1682 keeps (the point term dropped, this PR's message kept):agc_driver_graphicsfails at the first new geometry point row (triangle-list input) withexpected graphics rejection: multisampled targets rasterized without MSAA_ENABLE are unsupported for points or alpha-to-coverage(on0efe28a839; before that row existed, all three passed, so the point term had no test that could fail).agc_driver_graphicsfails at draw B withDB_ALPHA_TO_MASK0xaa01 withexpected graphics rejection: multisampled targets rasterized without MSAA_ENABLE are unsupported for points or alpha-to-coverage, andagc_driver_covered_centroid_stateat its 2x row withexpected graphics rejection: without MSAA_ENABLE are unsupported for points or alpha-to-coverage.customSampleLocationscleared): it fails withAGC graphics: VGT_PRIMITIVE_TYPE 2: pixel (5, 1) has 1 of its 4 samples covered by a line with every sample at the pixel center.A row added for one run and not committed: the geometry draw of
tests/Graphics.cppwithVGT_GS_OUT_PRIM_TYPE1 (a line strip) instead of 2 decodes as lines (RasterPrimitiveOf= line) with every sample at the pixel center;agc_driver_graphicspasses with it.Khronos validation layer A/B (
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1,ctest --test-dir build -R <the six tests> -V), same machine and GPU:VUID-linesmainb85d972f4mainmainb85d972f4'sState.cppwith this PR's testsb85d972f4)main7ab4b2e56main7ab4b2e56)No log contains
was not found but was requested. Runs withVK_LOADER_DEBUG=layershowInsert instance layer "VK_LAYER_KHRONOS_validation"foragc_driver_native_msaa_vertex_input,agc_driver_msaa_enable_single_sample(twice) andagc_driver_sample_multisample_targetonmainand on this branch, and foragc_driver_multisample_centered_lineson this branch;agc_driver_graphicsandagc_driver_covered_centroid_statecreate no Vulkan instance.python tools/check_conventions.py --base origin/main, also with this title and body:docs/dev/debt/libSceAgcDriver.md:34: warning: [debt-length] ... 3371 characters; that entry already has 3275 onmain, and this PR changes two statements of it (see How); no other finding.python tools/pr_overlap.py --branch fix/msaa-enable-clear-lines: conflicts only indocs/dev/debt/libSceAgcDriver.md, with #7729 (L27), #8121 (L27), #8424 (L26-27) and #7978 (L29-30); none inState.cpportests/Graphics.cpp. It could not compare 45 open PRs that conflict withmain; none of their changed lines in these three files mentionMSAA_ENABLE,RasterPrimitiveOf, themsaaEnableCleartests or this refusal.Linux, by @simonbbby on 0f8e9be7d (Ubuntu 24.04.3, GCC 13.3, Release,
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, three serial rounds per ICD): the six tests pass on an RTX 3090 (595.99.02) and on gfx1036 with RADV (Mesa 25.2.8); lavapipe passes five and skipsagc_driver_multisample_centered_lines(noVK_EXT_sample_locationsat 4 samples). Centered lines cover 27/36 pixels (list/strip) on the RTX 3090 and 27/35 on RADV, each in all four samples, and match the one-sample references at all 229 compared pixels. Withmain7ab4b2e56'sState.cpp, the centered-lines test fails 3/3 on both GPUs with the refusal quoted above. The line-strip rows above came from that run.In the title (@mrfelek, Linux, RTX 3080 Ti, NVIDIA 615.71.09,
maincecb540a6+ #78039ac1a20ce+ this PR593f4ab86, without local changes): Peace Walker plays through the logos, intro, title screen and New Game into the beach tutorial at about 60 FPS. The log has nopoints, lines or alpha-to-coveragerefusal and no other driver error, and with neither #6801 nor #7869 in that build no point draw was refused either.Linux, RTX 4090 (NVIDIA 610.57.04), by @oneandonlydean on 593f4ab868: the six focused tests pass 3 of 3, centered lines cover 27 and 36 pixels with 0 of 229 differing, and with
main2c4b116da9'sState.cppthe same three tests fail as in the red run above.Not tested: NVIDIA and other drivers on Windows, and the console. 8e5e1682 also drops the point refusal; points rasterized in this state are refused here (a geometry program's point output since #8856, and #6801's vertex-path points), while #7869's point polygon mode passes this check (see Overlaps).
Overlaps:
mainsince #8856, andRasterPrimitiveOfreturns a point for both. This check refuses both in this state: onmainthe vertex-path list throws earlier and the geometry output from a triangle list is drawn.RasterPrimitiveOfdoes not read it, so a triangle draw with a point polygon mode passes this check and is drawn as one-pixel points with every sample at the pixel center. It would be refused only if the polygon mode were decoded before this check andRasterPrimitiveOfread it.main's refusal, which readsVGT_PRIMITIVE_TYPE, lets it through as well. A line polygon mode is drawn as lines are after this PR.VGT_PRIMITIVE_TYPE. This check judges such a draw by the primitive its program outputs (triangles and lines are drawn, points refused), so its input type does not change the outcome; withmain's refusal, a point-list type would be refused and a triangle-strip type drawn for the same program.PS_ITER_SAMPLEsentence of the one-sample target entry this PR edits, #8424 changes the entry right before it and #7978 the entry right after the rewritten one; whichever lands second needs a one-line rebase. pr_overlap.py finds no textual overlap with #6801, #7869 or #8395.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-21T04:13:07Z.
Code review location:
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp; line 1223The new line coverage tests exercise a one-sample color target and a four-sample depth/color pair. This guard now permits line primitives for every multisampled-rasterizer state with MSAA_ENABLE clear, including the one-sample depth target case; the debt entry still says line lists/strips with a one-sample depth target throw, and there is no corresponding execution case here. Is extending the line rule to that depth-target combination intentional and supported by evidence? If so, could the test and debt entry cover/update it; otherwise the guard needs to preserve the refusal for that case.
Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-21T04:26:21Z.
Linux check of exact head
0f8e9be7d30ed7e5e289f5c0e9a750306dea6a65, including the one-sample-depth boundary raised in review:msaaEnableClearOneSampleTargetTestsstill rejects a line list into a one-sample depth target, both depth-only and with a color target. I temporarily expanded that case from primitive2to{2u, 3u}:agc_driver_graphics_testspasses 3/3, confirming the line-strip refusal too. This is decoder/refusal coverage; no unsupported one-sample-depth line was executed.agc_driver_graphics,agc_driver_covered_centroid_state,agc_driver_native_msaa_vertex_input,agc_driver_msaa_enable_single_sample,agc_driver_sample_multisample_target, andagc_driver_multisample_centered_lines. RTX 3090 and gfx1036/RADV each pass all six in every round. Lavapipe passes five and skips centered lines in every round because it has noVK_EXT_sample_locationsat four samples.State.cppfrom parent main7ab4b2e5610c3d4328c83566cba488eb82972c9cmakes centered lines fail 3/3 on each physical GPU withmultisampled targets rasterized without MSAA_ENABLE are unsupported for points, lines or alpha-to-coverage. Restoring the exact PR source, rebuilding and rerunning makes both pass again. The temporary test extension was removed; checkout is clean.Ubuntu 24.04.3, GCC 13.3, Release; NVIDIA RTX 3090 / 595.99.02; AMD gfx1036 (
1002:13c0) / RADV Mesa 25.2.8; lavapipe LLVM 20.1.2 / Mesa 25.2.8.ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1. Khronos validation is unavailable on this host, so this does not supply the validation-layer A/B. No title execution or PS5 line-rule measurement is claimed.Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T05:50:51Z.
Code review location:
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp; line 1223It isn't extended to that case. A one-sample depth target is handled before this guard, in the
depthKeepsSampleZeroblock (State.cpp L1210-L1220), and this PR doesn't change that block. Itsfilledterm rejectsPOINT_LIST,LINE_LISTandLINE_STRIPwitha one-sample depth target under a multisampled rasterizer without MSAA_ENABLE is unsupported for points or lines .... Otherwise it setsresult.samples = 1. Either way a one-sample-depth draw never reaches this guard, which only runs forresult.samples > 1. The guard only changes the case where the target and the rasterizer have the same sample count.msaaEnableClearOneSampleTargetTestsalready covered the line list, both depth-only and with a one-sample color target. 5fa781bbc adds the line strip (VGT_PRIMITIVE_TYPE3) to the same rows. That's the extension @simonbbby ran on Linux (3/3), andagc_driver_graphicspasses 3/3 with it here too (RX 6700 XT). The debt entry still says line and point lists (VGT_PRIMITIVE_TYPE1-3) into a one-sample depth target throw, and that is still the behavior, so the entry is unchanged. There's no execution case because these draws throw before anything is drawn. The PR body now says the same.Imported from boykopovar/AnyPS5. Originally posted by mrfelek on 2026-10-21T16:52:42Z.
Peace Walker reaches the beach tutorial with
main+ #7803 + this PR, without my local changes.AI-assisted; the runs are from my machine(s).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T20:36:07Z.
@thuanquang I checked 593f4ab868 locally on an RTX 4090 (NVIDIA 610.57.04, Linux, Release). The six focused tests pass 3 of 3, and centered lines cover 27 and 36 pixels with 0 of 229 differing. With
main2c4b116da9'sState.cpp, the same three tests fail as in your RED. The line change itself looks right to me. Tessellation can't reach this check with points or lines: decode only accepts triangle and quad domains with triangle output.There's one behaviour change the description doesn't cover. #8856 (merged 20 Oct,
ee81c5112d) made point-list geometry output drawable: at this base,State.cppL1094 acceptsVGT_GS_OUT_PRIM_TYPE0 from a geometry program. So the "No draw onmainrasterizes points in this state" paragraph and the#6801overlap point both rest on theb85d972f4line (L1016), which no longer refuses this.That makes one draw class go from drawn to refused. I took your geometry row in
msaaEnableClearDepthTests(draw B, 4x depth and color pair, MSAA_ENABLE clear) and setVGT_GS_OUT_PRIM_TYPE(0x29b) to 0, withVGT_PRIMITIVE_TYPE4, 2 and 1:State.cppmain2c4b116da9points or alpha-to-coverage)A geometry program that makes points from triangles into such a target is drawn on
maintoday and throws with this PR. Refusing it may be what you want, since rasterized points stay unsupported here. Could you either:main's result for it, if you think the pixel-center argument covers points too?The row also gives the point term a test that can fail. Right now, with the term dropped (
Require(!result.alphaToCoverage, ...)), all six tests still pass on this head.A smaller point, and optional: the one-sample depth block (L1290) still judges points and lines by
result.topology. So there, a point list that a geometry program turns into triangles is refused, while the same draw into the 4x pair now decodes. If you'd rather keep this PR to the 4x check, a line in the debt entry would do.Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-22T03:49:54Z.
@oneandonlydean thanks, and thanks for the RTX 4090 run. I took the first option: rasterized points stay refused in this state, now including a geometry program's points from a triangle list, because nothing measures what the console rasterizes for a point there (the line evidence covers lines only). Pushed
0efe28a839, with no source change:msaaEnableClearDepthTestshas your rows: a triangle, line and point list (VGT_PRIMITIVE_TYPE4, 2 and 1) into a geometry program withVGT_GS_OUT_PRIM_TYPE0 into draw B's 4x pair, all refused with this check's message. With the point term dropped,agc_driver_graphicsnow fails at the triangle-list row. Withmain2c4b116da9'sState.cppthat row decodes, as in your table (I moved it first in the function somain's line refusal doesn't stop the test before it).mainrasterizes points in this state" paragraph and the #6801 overlap now account for #8856, and your run is in Tested.The six focused tests pass 3 of 3 on
0efe28a839(RX 6700 XT, Windows).Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-22T04:34:22Z.
@thuanquang thanks, that's the answer I was hoping for. I checked
0efe28a839against the head I tested: the source is unchanged, and the three new rows are what now pin the point term. With onlyRasterPrimitiveOf(result) != Pointdropped from that check,agc_driver_graphicsfails with "expected graphics rejection" at the new rows, where on 593f4ab868 the same change passed. The PR passes 3 of 3 merged with current main. The description and the debt line read right to me too.One small thing, no change needed: the new loop sits after the line-list decode rows, so with
main'sState.cppthe test stops at a line row before it gets there. The point-term check above covers what the rows are for.Next I'll run the full workflow on this head, then a no-worse run in the two titles we check every draw change against.