Repository navigation
fix(agc): draw a stencil replacement against a known stencil value as an inversion - #7725
Conversation
… an inversion DB_STENCILREFMASK holds a test value and a separate operation value, and REPLACE_OP, ONES and REPLACE_TEST write a value that can differ from the test value on bits the compare reads. Vulkan uses one reference for both, so such a face threw. Ghost of Tsushima (PPSA02225) stops on one at its splash screen (test value 0xff, operation value 0x40, both masks 0xff). Some compares fix the stencil value wherever an operation runs: EQUAL on pass and depth fail, NOTEQUAL on fail, and LEQUAL, GEQUAL, LESS or GREATER against the largest or smallest masked value. There, if every written bit is compared, the written bits hold the test value, so the replacement is an INVERT whose write mask holds only the bits that differ from the value written. The operations of a face share its write mask, so a face whose other operations can't be drawn the same way still throws. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.
|
jotitadev
left a comment
There was a problem hiding this comment.
Apple GPU / MoltenVK run. agc_driver_stencil_known_replace runs on Metal (no skip) and passes. It fails without the fix with the refusal from the description. The full ^agc suite is unchanged.
Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Head c9fe929, 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 main a373e85 + 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 plain main (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 (branch jotitadev:fix/agc-tests-vulkan-loader-macos). Base on that tree: 40 ^agc failures 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.- With this PR's hunks of
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. - Full
^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.
|
Windows data point for
Not tested: a title run, other GPUs, Linux. AI-assisted (Claude Code). |
|
@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 AI-assisted: yes (Claude Code) |
|
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
|
|
Intel and AMD Windows data: with this PR's test changes, Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
AI-assisted: yes (Claude Code) |
|
@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 AI-assisted: yes (Claude Code) |
|
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. |
|
Thanks @oneandonlydean. It merges cleanly with current AI-assisted: yes (Claude Code) |
|
Title data point for this PR (data only). Title: PPSA02225, 300 s per run through the runner, Baseline, then This PR ( (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). |
|
Thanks @xXPBSXx, that's the first Windows run of the title with this PR. It matches what I see on Linux. On 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) |
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
main8a526d4.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.main676d423 with fix(libScePlayGo): list chunks 0 to 999 when only a scenario file is present #7726 (MinGW-w64, WinLibs):agc_driver_stencil_known_replacepasses 3 of 3, and fails 3 of 3 withmain'sState.cpp.main7f596df. 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 fix(agc): key shader modules by the pipeline library mode #6436 targets).main6b8228b. 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.main50efb5c. 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 fix(agc): draw a PS_ITER_SAMPLE program once per pixel into a one-sample depth target #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_replaceonmain8a526d4 and 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.main8a526d4 or 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