feat(agc): draw a depth target with fewer samples than the rasterizer at its own samples #25525
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25525"
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 frankea on 2026-11-22T07:22:30Z.
What
A draw whose depth/stencil target stores fewer samples than the rasterizer covers (EQAA with fewer Z/S samples than coverage samples:
DB_Z_INFO.NUM_SAMPLESbelowPA_SC_AA_CONFIG.MSAA_NUM_SAMPLES, more than one) threw "the depth target's sample count differs from the rasterizer's" inDecodeState. Only the one-sample case was handled, by the sample-0 rule of9bf98992ff(rasterizesSampleZeroOnly/rasterizeSampleZero).This PR extends that rule from one stored sample to Z stored samples, for draws that write no color:
DecodeState: when the depth target has 1 < Z < N samples andPA_SC_MODE_CNTL_0.MSAA_ENABLE(0x292 bit 0) is set,requireLeadingDepthSampleschecks the draw andrasterizeLeadingSamples(result, Z)draws it with Z samples at the first Z coverage sample locations of each pixel of the 2x2 grid.customSampleLocationsandsampleLocationGridare recomputed for Z samples, so leading samples at the standard Z-sample positions need no VK_EXT_sample_locations.rasterizeSampleZerois now the Z = 1 call ofrasterizeLeadingSamples(same locations, custom and grid flags as before).PS_ITER_SAMPLE, centroid, sample, ancillary or coverage pixel inputs, a depth or sample-mask export (DB_SHADER_CONTROLbits 0 and 8), overrasterization (DB_EQAAbits 24-27), andDB_EQAAZ interpolation (INTERPOLATE_COMP_Z/INTERPOLATE_SRC_Z, bits 18-19) while the depth test is on, since the console may then test non-anchor samples against interpolated Z.MSAA_ENABLEthe draw keeps today's refusals.rasterizeLeadingSamplesmarks the state (State::leadingSamples), andplanDraw(both the prepared and the recipe path) calls the newValidateLeadingSamples, which refuses by name ("a draw rasterized at the leading samples of a target with fewer samples than the rasterizer is unsupported when its pixel shader writes memory ...") when the fragment stage'sShadersWriteMemoryis true (storage buffer or image writes, GDS, BDA stores). Vertex-stage writes are not affected. The sample-0 rule (Z = 1) had the same gap and goes through the same call, so it now refuses these shaders too. That is a behaviour change: a title that passes the sample-0 rule today with such a shader now stops here instead of losing those writes. GT7 does not reach it; I have not checked other titles.DecodeStatecannot check this, since it does not see the compiled shaders. A pixel shader with no color target, no export and noEXEC_ON_NOOPis skipped by the driver (PixelProgramSkipped) and is not affected.Register semantics (field positions from Mesa's gfx10.json):
PA_SC_AA_CONFIG.MSAA_NUM_SAMPLESis the coverage sample count andDB_Z_INFO.NUM_SAMPLESthe Z/S samples stored per pixel; radeonsi programs EQAA modes with fewer Z samples than coverage samples ("4s 2z" style) and setsDB_EQAA.MAX_ANCHOR_SAMPLESfrom the Z sample count. Which stored sample a coverage sample past Z updates whenSTATIC_ANCHOR_ASSOCIATIONSis 0 is not documented anywhere I found, so this PR assumes coverage samples Z..N-1 are dropped (truncation to the anchors), as the sample-0 rule does for Z = 1.MAX_ANCHOR_SAMPLESis not checked: GT7'sDB_EQAA0x00052202 sets it to 2 (four anchors) over a two-sample target, unlike radeonsi, and an anchor count above Z is assumed to change nothing. Not measured on a PS5.Debt: a new entry, "Depth targets with fewer samples than the rasterizer" (fragment
docs/dev/debt/changes/fix-depth-fewer-samples-than-coverage.md), states the truncation and anchor-count assumptions and the refusals, including the memory-writing pixel shader refusal for both rules.Tested
tests/Graphics.cpp(agc_driver_graphics): Gran Turismo 7's sample state (4 coverage samples,DB_EQAA0x00052202, a 2-sample D32S8 target, stencil only; the test's target has no HTILE, while GT7's has a depth-only HTILE (DB_Z_INFO.TILE_SURFACE_ENABLE1, stencil untiled byTILE_STENCIL_DISABLE), sample words 0x22eea66a) decodes as 2 samples at (-6,6) and (6,-6) with custom locations; leading standard positions (0xa66acc44) decode as the standard 2x pattern; leading samples swapped in one pixel decode as a 2x grid; a depth test without Z interpolation is accepted; a 4-sample depth target under an 8-sample rasterizer decodes as 4 samples; each refusal above is checked by its message; withoutMSAA_ENABLEthe old refusal stays.ValidateLeadingSamplesrefuses a leading-sample state with a pixel shader that stores to a buffer, and accepts the same state with only a vertex shader that stores, and the same shaders when the state is not marked; the PPSA01317 state and the one-samplePS_ITER_SAMPLEcase (Z = 1) are marked, and a draw whose targets match the rasterizer is not.tests/execution/DepthFewerSamples.cpp(agc_driver_depth_fewer_samples, PM4 throughsceAgcDriverSubmitDcb): a 2-sample stencil plane is filled with 0x25, a stencil-only draw (REPLACE 0x5a, no color written) under a 4-sample rasterizer withMSAA_ENABLEcrosses it with a shallow edge, then a DB stencil copy (DB_RENDER_CONTROLSTENCIL_COPY, COPY_SAMPLE 0 or 1) reads each stored sample into an R8 target. Each stored sample k must hold 0x5a exactly where coverage sample k's location lies inside the triangle, computed on the CPU from its integer vertices in exact 1/32-pixel units (the test throws if a location lies on an edge, so no tie rule is involved), and the two stored samples must differ. An earlier version took the expected coverage from a one-sample draw with a fractional viewport, which an AMD gfx1201 run showed depends on the driver;1f78603b84replaced it. Two location sets: leading standard positions (no VK_EXT_sample_locations needed) and GT7's (-6,6), (6,-6), (-2,-2), (2,2). Last, the same four-sample stencil draw with a pixel shader that does aglobal_store_dwordand setsEXEC_ON_NOOP(DB_SHADER_CONTROLbit 10) must be refused with the new message. Mutations checked on the Mac: taking coverage samples 2 and 3 instead of 0 and 1 fails the first case; decoding the leading samples as standard locations fails both tests (GT7's location case and the location check intests/Graphics.cpp); dropping the Z-interpolation refusal failstests/Graphics.cpp; removing theValidateLeadingSamplescall fromplanDrawfailsDepthFewerSamples.cpp(the storing draw is not refused); not marking the state inrasterizeLeadingSamplesfails both tests; makingValidateLeadingSamplesreturn early fails both tests.In the base runs, main's
State.cppwas built with this PR's test files. On main,tests/Graphics.cppdoes not compile with this PR's version (it readsState::leadingSamplesand callsValidateLeadingSamples), so the main column foragc_driver_graphicsis the previous revision of the test, which fails with the message below.76de27b03ac5067369cbagc_driver_graphics,agc_driver_depth_fewer_samplestests/Graphics.cppdoes not build)stencil_copy_draw,msaa_enable_single_sample,sample_mask_depth_stencil,sample_mask_multisample,eqaa_color_target,sample_order,multisample_readback,stencil_replayagc_driver_graphics,agc_driver_depth_fewer_samplesstencil_copy_draw,msaa_enable_single_sampleTitle: Gran Turismo 7 (PPSA01317), Windows, RTX 4090. In the garage/photo scenes after the World Map, GT7 draws a stencil-only pass (PS 0x1258d78900) with 4 coverage samples,
MSAA_ENABLE,DB_EQAA0x00052202 and a 512x512 2-sample D32S8 target (DB_Z_INFO0xa2900987, depth test and writes off, stencil ALWAYS,CB_TARGET_MASK0, PERSP_CENTER only, sample words 0x22eea66a), and main refuses it with "the depth target's sample count differs from the rasterizer's". One run on main729981cb5a+ #22767 + #7256 + #9335 + #16935 + this PR (warm shader cache,APS5_SPLIT_TABLE_CALLS=1, CROSS throughAPS5_PAD_INPUT_FILE): menu at 258 s, CROSS at 288 s, then at 553 s (2.25 FPS) it stops on this PR's own refusal, "a depth target with fewer samples than the rasterizer is unsupported for draws that write a color target", right after the same pixel shader is prepared. So the title also draws a color-writing pass into a target of this shape, which needs mixed color/depth sample counts and is left for a separate PR.Checklist
main; no other open PR implements the same functions (searched open PRs for depth sample count, EQAA depth and anchor samples; #23386 refuses depth targets with a sample count the device cannot hold and does not touch this path; #19943 changesPipeline.cppsample-location plumbing, notState.cpp)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repositorySummary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T07:40:15Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
c5067369cb5572ddab1881dd68d5d643fc739434usingrepo_read.pyto inspect the prepared diff and targeted source ranges. I did not run tests or builds; the results described in the PR body are author-reported.Results
Negative control
Not run by me. The PR body reports mutation checks for the sample selection and refusal paths; those results were not independently verified.
Findings
Blocking
None identified in the inspected changes.
Non-blocking
MAX_ANCHOR_SAMPLESexceeds the stored sample count remain assumptions, as the PR description and debt note state. A PS5 measurement would confirm them before closing that debt item. (State.cpp, debt note)Sources
Reviewed the prepared diff and targeted ranges of
State.cpp,Pipeline.cpp,Draw.cpp,State.hpp,Pipeline.hpp,Graphics.cpp, andDepthFewerSamples.cpp, plus the added debt note. The relevant changed test section inGraphics.cppwas read through the pinned reader although its full text was not included in the review bundle. No changed file was excluded from review.Not verified
Tests, builds, reported mutation checks, behavior on a physical PS5, and unchanged portions of the large
Graphics.cppfile were not independently verified.To get this to a good state
Nothing is required. The optional follow-up is to measure the anchor behavior on a PS5 and update the debt note when confirmed.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-26T15:34:04Z.
Review: COMMENTED
Actionable comments posted: 1
bbaee01e-18f5-494b-a61e-73e648f913f6Reviewing files that changed from the base of the PR and between
3ddd8d5e05and1f78603b84.core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/execution/DepthFewerSamples.cppdocs/dev/debt/changes/fix-depth-fewer-samples-than-coverage.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T15:45:28Z.
Review: COMMENTED
Reviewed — comments
Changes are supported by focused code inspection, but I could not confirm all changed files or run the reported checks, so a formal approval is not justified.
What I ran
Inspected prepared diff at head
1f78603b84dc62037a1d6280a36155e237e4641fand read the changed implementation, execution test, and debt entry throughrepo_read.py. No commands or tests were run by me.Results
Graphics.cppfull text was excludedFindings
Blocking
None identified in the code inspected.
Non-blocking
None.
Not verified
Full text of
core/libs/prx/libSceAgcDriver/tests/Graphics.cppwas excluded as too large for the review folder; only its diff was inspected. I did not inspect the full text ofPipeline.hpp,State.hpp,Draw.cpp, orPipeline.cpp.State.cpp,DepthFewerSamples.cpp, and the debt entry were read. No tests were run, and the described hardware results and PS5 behavior were not independently confirmed. The diff states that truncation to the leading anchors is assumed and has not been measured on PS5.To get this to a good state
Nothing is required. The description's test and hardware results are useful context but remain author reported in this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T03:37:11Z.
Review: COMMENTED
Reviewed — comments
The code implements the described leading-sample path and its refusals; runtime tests and PS5 behavior were not independently verified.
What I ran
Reviewed head
54544a7b121cd0a8d084032e108ff19f79591283. I read the prepared description, commits, manifest, and diff, then inspected the changed code and relevant tests throughrepo_read.py. I did not run commands or tests.Results
Negative control
Not run by me. The description reports mutation checks on macOS; those results were not independently confirmed.
Findings
Blocking
None.
Non-blocking
MAX_ANCHOR_SAMPLESabove the target sample count changes behavior. The description and debt entry document these limits; validating them on console hardware would increase confidence. SeeState.cpp:140-142in the diff.Sources
State.cppPipeline.cppNot verified
I read all seven changed files, including the full new
DepthFewerSamples.cppand the changed regions ofGraphics.cpp(its full text was excluded from the review folder as too large). No changed file was excluded from inspection. I did not run the tests or validate the author-reported Windows/macOS runs, the PS5 behavior, the documented sample-anchor assumptions, or files outside this change.To get this to a good state
Nothing is required. Optional: confirm the anchor mapping and
MAX_ANCHOR_SAMPLESbehavior on PS5 hardware.