Skip to content

fix(agc): draw a PS_ITER_SAMPLE program once per pixel into a one-sample depth target - #7729

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
milescoviello:fix/one-sample-depth-iter
Oct 21, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
milescoviello:fix/one-sample-depth-iter

Conversation

@milescoviello

@milescoviello milescoviello commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What

A one-sample depth target under a multisampled rasterizer without MSAA_ENABLE is drawn as a one-sample draw at the pixel center (#6196's follow-up, 3dadf77). A pixel program that runs with PS_ITER_SAMPLE threw there. Ghost of Tsushima (PPSA02225) draws its depth-only, alpha-tested pass this way and stops on it: 2x PA_SC_AA_CONFIG, PA_SC_MODE_CNTL_0 0x2 (MSAA_ENABLE clear), PA_SC_MODE_CNTL_1 0x06030000 (PS_ITER_SAMPLE), DB_SHADER_CONTROL 0x50 (KILL_ENABLE), no color target, and no ANCILLARY or SAMPLE_COVERAGE input.

On this path every sample is taken to be at the pixel center, and the one-sample target keeps sample 0's coverage. So whether the console runs such a program once per pixel or once per sample, each invocation gets the same position, interpolants and derivatives, and gives the same kill decision, depth and color, and only sample 0's reaches the target. The program is now drawn once per pixel, without sample shading (perSampleShading was already off here, since the draw has one sample).

  • ANCILLARY (sample index) and SAMPLE_COVERAGE inputs still throw, as do points, lines, alpha-to-coverage, a sample-mask export and DB_EQAA Z interpolation or overrasterization.
  • The one thing that can still differ is the memory accesses of such a program, if the console runs it once per sample: atomics and append or consume counters count once per pixel here. The debt entry says so.
  • The one-sample color target branch without a depth target still refuses PS_ITER_SAMPLE; it isn't needed by any title I know of yet.

@SandstromPL, who added this refusal with the one-sample depth path, checked the reasoning: without an ANCILLARY or SAMPLE_COVERAGE input an invocation can't tell which sample it runs for. Following their suggestions, ff312a7 rewords the debt entry: it now says up front that PS_ITER_SAMPLE alone still throws only with one-sample color targets and no depth target, and that atomics and append or consume counters are where a console that runs such a program once per sample would give a different result.

Tested

Ubuntu 24.04, GCC 13.3, NVIDIA RTX 4070 Ti (595.99.02), on main ca13a56.

  • agc_driver_graphics: the case that expected the refusal for PS_ITER_SAMPLE with KILL_ENABLE now decodes as one sample, with or without a one-sample color target, with no sample shading, and passes the precheck. Adding an ANCILLARY input to it still throws.
    • On main with the changed test, it fails on the refusal (a one-sample depth target under a multisampled rasterizer without MSAA_ENABLE is unsupported ...).
    • With the change, it passes 3 of 3.
  • The 59 tests matching multisample|msaa|sample|depth|^agc_driver_graphics$ pass.
  • Windows: @xXPBSXx ran it merged onto main 676d423 (MinGW-w64, WinLibs): agc_driver_graphics passes 3 of 3, and fails 3 of 3 with main's State.cpp and the changed test.
  • Intel and AMD, Windows: @savvaniss ran it on an Intel UHD 770 and an AMD RX 9070 XT, merged into main 6b8228b. The 21 tests built from tests/Graphics.cpp pass 3 of 3. With only this PR's test change, agc_driver_graphics fails on the refusal.
  • Rebased 10-19 onto main f72c7aa (head 1f63ba3). @blawesom offered the same rebase, green on an RX 9070 XT with RADV. The debt line is cut to the gap, as CONTRIBUTING.md now asks, with no title named in it. The 621 tests matching ^agc_driver_|^agc_shader|recompiler|spirv pass, and agc_driver_graphics passes 3 of 3.
  • Ghost of Tsushima (PPSA02225), with fix(libScePlayGo): list chunks 0 to 999 when only a scenario file is present #7726 and fix(agc): draw a stencil replacement against a known stencil value as an inversion #7725: without this PR it stops 41 s in on this refusal. A logging build showed the two such draws reaching this path: one with PS_ITER_SAMPLE (PA_SC_MODE_CNTL_1 0x06030000, DB_SHADER_CONTROL 0x50), which threw, and one without it, with a depth export (DB_SHADER_CONTROL 0x11). With this PR it draws past both and stops 39 s in at an unrelated check, a compute shader that imports a multisampled depth or stencil surface (native multisample stencil or depth format import is not implemented).
  • Khronos validation, as CONTRIBUTING.md asks: Ubuntu's 1.3.275 layer loaded with VK_LAYER_PATH, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -V, RTX 4070 Ti, Linux. Neither log reports was not found but was requested by env var VK_INSTANCE_LAYERS. ^agc_driver_graphics$ on main f72c7aa and on this PR's code (c7aa42ebe5, the same code as the current head) gives no validation messages in either log.
  • The same comparison under the LunarG SDK's 1.4.363 layer, the version Windows reviewers run: no validation messages on main f72c7aa or on this head.

Checklist

🤖 Generated with Claude Code

@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Oct 19, 2026
@SandstromPL

Copy link
Copy Markdown
Contributor

@milescoviello yes, the reasoning holds for me. I didn't have a specific case in mind; the refusal was there because I hadn't worked through what per-sample invocations could observe on this path. With MSAA_ENABLE clear every sample is taken to be at the pixel center, which this path already assumes. So without an ANCILLARY or SAMPLE_COVERAGE input, an invocation can't tell which sample it runs for. Sample-rate interpolants, derivatives, the kill decision, an exported depth and the color all come out the same, and the one-sample targets keep sample 0's. The diff and the test look right to me: the old case now decodes as one sample without sample shading, and adding ANCILLARY still refuses it. I only read it and didn't run it.

Two small suggestions, take them or leave them:

  • The debt entry still opens with "PS_ITER_SAMPLE, an ANCILLARY or SAMPLE_COVERAGE pixel input and a sample-mask export throw in a pixel program that runs", and makes the exception two sentences later. Saying there that PS_ITER_SAMPLE alone only throws on the color-only path would read more directly.
  • "Only the memory writes … can differ" could name atomics and append/consume counters, since those are where a once-per-sample console would give a different result rather than just repeat a write.

The color-only branch could take the same rule later; I agree it can wait for a title.

AI-assisted: yes (Claude Code)

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 8871 docs/dev/debt/libSceAgcDriver.md L34

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.

Pull request Shared files not compared
PR 1191 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 2434 docs/dev/debt/libSceAgcDriver.md
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4448 docs/dev/debt/libSceAgcDriver.md
PR 4449 docs/dev/debt/libSceAgcDriver.md
PR 5058 docs/dev/debt/libSceAgcDriver.md
PR 5372 docs/dev/debt/libSceAgcDriver.md
PR 5441 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5499 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 5925 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 6194 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6223 docs/dev/debt/libSceAgcDriver.md
PR 6235 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6280 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6300 docs/dev/debt/libSceAgcDriver.md
PR 6412 docs/dev/debt/libSceAgcDriver.md
PR 6481 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6548 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6549 docs/dev/debt/libSceAgcDriver.md
PR 6801 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6808 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6867 docs/dev/debt/libSceAgcDriver.md
PR 6868 docs/dev/debt/libSceAgcDriver.md
PR 6887 docs/dev/debt/libSceAgcDriver.md
PR 6946 docs/dev/debt/libSceAgcDriver.md
PR 6947 docs/dev/debt/libSceAgcDriver.md
PR 6965 docs/dev/debt/libSceAgcDriver.md
PR 6973 docs/dev/debt/libSceAgcDriver.md
PR 6977 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6987 docs/dev/debt/libSceAgcDriver.md
PR 6989 docs/dev/debt/libSceAgcDriver.md
PR 6995 docs/dev/debt/libSceAgcDriver.md
PR 7002 docs/dev/debt/libSceAgcDriver.md
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7449 docs/dev/debt/libSceAgcDriver.md
PR 7505 docs/dev/debt/libSceAgcDriver.md
PR 7604 docs/dev/debt/libSceAgcDriver.md
PR 7642 docs/dev/debt/libSceAgcDriver.md
PR 7800 docs/dev/debt/libSceAgcDriver.md
PR 7803 docs/dev/debt/libSceAgcDriver.md
PR 7883 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7893 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7910 docs/dev/debt/libSceAgcDriver.md
PR 8014 docs/dev/debt/libSceAgcDriver.md
PR 8070 docs/dev/debt/libSceAgcDriver.md
PR 8105 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 8395 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 8424 docs/dev/debt/libSceAgcDriver.md
PR 8538 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 8564 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 8592 docs/dev/debt/libSceAgcDriver.md
PR 9020 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9077 docs/dev/debt/libSceAgcDriver.md

@xXPBSXx

xXPBSXx commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Windows data point for 2c99c48ff alone merged onto main 676d42396 (merge e3beedebf, clean): Windows, MinGW-w64 (WinLibs) toolchain, ANYPS5_NO_SHADER_CACHE=1, ctest -R '^agc_driver_graphics$', three separate ctest invocations.

  • With the PR: exit code 0 in 3 of 3 runs.
  • Same tree with Graphics/src/State.cpp restored to main (the changed test kept): exit code 8 in 3 of 3 runs. The tail of a failing run ends with AGC graphics: unexpected failure: AGC graphics: a one-sample depth target under a multisampled rasterizer without MSAA_ENABLE is unsupported for points or lines and with alpha-to-coverage, PS_ITER_SAMPLE, a sample index or coverage input, a sample-mask export, or DB_EQAA Z interpolation or overrasterization (the message names PS_ITER_SAMPLE among the refused cases).

agc_driver_graphics is the only test I ran. Not tested: the other multisample tests listed in the PR, a title run, other GPUs.

AI-assisted (Claude Code).

@milescoviello

Copy link
Copy Markdown
Contributor Author

@SandstromPL thanks for working through it, and for both suggestions. I took them in ff312a7. The debt entry now says at the start that PS_ITER_SAMPLE alone still throws only with one-sample color targets and no depth target. It also names atomics and append or consume counters as the accesses where a once-per-sample console would give a different result. It's a docs-only commit, so the test results stand.

@xXPBSXx thanks for the Windows run, including the reverted State.cpp control. It's in the description now.

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@blawesom

Copy link
Copy Markdown
Contributor

Rebase handoff — rebased onto current main cleanly (both commits, authorship unchanged).

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; conventions pass; full suite green apart from the four known main regressions (#5444 Mesa, #7584 BDA, #7766, #7784), none from this PR.

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/7729
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is f962ba0ac.

@savvaniss

Copy link
Copy Markdown
Contributor

Intel and AMD Windows data: with this PR's test changes, agc_driver_graphics fails on main and passes with the PR, on an Intel UHD 770 and an AMD RX 9070 XT.

Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built, ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, with VkCache emptied first. This head ff312a718 merged into main 6b8228b2b. "Without" means only this PR's diff to tests/Graphics.cpp, applied to main 6b8228b2b.

Tests, ×3 UHD 770 RX 9070 XT
This head: the 21 tests built from tests/Graphics.cpp 21 of 21 pass 21 of 21 pass
Without agc_driver_graphics fails: a one-sample depth target under a multisampled rasterizer without MSAA_ENABLE is unsupported for points or lines and with alpha-to-coverage, PS_ITER_SAMPLE, ...; the other 20 pass same

AI-assisted: yes (Claude Code)

milescoviello and others added 2 commits October 19, 2026 11:05
…ple depth target

A one-sample depth target under a multisampled rasterizer without
MSAA_ENABLE is drawn as a one-sample draw at the pixel center, but a pixel
program that runs with PS_ITER_SAMPLE threw. Ghost of Tsushima (PPSA02225)
draws its depth-only pass this way (2x PA_SC_AA_CONFIG, PA_SC_MODE_CNTL_1
0x06030000, KILL_ENABLE, no sample index or coverage input) and stops on it.

Every sample is taken to be at the pixel center on this path, so
invocations per sample would get the same inputs and give the same depth,
kill and color results, and the target keeps sample 0's. Such a program is
now drawn once per pixel, without sample shading. ANCILLARY and
SAMPLE_COVERAGE inputs still throw. The debt entry notes that only the
memory writes of such a program can differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ry accesses can differ

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@milescoviello
milescoviello force-pushed the fix/one-sample-depth-iter branch from ff312a7 to 1f63ba3 Compare October 19, 2026 11:28
@milescoviello

Copy link
Copy Markdown
Contributor Author

@blawesom thanks for the rebase and the RADV run. I pushed my own rebase onto main f72c7aa (1f63ba3), not yours, because the debt line also had to change. oneandonlydean asked for no titles to be named in the debt files, and CONTRIBUTING.md now asks for entries cut to the gap. The code changes are the same as in yours. The 621 driver and recompiler tests pass on the new head, and agc_driver_graphics passes 3 of 3.

@savvaniss thank you for the UHD 770 and RX 9070 XT runs, with the test-only control failing on both. They're in the description now.

AI-assisted: yes (Claude Code)

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Picking this up for our testing: it addresses the stop we see in PPSA03208 on current main, one of the titles we're bringing up, and we'd like to move it into main. We'll review, test and merge it under the normal process. Your comments and review are still very welcome, @adriadam10.

@oneandonlydean oneandonlydean self-assigned this Oct 20, 2026
@milescoviello

Copy link
Copy Markdown
Contributor Author

Thanks @oneandonlydean. It merges cleanly with current main, so I'll leave the branch alone while you test it, unless you'd like a rebase or a change. #8121 makes the same change for a one-sample color target, in case PPSA03208 needs that case too.

AI-assisted: yes (Claude Code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants