fix(agc): draw a last provoking vertex that no pixel input sees without the extension #6741
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6741"
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 DavidSamir on 2026-10-16T09:03:13Z.
What
A draw with
PA_SU_SC_MODE_CNTL.PROVOKING_VTX_LASTthrows on a device withoutVK_EXT_provoking_vertex, whatever its pixel shader reads. MoltenVK 1.4.2 on Apple M2 doesn't expose the extension (vulkaninfolists neither it norprovokingVertexLast). Once #6535 clears its viewport-depth stop, ProsperoLichess (PPSA99009) stops here on macOS:A temporary log line before the refusal showed the draw: a triangle fan on the vertex path whose pixel shader has no inputs (
fragmentParametersempty). The provoking vertex selects the values of flat-shaded inputs and the order of per-vertex values. The driver records no transform feedback, so nothing else depends on it.Without the extension, last mode now throws only when a pixel shader could see the provoking vertex:
FlatorPerVertexKHRdecoration in its SPIR-V, on a variable or a block member. This also catches a shader built without the recompiler's metadata, as inagc_driver_provoking_vertex. It skips a built-in the pixel stage generates itself:FragCoord,PointCoord,FrontFacing,SampleId,SamplePosition,SampleMask,HelperInvocation,SubgroupSizeandSubgroupLocalInvocationId. VUID-StandaloneSpirv-Flat-04744 requiresFlaton every integer pixel input, built-ins included, but no vertex supplies those.Layer,ViewportIndex,PrimitiveIdand every other built-in still count;LayerorViewportIndexbuilt-in output (variable or block member). Vulkan takes the layer and viewport from the provoking vertex whether or not the pixel shader reads anything. One also decoratedPerPrimitiveEXT, the mesh path's per-primitive layer, is skipped, because it belongs to the primitive. The recompiler declares these outputs only when the guest exports them (PA_CL_VS_OUT_CNTL), so other vertex shaders are unaffected. A stage whose module can't be read also counts.Otherwise
ValidateProvokingVertexaccepts the draw. ThePipelineconstructor already leaves out the provoking vertex state on such a device, so it draws in first-vertex mode, as it already did for a draw without a pixel shader. Devices with the extension are unchanged. ThePROVOKING_VTX_LASTdebt entry says when last mode throws.Commits:
Flatdecoration is on aBuiltIn SubgroupLocalInvocationIdinput.main.LayerorViewportIndexobserves the provoking vertex.Tested
macOS 26.7.1, Apple M2, MoltenVK 1.4.2 from the LunarG Vulkan SDK 1.4.363, AppleClang 21.0.0, x86-64 under Rosetta, Release.
maindoesn't build the system libraries on macOS by itself, so the tests ran in a local tree:maince991f1ecwith #4627, #4630, #6124, the four macOS relinker PRs and mugurc's macOS port branches merged, and #6535 applied. This branch'sPipeline.cppis identical to the one tested.agc_driver_unobserved_provoking_vertexpasses 5 runs of 5. It covers points, lines, line strips, triangle lists, strips and fans on a device without the extension:It also reruns
ProvokingVertexTests.With
main'sPipeline.cppthe new test fails. It also fails for each of 12 deliberately wrong versions of the fix, each dropping one of the conditions above or reading every stage's inputs.agc_driver_provoking_vertex(GPU), run with the SDK's loader on the path (as plainctestit skips: nolibvulkan.1.dylibfound), passes 3 runs of 3 on MoltenVK. It checks first-vertex rendering and that its flat GLSL shader is still refused in last mode. An earlier version of this branch read only the recompiler's metadata, drew that shader and failed there, which is why the SPIR-V check is in; the two SPIR-V variants among the 12 above fail it too.All 597
agc_tests in this tree, with this branch and withmain'sPipeline.cpp:agc_write_trackingandagc_shared_writefail with both;agc_driver_graphicsand the new test fail only withmain's;Cloud Play (PPSA99600, 1.0.0) and PS5 OpenGL Showcase (PPSA99005, 1.0.2), both with catalog sha256 checked, 40 s runs:
OpDecorate %10 Flaton%10, aBuiltIn SubgroupLocalInvocationId32-bit unsigned input. Cloud Play's draw is a triangle list with no recorded inputs; Showcase's is a triangle fan with one smooth input;Barycentric geometry SPIR-V: geometry shaders are unavailable(#6222's area). Showcase stops on64-bit float instructions need the Float64 capability, whose only 64-bit operation here isFPInterpolateF16.The built-in cases fail for each of 4 more wrong versions: no built-in skipped, every built-in skipped, block members keyed as variables, and a built-in on one variable excusing another.
ProsperoLichess (PPSA99009, catalog release 01.000.000), 60 s runs:
viewport depth outside [0, 1] requires VK_EXT_depth_range_unrestricted. A log line showed that draw has depth −1..1 with a depth target bound, which #6535 leaves alone and #4650 addresses. #4650 conflicts withmain, so I couldn't add it to this tree.tools/check_conventions.py --base origin/mainandgit diff --checkpass.After review (commits 7 to 11). Windows 11 Pro 26300, NVIDIA RTX 3070 (driver 610.60), WinLibs GCC 15.2.0, Release; and WSL Ubuntu 24.04 with Mesa lavapipe, on
main02fb1ce532merged in.New cases in
agc_driver_unobserved_provoking_vertex, for vertex, tessellation-evaluation, geometry and mesh stages beside a smooth pixel shader on a device without the extension:BuiltIn LayerorBuiltIn ViewportIndexon a variable or block member, including one wherePerPrimitiveEXTis on a different member: these throw. With the extension they pass;PerPrimitiveEXT, in either order: these pass;PositionandPointSizeonly: these pass;The existing case, vertex-stage metadata and
Flatbeside a smooth pixel shader, still passes.With commit 8 (no fix) and the new cases, the test fails with
expected graphics rejection: last provoking vertex requires VK_EXT_provoking_vertex with provokingVertexLast enabled. With commit 9 it passes.Each of commits 8, 9 and 10 builds, and
agc_driver_unobserved_provoking_vertex,agc_driver_provoking_vertex,agc_driver_mesh_provoking_layerandagc_driver_mesh_provoking_vertexpass on the RTX 3070.Validation (as AGENTS.md asks for AGC changes):
ctest -R provoking -Vonmainand on this head, same machine, lavapipe ICD, Khronos validation layer 1.3.275, withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.was not found but was requested by env var VK_INSTANCE_LAYERS.VUID-VkDeviceCreateInfo-pNext-pNext, the 1.3.275 layer not knowing a newer device-create struct. Nothing new from this change.Commits 1 to 6 were not tested on Windows, Linux or devices with the extension. Their path is unchanged, since the new early return needs
provokingVertexLastto be false. Commits 7 to 11 were tested on Windows and Linux, as below.Limits of this Mac's GPU.
vulkaninfoon Apple M2 with MoltenVK 1.4.2 reports no geometry shaders, noshaderFloat64, noVK_EXT_depth_range_unrestrictedand noVK_EXT_provoking_vertex. AnyPS5 turns MoltenVK'sVK_KHR_fragment_shader_barycentricoff (5333a2053), so barycentric pixel shaders need the geometry-shader fallback. These are limits of the device. Apart from the provoking-vertex case below, this PR doesn't remove them. A title named here as stopping on one of them is not tested past that stop:Barycentric geometry SPIR-V: geometry shaders are unavailable: no geometry shaders; #6222 has a route around it.viewport depth outside [0, 1] requires VK_EXT_depth_range_unrestricted: #4650 works around it.last provoking vertex requires VK_EXT_provoking_vertex: this PR removes it only for draws whose pixel shader can't observe the provoking vertex. A draw that does observe it still stops.Overlap: #6451 and #6683 register tests next to
agc_driver_covered_centroid_stateinCMakeLists.txt, as this does; whichever lands second rebases. The overlap check couldn't compare the pull requests that conflict withmain. Of those, #1896, #5925 and #6222 editPipeline.cpp, and none of them changesValidateProvokingVertexor the provoking vertex state. I found no open pull request that changes this check.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 johnmaia on 2026-10-16T13:59:32Z.
Windows run, since Windows is untested. Windows 11, WinLibs GCC 15.2.0 r7 (MinGW), Release,
BUILD_TESTING=ON,ctest -j4 --timeout 300. Head3e5785b51merged intomain82ddae75b, plus #6452 so the MinGW test build works. Both GPUs reportVK_EXT_provoking_vertex, so this covers the "devices with the extension" case, not the new path without it.agc_driver_provoking_vertex,agc_driver_unobserved_provoking_vertex,agc_driver_covered_centroid_state,agc_driver_graphics,agc_shared_writeandagc_write_trackingpass on an RTX 4080 (NVIDIA 617.42) and an Intel UHD 770 (101.6129).guest_kqueue, an elevated-session artefact that #6599/#6629/#6173 address.guest_kqueue:agc_driver_bindless_images,agc_driver_image_sint8,agc_driver_image_table,agc_driver_image_table_cache_boundsandagc_driver_image_table_reusefail the same way onmain82ddae75b(+#6452) on this GPU, so they're pre-existing.guest_shader_linktimed out once here and passed onmainonce. It hangs intermittently on this GPU (#6503), so one run doesn't attribute it either way.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-16T14:19:45Z.
Follow-up on the
guest_shader_linktimeout above: on the same UHD 770 it times out 4 of 15 runs onmain82ddae75b+ #6452 (measured on #6503), so it's an existing Intel flake, not this PR.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T08:08:02Z.
Review: CHANGES_REQUESTED
Thanks, the approach and the evidence are good. One gap before this can merge:
Pipeline.cpp:113-157: only the fragment stage is inspected, but the provoking vertex also selects which vertex suppliesLayerandViewportIndex(Vulkan spec, primitive layer/viewport selection), and that happens whether or not the pixel shader reads anything. The recompiler emits both as vertex-stage outputs (StageOutputKind::Layer/ViewportIndex,SpirvEmitterHelpers.cpp:396-399). A vertex shader writing a per-vertexgl_Layerorgl_ViewportIndexwith a pixel shader without inputs now passesValidateProvokingVertexand renders into the first vertex's layer/viewport instead of the last's, silently.LayerorViewportIndexasBuiltInoutputs (a variable or block member) as observing the provoking vertex, so last mode still throws there without the extension. Add cases toUnobservedProvokingVertexTests(vertex stage withBuiltIn Layer/ViewportIndex, and your existing "vertex-stage metadata beside a smooth pixel shader" case must still pass without those built-ins), and mention it in the debt entry.Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-19T19:10:17Z.
Title evidence for #6741 and #7426 together, from a macOS catalog sweep: Apple M2, MoltenVK 1.4.x (no
VK_EXT_provoking_vertex, no geometry shaders), Rosetta 2, onmain00d7e611efwith @mugurc'sci/macos-series-2and #7937 (so libkernel builds on macOS). 30 s per title, same build apart from the two PRs.On that base, 12 catalog titles stop at
AGC graphics: last provoking vertex requires VK_EXT_provoking_vertex with provokingVertexLast enabled. Results:So on a device without the extension these titles need both changes: #6741 for their last-vertex draws whose pixel shader cannot see which vertex provokes, and #7426 for the ones whose pixel shader reads emulated barycentrics through the generated tessellation stages. Either alone still stops at the same check. Nothing past 30 s is tested; MoltenVK-specific limits (#6235, #6528) are not in the way of these 11.
The two PRs touch the same function (
ValidateProvokingVertex); merged together, the #7426 block for barycentric patches goes first and #6741's check of whether a pixel input reads the provoking vertex follows, with no other change.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-19T21:11:29Z.
Validation-layer comparison, as AGENTS.md now asks for AGC changes. Apple M2, MoltenVK 1.4.x (Vulkan SDK 1.4.363), macOS 26, x86-64 under Rosetta 2, same machine and build directory, on
mainwith @mugurc'sci/macos-series-2and #7937 (needed for libkernel on macOS). Each test run withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation; the loader reports loadinglibVkLayer_khronos_validation.dylib, and no log containswas not found but was requested by env var VK_INSTANCE_LAYERS.agc_driver_pixel_barycentric_emulationVUID-VUID-agc_driver_graphicsVUID-VUID-agc_driver_provoking_vertexrequired provoking vertex rendering coverage is unavailable: provokingVertexLast is not supportedVK_EXT_provoking_vertex; withoutANYPS5_REQUIRE_VULKANit skips)No new validation errors with the two changes. The title results for the pair are in the comment above (11 catalog titles run past the provoking-vertex stop with both).
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-19T23:37:41Z.
No-regression run on a GPU with
VK_EXT_provoking_vertex:main567c5fd630againstmainplus head23e22f1d81. Windows 11 Pro 26300, NVIDIA RTX 3070 (driver 610.60), WinLibs GCC 15.2.0, Release. Catalog releases with sha256 checked, 60 s each.The nine titles listed for the Mac all run the full 60 s on both builds: SymphonyStation5 (PPSA17641), VITA5 (PPSA39410), Signal Companion (PPSA69426), PokeMMO (PPSA98001), ProsperoLight (PPSA99002), PS5LM (PPSA99575), Cloud Play (PPSA99600), PShare (PPSA99773) and Pulse (PPSA99993). None stops early.
This device takes the extension's native path, so this run checks only that nothing regresses. The emulated path is covered by the Mac runs in the description.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-20T12:19:19Z.
@adriadam10 thanks, you're right. Addressed in 507e6b5737..3684f25e85:
ValidateProvokingVertexnow also treats a non-fragment stage whose SPIR-V decorates aBuiltIn LayerorBuiltIn ViewportIndexoutput, on a variable or a block member, as observing the provoking vertex. Last mode still throws there without the extension. Two details:PerPrimitiveEXTis skipped. That is the mesh path's per-primitive layer, which the emitter writes per primitive from its last index, so Vulkan's provoking vertex doesn't select it.The recompiler declares those outputs only when the guest exports them through
PA_CL_VS_OUT_CNTL, so plain vertex shaders keep drawing.UnobservedProvokingVertexTestsgains cases for vertex, tessellation-evaluation, geometry and mesh stages:LayerandViewportIndex, each as a variable and as a block member: refused without the extension, accepted with it;Position/PointSizeonly: accepted;The existing "vertex-stage metadata beside a smooth pixel shader" case still passes.
The new cases fail on the commit before the fix. The debt entry names the built-ins.
Validation-layer comparison with
mainand per-commit results are in the PR body.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-20T12:34:00Z.
Apple M2 check of head
3684f25e85(same account as the author, run from the Mac): macOS 26, MoltenVK from Vulkan SDK 1.4.363.0, x86-64 build under Rosetta, tree = main35fa2bdd82+ the macOS port series + this head + #7426. 40 s per title, relinked with--macos --to-rosetta.The 11 titles that need the two provoking-vertex PRs still run the full 40 s with no
driver failure, noterminatingand no new throw about Layer or ViewportIndex: PPSA17641, PPSA39410, PPSA69426, PPSA98001, PPSA99002, PPSA99051, PPSA99575, PPSA99581, PPSA99600, PPSA99773, PPSA99993. PPSA47770 (Afterglow) exits after 14 s at its own check, as before this change.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T17:14:05Z.
@adriadam10 could you take another look when you have a moment? On 3684f25e85 your Layer/ViewportIndex point looks addressed to us: the non-fragment stages that decorate
BuiltIn LayerorViewportIndex(as a variable or a block member) now count,PerPrimitiveoutputs are skipped, and an unrecognised case fails closed. The CPU tests cover vertex, tessellation evaluation, geometry and mesh. If it looks right to you too, an updated review would clear your change request.