Repository navigation
fix(shader): keep clip distances in the blocks between the barycentric tessellation stages - #7487
Conversation
…c tessellation stages boykopovar#7330 passes the vertex clip distances as separate ClipDistance arrays so the control stage's input matches the vertex shader's output. SPIRV-Cross, which MoltenVK uses, cannot translate a separate ClipDistance array in a tessellation evaluation stage, so on MoltenVK every pipeline of the barycentric tessellation route failed to compile. The control stage now reads the separate array the vertex shader writes and passes it on inside its per-vertex block, which the evaluation stage reads and writes.
|
Overlap note: this PR and #7426 (last provoking vertex through the same stages) edit adjacent lines of AI-assisted: yes |
|
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.
|
|
The change looks right to me: separate array only at VS→TCS, block from the TCS output on. One gap: |
Keeps the macOS port current with 50 upstream commits. - Upstream's boykopovar#7487 keeps the barycentric tessellation stages' clip distances in the blocks between the stages, which MoltenVK's SPIRV-Cross translates; it replaces the fork's MoltenVK-only switch (clipDistancesInPerVertexBlock), so the switch, its device query and its debt note are removed and every driver takes upstream's stages. - The provoking vertex debt entry takes upstream's geometry program and strip facts and keeps the fork's rule for devices without VK_EXT_provoking_vertex (boykopovar#6741). - The f16 interpolation debt entries keep the fork's 64-bit integer text and take upstream's clip distance description. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings the pull request up to the upstream commits that made it conflict, with the resolutions already tested on the fork's main: - upstream's boykopovar#7487 keeps the barycentric tessellation clip distances in the blocks between the stages, which MoltenVK translates; - SpirvTarget keeps fragmentBarycentricBuiltins beside upstream's robustBufferAccess2, and Time.cpp keeps both platforms' includes; - the force-TLS-destructor test stays off macOS beside upstream's new inet address test, and the new flexible memory tests run everywhere; - GuestMath's Bessel references come from libm's jn and yn on macOS, whose libc++ has no C++17 special math functions; - the provoking vertex and f16 interpolation debt entries keep both sides' facts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keeps the macOS port current with 50 upstream commits. - Upstream's boykopovar#7487 keeps the barycentric tessellation stages' clip distances in the blocks between the stages, which MoltenVK's SPIRV-Cross translates; it replaces the fork's MoltenVK-only switch (clipDistancesInPerVertexBlock), so the switch, its device query and its debt note are removed and every driver takes upstream's stages. - The provoking vertex debt entry takes upstream's geometry program and strip facts and keeps the fork's rule for devices without VK_EXT_provoking_vertex (boykopovar#6741). - The f16 interpolation debt entries keep the fork's 64-bit integer text and take upstream's clip distance description. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 feat(shader): emulate barycentrics through tessellation on devices without geometry shaders #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(e5c2b3c) 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 Barycentric tessellation helper mismatches vertex BuiltIn blocks (VUID 08746) #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)