feat(agc): replay stencil exports over triangle strips, with culling by the facing of each original triangle #24379
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24379"
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 Capmare on 2026-11-20T15:28:33Z.
What
On a device without
VK_EXT_shader_stencil_export(NVIDIA), the stencil replay draws each triangle once per reference value. Until now it accepted only triangle lists, so a triangle strip stopped the draw withstencil replay supports direct triangle lists without restart, mesh or tessellation.Marvel's Wolverine (PPSA03671) stops on this after #18530: the draw of shader
0x11d01d0900is a 4-vertex triangle strip with back-face culling. mrfelek saw the same stop on an RTX 3080 Ti in #18530.The replay now splits a strip into its triangles. Triangle
iuses verticesitoi + 2. A strip reverses the winding of every odd triangle, but the split triangle does not. So for each odd triangle the replay flips the front face withvkCmdSetFrontFace, and culling sees the facing of the original triangle.A strip is accepted only when:
The change:
Draw.cpp:StencilReplayStrip,FlippedFrontFace, and the strip split inrecordStencilReplay.Pipeline.cpp:VK_DYNAMIC_STATE_FRONT_FACE_EXTfor a culled replay strip.StencilReplay.cpp(test): a strip without culling, the four cull mode and front face pairs, and two strips that must stay refused.Tested
Rocky Linux 10.2, i7-14700K, RTX 4070 SUPER, NVIDIA 620.70.06, Release, on
main7fa48cd1c6. Tests were run asANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -R '^agc_driver_stencil'.mainagc_driver_stencil_*passingagc_driver_stencil_ref_exportreports skipped on both sides, because NVIDIA does not expose the extension. Onmainthe threeagc_driver_stencil_replay*tests stop on the new strip case withstencil replay supports direct triangle lists without restart, mesh or tessellation.New cases in
agc_driver_stencil_replay:a replayed culled triangle strip draws both of its triangles or none: pixel (2, 0) is 64, expected drawn, because the odd triangle is culled the other way.agc_driver_stencil_replay_no_gpl.The validation layer reports only
VUID-VkDeviceCreateInfo-pNext-pNextandVUID-VkShaderModuleCreateInfo-pCode-08737,08739and08741. They come from device creation and the float-controls probe at startup, before the first draw, and also occur onmain.Marvel's Wolverine: with this change on top of #18530, the game accepts the draw and logs
Stencil replay: a draw replays all 256 stencil reference values because its pixel shader's export is not bounded, recording 256 passes per triangle and instance. The run continued 90 s after the draw with no abort. I have not checked the image or the frame rate. The game reaches this draw only after the texture memory stall of #12575.tools/pr_overlap.pymerged the 87 PRs that share files with this branch intomainwith no conflict, and failed closed on 52 of them because they editDraw.cpporPipeline.cpp. #22697 also editsStencilReplay.cpp; it moves recording into command streams and does not change the replay topology.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T15:48:10Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed change is consistent with its stated scope at head
246e22fc9ac5784829738b8b2e9a0fe24e221e7a; the prepared diff and targeted source reads show no verified blocking defect.What I ran
No commands were run. I inspected the prepared diff and targeted source context; I did not run tests or build the change.
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
agc_driver_stencil_*test results, Vulkan validation output, game behavior, and performance were not independently verified.To get this to a good state
Nothing is required.