AGC: pixel shaders that export a stencil reference value abort on devices without VK_EXT_shader_stencil_export (NVIDIA; Demon's Souls, 1080p renderconfig) #4276
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 fisherjoey on 2026-10-12T03:49:15Z.
Demon's Souls (PPSA01341 v1.07, US) aborts during the tutorial level load with:
Register 0x203 is DB_SHADER_CONTROL. 0x52 sets three bits:
ShaderControlMaskinGraphics/src/State.cppalready accepts bits 4 to 6. Bit 1 is the only one it rejects, so this is a draw whose pixel shader writes the stencil reference. There is no stencil export path today: nothing in the driver or the recompiler emitsFragStencilRefEXTor enablesVK_EXT_shader_stencil_export.How to reach it: the title only takes this path here when it renders at 1920x1080. Following ponhei9502's note in #1283, I set
+r_Wants4K = WantsPerfin copies of the fiveapp0/misc/renderconfig_ps5_*.txtfiles (a local copy ofapp0/misc, the dump untouched) and booted through the debug start menu into the tutorial. The abort came at about 1209 s, during level loading, after 157 presented frames. With the default renderconfig (4K) the same build gets to a different stop first (a depth plane sampled as a texture), so I haven't seen this draw at 4K yet.I don't have the pixel shader address. The check fails while the draw's state is decoded, and the message doesn't name the program. I can add that and report back if it helps.
Setup: Linux, RTX 5070 Ti, NVIDIA 595.91.07.
main7a84b222with #4049, #758, #4241 and #4265 merged locally (#4265 is the fiber stack fix that gets this far),ANYPS5_ENABLE_SPIRV_TOOLS=ON,APS5_SPIRV_OPT=none.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-13T20:16:39Z.
Status on
main: the stop in this issue's title is gone on devices withVK_EXT_shader_stencil_export. #4355 (merged 2026-10-12,22d662eda) emitsFragStencilRefEXTfor pixel shaders withDB_SHADER_CONTROL.STENCIL_TEST_VAL_EXPORT_ENABLE. It says "Refs #4276", so this issue was not closed with it.On AMD the new test passes:
agc_driver_stencil_ref_exportpasses 5 of 5 (not skipped) atmaina0f5916a2. Setup: Windows 11 (26300), Radeon 860M (RDNA 3.5, driver 32.0.13058.8001, which advertisesVK_EXT_shader_stencil_export), WinLibs GCC 15.2.0, Release.What is still open is NVIDIA, whose driver lacks the extension. There the draw stops with
a pixel shader that exports the stencil reference needs VK_EXT_shader_stencil_export, which the device lacks. #5304 removes that stop for draws without a stencil test, but Sam-mon7's Demon's Souls draw on the same PR has the stencil test on. It may be clearer to retitle this issue to that NVIDIA case, or to close it in favour of a new one.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-13T23:01:33Z.
@LeandroLP23 thanks, retitled to the NVIDIA case. #4355 covers devices with
VK_EXT_shader_stencil_export; the RTX 5070 Ti here doesn't advertise it, so Demon's Souls still stops on this draw. #5304 and #5466 both target that remaining case; I'll test them on Linux NVIDIA with Demon's Souls and post the results here.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-14T01:58:11Z.
Results for #5304 and #5466 on Demon's Souls, as promised above. Neither gets the title past this stop on NVIDIA yet.
Setup: Linux, RTX 5070 Ti, NVIDIA 595.91 (no
VK_EXT_shader_stencil_export). Demon's Souls PPSA01341 v1.07, 1080p renderconfig, debug direct boot. Base ismain7a0c838caplus a local merge of #758, which the title needs to reach the level load.ANYPS5_ENABLE_SPIRV_TOOLS=OFF.mainonlyGetImageResource dword 0(#758's case)main+ #758a pixel shader that exports the stencil reference needs VK_EXT_shader_stencil_export, shader 0x24ab8e200DB_DEPTH_CONTROL0x007007e7 / 0x007007c7), so its rule doesn't applyDB_STENCIL_CONTROL0x00030030, ZPASS REPLACE on both faces,DB_STENCILREFMASK0x018080ff, write mask 0x80)stencil reference export emulation requires a replay-safe pixel shader with late tests, shader 0x24abb6d00The refused addresses run the same 788-word pixel shader (0x24abb6d00 and 0x24ab57200 are byte-identical). The draws differ only in stencil state: one doesn't consume the reference, so the widening drops its export, and the other writes it. Why #5466 refuses that shader is on #5466.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-17T08:59:11Z.
Another NVIDIA case, from Onimusha: Way of the Sword (PPSA27836) during its first scene load. RTX 5070 (617.42), Windows 11,
main17cfb1f4c+ #6762 (STENCIL_OP_VAL_EXPORTwithREPLACE_OP, value in MRTZ.Y bits 8-15):The draw:
DB_SHADER_CONTROL0x45 (Z export, operation-value export, kill),DB_DEPTH_CONTROL0x7007e7,DB_STENCIL_CONTROL0x40040 (REPLACEon depth pass, both faces),DB_STENCILREFMASKwrite mask 0xff.#5466's replay can't take this shader even with a larger value limit, for two reasons:
s4 & 0xff) or comes from a buffer read.exp mrtz.So replaying per value would run those side effects more than once.
An idea for draws like this one, where the only stencil op that uses the reference is
REPLACEon depth pass and the stencil test isALWAYS. I haven't tried it:FragStencilRef. WithALWAYS, a fragment that passes the depth test is exactly one whose stencil would be replaced, so the last fragment written per pixel is the same one the console keeps.REPLACEwith reference1 << band write mask1 << b, after one pass that clears the masked bits where the flag is set.Before anyone writes it: does this match how others see the problem? I'd like to hear from @fdfawef324 (#5466) whether this kind of second path belongs next to the replay or should replace part of it.
AI-assisted: yes (Claude Code); the run and the decoding are mine.
Imported from boykopovar/AnyPS5. Originally posted by juanpimg on 2026-10-20T18:24:04Z.
While working on the recorder test registrations I ran every flag-scoped mode of the AGC
driver against two devices, and one of them found a case of this. It is not a new symptom,
but it locates the failure and shows why it is invisible today.
Reproduction
The test is
agc_driver_stencil_ref_export_unused_tests, incore/libs/prx/libSceAgcDriver/tests/execution/StencilRefExportUnused.cpp. It takes a--caseargument, and six of its eight cases fail on every device:--casekeepinvertcompare,back-compare,replace,fail-replace,depth-fail-replace,partial-replaceThe failure message is the test's own:
The two devices differ in the extension, and the test skips on one of them
VK_EXT_shader_stencil_exportis present on the Intel device and absent on the NVIDIA one.The test's
keepandinvertcases pass on both, and the six dependent cases fail on both.The reason the Intel run skips rather than fails is in the test's own expectation: it looks
for the refusal
and on the Intel device the draw is admitted for a different reason, so the expectation does
not hold there either.
Where the refusal and the emulation live
The message the test expects is thrown in
core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp:380, and it isreached only on the native path, that is, when
state.stencilRefVariable != 0andstate.stencilReplayis false.state.stencilReplayis set incore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp:425, in thebranch that runs when the device does not have the capability, and that branch emulates the
stencil reference export instead of refusing it.
So on a device without
VK_EXT_shader_stencil_exportthe driver emulates the export, andthe refusal the test expects no longer happens. The emulation has three preconditions of its
own, each with its own message, and none of them fires for these six cases: the draw is
admitted silently.
Whether the emulation is right for a dependent stencil reference, or whether the draw has to
be refused as the test expects, is a question about the console's own behaviour, which I
cannot measure. I did not touch the driver.
Why this is invisible
agc_driver_stencil_ref_export_unused_testsis built, because the AGC execution tests areglobbed from
tests/execution/*.cpp, but no ctest entry runs it, and no ctest entry passesit a
--caseeither. The six cases are therefore never executed by CI, and a local run onlyreaches them with the argument by hand.
The registrations I am proposing in #8445 add the two cases that pass,
keepandinvert,and leave the six that fail out, so that the coverage grows without a red job.