Repository navigation
ShaderCompiler: mark the Metal vertex position invariant - #2070
bkaradzic-microsoft merged 2 commits into
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
1 open issue
What changed in this PR
Marks the Metal vertex position output as invariant to prevent cross-pipeline z-fighting caused by Metal fast-math producing slightly different position results across passes.
Changes:
- Detects vertex stage and decorates the
BuiltInPositionoutput withInvariant. - Forces MSL version 2.1 to ensure
[[position, invariant]]emission.
| File | Description |
|---|---|
| Plugins/ShaderCompiler/Source/ShaderCompilerMetal.cpp | Adds invariant decoration for the Metal vertex position output and bumps MSL version to 2.1 for vertex shaders. |
Review effort: Lite
8c25775 to
7fb2729
Compare
|
CI note: run 44208782078 (attempt 1) failed only in Android_Ubuntu_JSC / build. This is infrastructure, not this PR. In "Build Playground JavaScriptCore", Gradle couldn't resolve its classpath because Maven Central returned HTTP 429 Too Many Requests for
Total wall-clock: 1h12m38s (00:33:25Z → 01:46:03Z). The critical path was queue time: the Vulkan and iOSTests runners started about an hour late.
|
Babylon.js draws the same geometry with different programs across passes (depth prepass, geometry renderer, main pass) and depth tests them against each other. Metal's fast-math may compile identical position math differently per pipeline, causing z-fighting. Decorate the position output Invariant ([[position, invariant]], MSL 2.1). Fixes 'FrameGraph nrge csm shadows with autoCalcDepthBounds'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5a2ca4f4-15a2-4ad1-8a64-9dad061e773d
Invalidate caches produced before Metal vertex positions were marked invariant, and verify the serialized cache header version. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8bd57bfd-bbb3-4e86-8a17-9a44fb995d0f
7fb2729 to
b8a20d3
Compare

Summary
Babylon.js draws the same geometry with different programs across passes (depth prepass, geometry renderer, main pass) and depth-tests them against each other. Metal's fast-math can compile identical position math differently in each pipeline, which causes z-fighting.
The Metal vertex position output is now marked invariant (
[[position, invariant]], MSL 2.1). This fixes FrameGraph nrge csm shadows with autoCalcDepthBounds.Verification
Ran the Playground validation suite on macOS with Metal and JavaScriptCore, with the Metal API validation layer enabled. The full suite passes with no regressions.