fix(agc): draw a last provoking vertex through the barycentric tessellation stages without VK_EXT_provoking_vertex #21938
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21938"
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 kurexw on 2026-11-16T22:29:58Z.
What
On a device without
VK_EXT_provoking_vertexprovokingVertexLast(MoltenVK on Apple GPUs), a draw in last-provoking-vertex mode whose pixel shader shows the provoking vertex fails atValidateProvokingVertex(Graphics/src/Pipeline.cpp) withlast provoking vertex requires VK_EXT_provoking_vertex with provokingVertexLast enabled. The barycentric tessellation stages already give each corner the last vertex's flat values (#7426, #8083), but a draw used them only when its pixel shader had been recompiled with emulated barycentrics, which happens only on devices without native fragment barycentrics. The Apple M4 has native barycentrics, so these draws took the native path and threw.This PR sends such draws through the existing tessellation stages:
LastVertexPatches(Pipeline.cpp) decides it. The device lacksprovokingVertexLastand has tessellation shaders, the draw is in last mode on the vertex path (not a rect list, mesh or tessellation draw), and its pixel shader shows the provoking vertex (the same testValidateProvokingVertexalready applies, moved to file scope). Its vertex shader writes noLayerorViewportIndex, and the topology is one the stages draw: a triangle list (primitive restart only withoutVK_EXT_primitive_topology_list_restart) or a triangle strip (primitive restart only in a non-indexed draw).Execution/src/Driver/Draw/Draw.cpp) then recompiles the pixel shader with a newGraphicsCompileContext::emulateBarycentricsflag and builds the tessellation stages with the last vertex, as it already does for emulated barycentrics. Re-materialised stages of an indirect draw keep the flag.Recompiler.cpp) translates a pixel shader with that flag the way it already does when lowering to host interpolation fails.Note for merging: #20153 also moves request serialization to version 63. Whichever merges second needs version 64.
Tested
macOS 27.2 on an Apple M4 (MoltenVK 1.4.2 from the LunarG Vulkan SDK 1.4.363.1, x86-64 build under Rosetta). This is the only GPU I tested. I could not run RADV, NVIDIA or Windows here. Devices with
provokingVertexLastdon't reach the new path, whichLastVertexPatchTestschecks on the CPU.New tests
agc_driver_vertex_provoking_vertex(new) submits real DCB draws through the driver: a guest vertex program with a flatv_interp_movP0 pixel shader, as a triangle list and a triangle strip, alternating first, last and first mode. It checks that each triangle takes its first or its last vertex's color.3b17977ba6fails it with the throw above.Draw.cpprouting disabled, it also fails with that message.agc_driver_provoking_vertex: on a device withoutprovokingVertexLastand with tessellation, it now also draws the guest P0 shader through the emulated barycentric stages, as a list and a strip, first/last/first, and checks the last-vertex colors.ANYPS5_REQUIRE_VULKAN; this branch passes it.agc_driver_unobserved_provoking_vertexgainsLastVertexPatchTests, which covers every condition of the decision.agc_shader_memorygainsverifyEmulatedBarycentricRequests. It checks that:request_serializerandagc_shader_memorywere updated for version 63.GPU tests, main vs. this branch
3b17977ba6; this branch was first tested on that commit, then rebased onto459f4f8c22and tested again.ctest --test-dir build -R '^agc_driver_.*(barycentric|tessellation|provoking|patch_vertex|interpolation|rect_list).*' -V, three runs per side.ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer.Insert instance layer "VK_LAYER_KHRONOS_validation"(layer 1.4.363). None loggedwas not found but was requested by env var VK_INSTANCE_LAYERS.agc_driver_provoking_vertexagc_driver_vertex_provoking_vertexagc_driver_tessellationVUID-linesFull
ctest -j8guest_audio_propagation,guest_main_stack_moveandguest_system_service_open_url. None of them links the AGC driver or the recompiler. Run alone, each passes on some runs and fails on others on this branch.guest_pthread_mutex_contentionandwrite_watch_backing_shared.Not tested
DRAW_INDEX_AUTOdraws without primitive restart. These run only in the CPU tests (LastVertexPatchTests), not on a GPU:VK_EXT_primitive_topology_list_restart, or a non-indexed strip;Draw.cpp, the patched-program loop).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 MarcZX10 on 2026-11-17T00:35:05Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected implementation supports the described last-vertex fallback; a complete review and local checks were not possible because several changed files were not read and no tests were run.
What I ran
Reviewed head
942ec64f2f798b0a8adbc5990c6cb9c6c3590685using the prepared review bundle andrepo_read.pyreader. No test commands were run. I readdescription.md,commits.md,manifest.json, and the relevant portions ofdiff.patch; repository code read includedDraw.cpp,DrawCapture.cpp,Pipeline.hpp,Pipeline.cpp,CacheKey.hpp,RequestSerializer.cpp,Recompiler.cpp, andtests/execution/VertexProvokingVertex.cpp.Results
Findings
Blocking
None in the inspected code.
Non-blocking
Not verified
I did not read the changed files
tests/Graphics.cppandtests/ShaderMemory.cpp, which were excluded from the review folder as too large, or the remaining changed files and hunks not listed above. I did not run tests or verify the author-reported GPU results. The PR description says indexed draws, primitive-restart cases, and indirect draw re-materialization were not GPU-tested.To get this to a good state
Nothing is required. Optional: coordinate the serialization version with the other PR before merging.