flowchart TD
D["draw"] --> Q{"pixel shader writes depth,
a depth buffer is bound,
a viewport range isn't [0, 1]?"}
Q -->|"no (most draws)"| P["plain pipeline
Metal clamps to [0, 1],
which is right here"]
Q -->|yes| V["clamp variant
made on first use"]
V --> B["per-draw buffer 30
words 24+: (min, max)
for each viewport"]
B --> F["fragment function ends with
depth = clamp(depth, min, max)
of its viewport index"]
P --> I["indirect command
buffers allowed"]
F --> N["no indirect command buffers:
ExecuteIndirect runs per record"]