fix(agc): draw compacted restart lists and restart-free strips through the barycentric patches #12706
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12706"
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 Gonic0 on 2026-10-29T03:57:05Z.
What
On a device with neither
fragmentShaderBarycentricnor geometry shaders (MoltenVK), a pixel shader that reads barycentrics is emulated through generated tessellation stages. Until now,Driver::drawandPipelinerefused every such draw with the primitive restart bit set, but two of those draws never restart on the host:VK_EXT_primitive_topology_list_restart. Since #12180, its indices are compacted on the CPU before the draw, so no restart index reaches the host.Both now take the patches. These still throw:
Pipelinedoes not know whether a draw is indexed, so it accepts any strip.Graphics::Draw, which does know, now refuses an indexed strip with restart next to its existing indirect-strip check.Driver::drawrefuses it too.The pipeline keeps
primitiveRestartEnableoff for patch lists. Vulkan requires that withoutprimitiveTopologyPatchListRestart(VUID-VkPipelineInputAssemblyStateCreateInfo-topology-06253).The
docs/dev/debt/shader.mdandlibSceAgcDriver.mdentries for this path now say what is accepted and what throws.check_conventions.pywarns about the length of the shader entry. That entry was already over 1000 characters onmain; this PR only rewrites two of its clauses.Overlap
requireinDriver::drawand adds a mesh block right after theprimitiveRestartEnableline inPipeline.cpp. Neither PR needs the other. Whichever lands second keeps both changes: themeshCompute ||prefix from #9387 in front of this PR's topology condition, and #9387's mesh block after the patch-awareprimitiveRestartEnableline.APS5_NO_LIST_RESTART. Once it lands, a CTest entry with that variable can run this PR's list cases on devices that have the extension (NVIDIA, AMD, lavapipe). For now they run only on devices without it. I did not add the same switch here, to avoid duplicating #9875.Tested
Apple M5 Pro, macOS 27.2, MoltenVK from Vulkan SDK 1.4.363 (no geometry shaders, no
primitiveTopologyListRestart), x86-64 Release under Rosetta 2,ANYPS5_NO_SHADER_CACHE=1.mainalone does not build libkernel or the driver on macOS, so I ran the tests in a tree with the open macOS port PRs. In that tree the changed functions match this branch exactly, andmainhas not touched the three source files between that tree's base andb433c40f2f.agc_driver_pixel_barycentric_emulation_testspasses 3 of 3 withVK_LAYER_KHRONOS_validationloaded and noVUID-messages. It now draws through the tessellation stages, with the restart bit set:2 R 0 1 2 0 1, where R is the restart index and only0 1 2is a complete triangle;It checks the I/J of every interior pixel as for the draws without restart: 864 and 864 pixels for the strip's two triangles, and 932 for each list. The list cases run only on a device without the extension. The strip cases run wherever tessellation does.
Negative controls (each fails, or reports, as expected):
Pipelinecheck fails at that check.Graphics::Drawcheck, the run fails with "an indexed triangle strip with primitive restart was not refused".!patchesinprimitiveRestartEnable, the run passes but the validation layer reports VUID-...-06253 4 times.agc_driver_list_restart_testspasses.agc_driver_graphics_testspassed 7 of 9 runs; both failures were "two ranges under a budget for two were not imported" from the host-import budget check inBdaResources.cpp. This PR does not touch that code, and the test then passed 5 runs in a row.agc_driver_mesh_barycentric_emulation_testsskips because there is noVK_EXT_mesh_shader.Not covered by a test: the changed
requireinDriver::draw. The tests callVulkanDevice::Drawdirectly, and no execution test sends a barycentric draw throughDriver::draw.ASTRO BOT (PPSA21564 01.007.000): in a local tree that also emulates mesh shaders, the title aborted about 10 s in, while loading the UI, at this
requirewithout this change. With it, it ran for 300 s. Which of the three cases its draws use was not logged.Not tested on Linux or Windows. Devices with geometry shaders do not take the patches.
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