fix(shader): keep clip distances in the blocks between the barycentric tessellation stages #7487
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7487"
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-18T09:12:01Z.
What
#7330 fixed #7328: our generated tessellation stages declared
ClipDistanceinside theirgl_PerVertexinput block, while the vertex shader writes it as a separate built-in array, so the validation layer reported VUID-RuntimeSpirv-OpVariable-08746. Its fix passesClipDistanceas separate built-in arrays through both generated stages.That broke the route these stages exist for: Apple GPUs under MoltenVK, which have no geometry shaders. SPIRV-Cross, which MoltenVK uses to translate SPIR-V to Metal, cannot handle a separate
ClipDistancearray in a tessellation evaluation stage:As a result, every pipeline on the barycentric tessellation route fails with
vkCreateGraphicsPipelines: Vulkan result -3on macOS.This PR keeps #7330's fix where it applies and goes back to the block where it doesn't. VUID-08746 concerns the vertex-to-control interface, so:
{Position}plus the separateClipDistancearray, exactly what the vertex shader writes.ClipDistancegoes back inside the per-vertex block{Position, ClipDistance}, which SPIRV-Cross translates. That's the layout MoltenVK ran with in #7308.Without vertex clip distances, the stages are unchanged. The unit test now checks both: the separate array on the control stage's input, the block member on its output, and only the block member on the evaluation stage. The
shader.mdentry explains why.Tested
Apple M2, macOS 26.7.2, MoltenVK 1.4.2 (no
geometryShader), x86-64 under Rosetta. The test stack is currentmain(e5c2b3c32) plus mugurc's macOS port branches (ci/macos-series-2), with our open macOS PRs including #7426, and with #6535 so the titles below get past the depth-range check first. Release build,ANYPS5_NO_SHADER_CACHE=1. The changed files also compile on this Mac against plainmain, and the conventions check passes.agc_driver_pixel_barycentric_emulation: fails onmainat the first tessellation pipeline (MoltenVK's errors above). With this PR it passes the tessellation route: 932 perspective and 932 linear I/J pixels, raw vertex values, host interpolation, face culling, and flat inputs in first and last provoking vertex mode.VK_LAYER_KHRONOS_validation1.4.363) with this PR: no VUID-RuntimeSpirv-OpVariable-08746. The only message is the unrelatedVUID-VkImageCreateInfo-usage-00968, whichmainalso reports. So #7328 stays fixed.agc_driver_graphics_tests: passes, including the updated clip-interface checks.Titles (homebrew catalog, checksum-checked, relinked for macOS, 45 s each, same build with and without this PR):
mainvkCreateGraphicsPipelines: Vulkan result -3(evaluation stage)Without #6535, these titles stop earlier on current
mainatviewport depth outside [0, 1] requires VK_EXT_depth_range_unrestricted. CD Player and ProsperoStore also need #7426 (last provoking vertex), which is in the stack.Device limits of the M2 that stop titles here, not tested past them: no
geometryShader,shaderFloat64,VK_EXT_provoking_vertexorVK_EXT_depth_range_unrestricted.Not tested: Windows and Linux. There, devices with geometry shaders don't use this route; the validation result above covers the interface rule #7328 is about.
@MarcZX100 @Amoenus FYI, since this adjusts #7330 / #7328.
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)main)Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-18T09:12:44Z.
Overlap note: this PR and #7426 (last provoking vertex through the same stages) edit adjacent lines of
BarycentricGeometryShader.cppand the sameshader.mdentry, so whichever merges second needs a small merge. The combination, with #7426's flat-value line next to this PR's clip line, is what ran the titles above. I'll push that merge as soon as the first one lands.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T09:20:03Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mdImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T09:51:57Z.
The change looks right to me: separate array only at VS→TCS, block from the TCS output on. One gap:
agc_driver_pixel_barycentric_emulationdraws without clip distances, so its validation-layer run covers the unchanged unclipped path, and nothing creates a pipeline for the clipped tessellation route under the layer. Could the emulation test add a case whose vertex shader writes clip distances (e.g. one plane that cuts the triangle, checked in the readback), run through both routes? That would pin the MoltenVK translation and the VUID-08746 rule on the exact layout this PR changes, on lavapipe in CI as well.