fix(agc): draw a stencil replacement against a known stencil value as an inversion #7725
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7725"
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 milescoviello on 2026-10-19T03:11:06Z.
What
DB_STENCILREFMASKholds a test value (STENCILTESTVAL) and a separate operation value (STENCILOPVAL).REPLACE_OP,ONESandREPLACE_TESTwrite a value that can differ from the test value on bits the compare reads, while Vulkan has one reference for both. Such a face threwstencil replacement ... is unsupported. Ghost of Tsushima (PPSA02225) stops on one at its splash screen: anEQUALtest against 0xff whose pass operation isREPLACE_OPwith 0x40, both masks 0xff.Some compares fix the stencil value wherever an operation runs:
EQUAL,LEQUALagainst the largest masked value,GEQUALagainst 0;NOTEQUAL,LESSagainst 0,GREATERagainst the largest masked value.There, if every written bit is also compared, the written bits hold the test value, so writing
valueis the same as inverting the bits where it differs from the test value. The face becomes anINVERTwhose write mask is(test ^ value) & writeMask, and its reference stays the test value for the compare.KEEPbecomes the same inversion (for exampleREPLACE_OPon both pass and depth fail). Any other combination still throws, now with its own message.Tested
Ubuntu 24.04, GCC 13.3, NVIDIA RTX 4070 Ti (595.99.02), on
main8a526d4495.agc_driver_stencil_known_replacefills the stencil with a value, draws with one of the cases below, and then probes the stencil with anEQUALdraw that must cover exactly the filled pixels:EQUAL0xff,REPLACE_OP0x40 on pass, then on pass and depth fail → 0x40;EQUAL0x25,ONES→ 0xff;EQUAL0xff,REPLACE_OP0x40 through write mask 0xf0 → 0x4f;NOTEQUAL0xff andGREATER0xff,REPLACE_OP0x40 on fail → 0x40, with no color written;LEQUAL0xff,REPLACE_OP0x40 → 0x40.mainwith the new and changed tests, both fail:agc_driver_stencil_known_replaceonstencil replacement 0x40 against test value 0xff,agc_driver_graphicson0x05 against test value 0x02.agc_driver_graphics: the decode case that expected thestencil replacementfailure (EQUAL2,REPLACE_OP5) now expectsINVERTwith write mask 7 and reference 2. New decode cases cover depth fail,NOTEQUAL,LEQUALandGREATER. The refusals that remain are checked:NOTEQUALon pass,LESSon pass, a write mask wider than the compare mask,LEQUALagainst 0x7f, and aZERObeside the inversion.stencil|depth|^agc_driver_graphics$|htilepass.agc_driver_stencil_known_replaceruns there (no skip) and, likeagc_driver_graphics, passes 3 of 3 on both drivers. With this PR'sState.cpphunks reverted, both fail with the refusals above. The rest of their^agcsuite is unchanged.main676d42396with #7726 (MinGW-w64, WinLibs):agc_driver_stencil_known_replacepasses 3 of 3, and fails 3 of 3 withmain'sState.cpp.main7f596df48. Without this PR,agc_driver_stencil_known_replacefails 3 of 3 on the0x40 against test value 0xffrefusal. With it, the test passes 3 of 3, and so doesagc_driver_graphics. The other stencil tests pass exceptagc_driver_stencil_replay_no_gpl, which fails the same way without this PR (the GPL cache-order effect #6436 targets).main6b8228b2b. The 22 tests built from the two test files pass 3 of 3. With only this PR's test changes,agc_driver_graphicsandagc_driver_stencil_known_replacefail with the two refusals above.stencil replacement 0x40 against test value 0xff (masks 0xff/0xff), in 2 of 2 runs (23 s and 47 s in). A logging build showed the face: compare 2 (EQUAL), operations 0x040 (REPLACE_OPon pass). With this PR it draws past it and stops 41 s in at an unrelated check: a one-sample depth target under a 2x rasterizer withPS_ITER_SAMPLE.main50efb5c405. Onmainit aborts on the samestencil replacement 0x40 against test value 0xffrefusal. With this PR it gets past it and stops on the one-sample-depth refusal that #7729 handles.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 reportswas not found but was requested by env var VK_INSTANCE_LAYERS.^agc_driver_graphics$|stencil_known_replaceonmain8a526d4495and this PR:agc_driver_graphicsgives no validation messages on either. The newagc_driver_stencil_known_replacereports onlyVUID-VkDeviceCreateInfo-pNext-pNext(newer device extensions) andVUID-VkGraphicsPipelineCreateInfo-pLibraries-06681. This older layer reports both for every device-creating test onmaintoo: 15 and 141 times overmain's tessellation and journal tests, for example.main8a526d4495or with this PR. The 1.4.363 layer doesn't report the old layer'spNext-pNextandpLibraries-06681.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 github-actions[bot] on 2026-10-19T03:28:47Z.
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.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/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.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/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.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-19T04:28:29Z.
Review: COMMENTED
Apple GPU / MoltenVK run.
agc_driver_stencil_known_replaceruns on Metal (no skip) and passes. It fails without the fix with the refusal from the description. The full^agcsuite is unchanged.Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Head
c9fe9292d, PR diff applied cleanly. Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0) and MoltenVK main + SPIRV-Cross #2704.Tested: the tree is
maina373e85e5+ mugurc's macOS series (ci/macos-series-2) + the PRs needed to build on macOS (#6667, #6668, #7524, #6969, and two files of #7332), not plainmain(it doesn't build on macOS yet). Also in the same build: #7725, #7729, #7717, #7694, #7682, #7731 and #6815 (they applied cleanly together), plus a test-only patch that lets nine AGC fixtures load the Vulkan loader on macOS (branchjotitadev:fix/agc-tests-vulkan-loader-macos). Base on that tree: 40^agcfailures with MoltenVK 1.4.2 and 26 with MoltenVK main + #2704.agc_driver_stencil_known_replace(stencil replacements with a known stencil value passed) andagc_driver_graphicspass 3 of 3 on both drivers, as do the otherstencil,depthandhtiletests in the tree. Twomultisampletests fail the same way as on the base.State.cppreverted, both tests fail on both drivers.agc_driver_stencil_known_replacefails withstencil replacement 0x40 against test value 0xff (masks 0xff/0xff) is unsupported, andagc_driver_graphicswith0x05 against test value 0x02.^agcsuite with the stack: the base failures on each driver, plusagc_driver_pooled_buffer_rangeandagc_performance_overlay, which only run because of the loader patch. Nothing from this PR.GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704)
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-19T05:27:13Z.
Windows data point for
c9fe9292d(this PR) merged ontomain676d42396together with #7726 (42f4382bc) in one tree (f58459c78, both merges clean,git statusempty): Windows 10 (10.0.19045), MinGW-w64 (WinLibs) toolchain,ctest -R '^agc_driver_stencil_known_replace$', one fresh process per run.Graphics/src/State.cpprestored tomain(git checkout upstream/main -- core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp, the new test kept; #7729 is not in this tree): fails 3 of 3 (exit code 8) withAGC graphics: stencil replacement 0x40 against test value 0xff (masks 0xff/0xff) is unsupported.Not tested: a title run, other GPUs, Linux.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T06:05:29Z.
@jotitadev @xXPBSXx thank you both. jotitadev's MoltenVK runs on two drivers show the new test runs on Metal and catches the change there. xXPBSXx's Windows run, with the reverted
State.cppcontrol, covers the MinGW build. Both are in the description now.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-19T08:08:14Z.
An AMD run: RX 6700 XT (gfx1031, RDNA 2), AMD driver 32.0.21045.5002, Windows 11 26200, WinLibs GCC 15.2.0 r7, Release. Base
main7f596df48(with #7074 merged, which touches only f16 fma translation), then this PR's headc9fe9292dmerged on top (clean).agc_driver_stencil_known_replacefails 3 of 3:stencil replacement 0x40 against test value 0xff (masks 0xff/0xff) is unsupported.agc_driver_graphicspasses 3 of 3.agc_driver_sample_mask_depth_stencil,agc_driver_stencil_null_feedback,agc_driver_stencil_ref_export,agc_driver_stencil_ref_export_unused,agc_driver_stencil_replay), exceptagc_driver_stencil_replay_no_gpl. That one isn't this PR: it is the GPL cache-order effect of #4768 on AMD's Windows driver. From a fresh driver cache (a renamed copy of the executable), whichever GPL mode runs first passes and the other mode then fails withvkQueueSubmit recorder: Vulkan result -4, and it does exactly the same without this PR (onmain7f596df48with only #7769, a storage-flush fix, merged). #6436 targets that.Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-19T09:33:54Z.
Intel and AMD Windows data: with this PR's test changes,
agc_driver_graphicsand the newagc_driver_stencil_known_replacefail onmainand pass 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, withVkCacheemptied first. This headc9fe9292dmerged intomain6b8228b2b. "Without" means only this PR's diff totests/Graphics.cppand the newtests/execution/StencilKnownReplace.cpp, applied tomain6b8228b2b.agc_driver_graphicsfails:stencil replacement 0x05 against test value 0x02 (masks 0xff/0xff) is unsupported;agc_driver_stencil_known_replacefails:stencil replacement 0x40 against test value 0xff (masks 0xff/0xff) is unsupported; the other 20 passAI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T11:27:11Z.
@thuanquang @savvaniss thank you both, the runs are in the description now. They cover RDNA 2, RDNA 4 and Intel on Windows, each failing without the fix and passing with it. Thanks also, thuanquang, for checking
agc_driver_stencil_replay_no_gplseparately: it fails the same way without this PR, so that's #6436's cache-order issue and not this change.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T18:49:51Z.
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.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T19:02:35Z.
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.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T10:13:49Z.
Title data point for this PR (data only).
Title: PPSA02225, 300 s per run through the runner,
ANYPS5_GPU=4080; both.outlogs showSelected GPU name=NVIDIA GeForce RTX 4080 SUPER vendor=0x10de device=0x2702 subgroup=32. Windows 10 Pro 10.0.19045, WinLibs GCC 15.2.0, Release, the relinker and all libs built from the same tree.Baseline,
main50efb5c405(run_120636.err):then
FATAL: abort() (SIGABRT)(lines 234-238).This PR (
c9fe9292d8) merged into the samemain(run_115819.err): the stencil stop does not occur. The run stops about the same place in the log on a different refusal:(lines 240-242). That is the area of #7729, #8115 and #8121, not of this PR.
One run each, so this shows that the draw gets past the stencil check with the PR, not that the title is fixed. I did not look at the picture, and I did not run the PR's tests on this machine.
Not run: other GPUs for this title, the PR's tests, other titles, the console.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T10:21:04Z.
Thanks @xXPBSXx, that's the first Windows run of the title with this PR. It matches what I see on Linux. On
mainit aborts on the0x40 against test value 0xffstencil refusal. With this PR it gets past it and stops on the one-sample depth target under a multisampled rasterizer, which in Ghost of Tsushima is aPS_ITER_SAMPLEdepth-only pass.That next stop is what #7729 handles. On Linux, with #7726, this PR and #7729, the title draws past both of those draws and stops later, at an unrelated check (it's in #7729's description). I added your run to the Tested section.
AI-assisted: yes (Claude Code)