Under LoweringInputs::depth_range_fold, a vertex (or post-tessellation
vertex) function that stores its position does three things at each
return:
- it stores the position's z as znear * w + (zfar - znear) * z, reading
[znear, zfar - znear] from PushField::DepthRangeFold;
- it stores z and w - z, of the z it returned, as two clip distances
after its own;
- it records PrecisionNote::DeviceArithmetic.
Drawn with the viewport's depths [0, 1] and depth clamping enabled, this
maps a viewport depth range past [0, 1] as Metal maps it (the M3 Max, jobs
m3-max-85541 and m3-max-85617): [[position]].z reads znear + z / w *
(zfar - znear) unclamped; the depth stored and tested is that, clamped to
[0, 1] by the clamp; and the clip distances keep Metal's 0 <= z <= w where
the clamp leaves z unclipped.
Planning:
- The function's own ClipDistance array is declared two longer, with its
own elements stored as before.
- A function with none declares ClipDistance of 2 (shaderClipDistance).
- Under the fold the declared count must fit maxClipDistances and
maxCombinedClipAndCullDistances, else Unsupported names
Feature::ClipDistance and the limit.
- The usual path's check (maxClipDistances alone) is unchanged.
- A function that stores no position, and any other stage, compiles as
without it.
docs/API.md's DeviceArithmetic entry says the fold records it on every
such compile and why. SEMANTICS_VERSION 2377 and ARTIFACT_FORMAT_VERSION
611 (a new push field and fact). runtime-sources.sha256
takes the translator's new sources, including the commit before's.
Verified: see the twin's READY job lines (the red tests at the commit
before fail, pass here).