Stencil output: a device without VK_EXT_shader_stencil_export draws it by bits, the owner's tenth form

A fragment function's [[stencil]] output is the reference of both faces' stencil test for its
fragment (MSL Table 5.7, 5.2.3.5). On a device without VK_EXT_shader_stencil_export it was refused
at creation (StencilExport). Under the owner's grant (rule 2's tenth form, chosen by that
extension's query alone), such a device now draws it by bits; a device with the extension is
unchanged (FragStencilRefEXT, no fact, no note, the draw issued once).

Translator: the function stores no reference; each return kills the fragment where the draw's new
push field PushField::StencilBit k is below 8 and bit k of the output's low 8 is 0, and keeps
every fragment at 8 or more (one module, no specialization). The function states
RuntimeFact::StencilBitDraws (Mechanism::PushConstant) and its fragment stage the static note
PrecisionNote::StencilOutputOverlap. Refused there, naming the extension (Unsupported
StencilExport): a function that also writes a colour (the colour would be written by every
repeat) or memory, one whose returns cannot kill (an interlocked body, a loop over its covered
samples), a mesh pipeline, and a render pipeline made for indirect command buffers. Where the
device also lacks the pixel interlock, a function writing memory in a raster order group meets
that refusal first (RasterOrderGroups). SEMANTICS_VERSION 2301 -> 2302, ARTIFACT_FORMAT_VERSION
595 -> 596 (new codec members).

Runtime (depth_stencil::BitDraws, render_encoder::draw): with w the low 8 bits of the write masks
of the faces having a Replace operation, a draw whose stencil test is on and w is not 0 is drawn
once with every fragment kept under the reference 0 (Replace zeroes w's bits, every other
operation runs once), then once per bit k of w keeping the fragments whose output holds bit k,
under the reference 255, write mask (1 << k) & mask, Replace kept and every other operation Keep,
and no depth write; where the state writes depth under a compare other than Always and Never, the
first draw writes none and a last draw writes it with stencil write masks of 0. Each draw records
only the dynamic state that differs from the last; the encoder's tests and reference are recorded
again at the next draw. Counted in Metrics::stencil_bit_draws (the draws beyond the first).
Refused at a draw, Gap::Draw of DrawKind::StencilOutput: a face compare other than Always or Never
(the output decides that test), and, where w is not 0, a draw inside a Counting visibility
segment (every draw would add its samples). A Boolean segment is drawn. Vulkan Appendix I: the
repeats change stencil reference, operations and write masks between draws of one pipeline,
which Rule 2 lists as required (write masks) and strongly suggested (stencil parameters) to be
invariant; the note records the one difference the repeats make.

The note (rule 1): fragments of one draw that overlap leave the OR of their values. Where two
fragments of one draw reach one sample under Replace, the sample stores the OR of their outputs'
low 8 bits within the write mask, where Metal stores the later fragment's value; under a depth
test that writes, each fragment's stencil operation is chosen against the depth from before the
draw. Measured on an RTX 3090 (NVIDIA 620.70.06) under the validation layer 1.4.363.0, job
m3-max-73635: two triangles of one draw outputting 0x35 then 0x4a store 0x7f on the 32 texels both
reach, where Metal stores 0x4a, and 0x35 on the 32 one reaches, in 8 bit draws; the 780M (RADV)
and the Iris Xe (ANV), which list the extension, store 0x4a with 0 bit draws.

AGENTS.md rule 2: "for nine only" becomes "for ten only", the list ending with fragment stencil
output (the planner's text, relayed by main, word for word).

Tests: the translator's engine_stencil (every committed profile: the extension or the draws by
bits, L3 both ways; refusals for colour, memory, mesh and indirect command buffers); rt's host test
of BitDraws::of; rt's device cells (stencil_export.rs): the stencil alone and the stencil with the
depth under Always and Less over a quad, exact, texels of stencil 0 among them; the overlap row;
the refusals; the route of a 4-sample Depth32Float_Stencil8 source read at sample 0 into a
single-sample target under Always/Replace 0xff and depth Always with write, beside colour 0
RGBA8 of write mask none; the codec round trip; the mechanism table.

Docs: docs/API.md (the stencil output passage and the catalogue entry
metal2vulkan-degrade-stencil-output-overlap), rt README known gap and floor row,
docs/REFUSALS.md regenerated, api_signatures blessed. The conformance degradation and the
validation allowance (unbounded) of the note. known-gaps-rt.tsv: stencil-output and
stencil-output-loaded on NVIDIA, refused at renderCommandEncoder (draw 3's back face Equal against
the output) and divergent at case/stencil as a result. runtime-sources.sha256: the guard's inputs
changed only by mechanism.rs gaining the new fact's arm, which no existing artifact states, so no
run of an existing artifact changes.

Golden rows and the engine inventory (22 cells) are re-blessed on development: 20 move from the
StencilExport refusal to a module (stx_stencil_by_pixel, stx_stencil_discard,
stx_stencil_with_depth, stx_stencil_ms_by_sample, fragment_depth_stencil on nvidia-pascal-linux,
nvidia-rtx50-linux, nvidia-rtx5080-laptop and runtime-floor), and the 2 cells
stx_stencil_in_order and stx_stencil_ms_in_order on runtime-floor move from StencilExport to
RasterOrderGroups, still refused. Why: the memory-write refusal now runs on the emitted module
(pipeline/compile.rs), after the body's own refusals, so on a profile without the pixel interlock
the raster order group these functions write memory in is refused first; at the base the plan's
entry refused every [[stencil]] output on such a device before any body was lowered.

Verified (this tree, or the rt archive of d6bd77d203 where named; the rt and translator sources
there differ from this tree in the translator's test and a doc comment alone):
- msi check, job m3-max-73648 (this tree): fmt, signatures, refusals, clippy -D warnings with all
  features plain, --cfg m2v_gpu and --cfg m2v_cpu_icd, Rustdoc, the rt nextest archive and the
  conformance binary built; rt's whole suite on lavapipe under the validation layer 1.4.363.0,
  738 tests run: 738 passed, 3 skipped; the lavapipe leg, 7 tests run: 7 passed: export enabled,
  the overlap row storing {4a}, bit draws 0 on every cell.
- RTX 3090 (NVIDIA 620.70.06, layer 1.4.363.0), job m3-max-73635 (d6bd77d203): 7 passed; the
  overlap row above, bit draws 8; the stencil alone and with depth under Always and Less, 64
  texels exact, bit draws [8, 8, 9]; the route exact, bit draws 8; refused a colour beside the
  stencil (StencilExport), Equal and a Counting segment (DrawKind::StencilOutput), a Boolean
  segment drawn. Conformance stencil-output and stencil-output-loaded: refused at
  renderCommandEncoder and divergent at case/stencil (4 elements, largest difference 80), the
  four known-gaps rows.
- RTX 5080 Laptop GPU (NVIDIA 615.71.09, layer 1.4.363.0), job m3-max-73652 (this tree): 7
  passed; overlap {7f} where both reach, {35} where one, bit draws 8; cells exact, bit draws
  [8, 8, 9]; the route exact, bit draws 8; the same refusals; conformance replay with this tree's
  binary matched the four NVIDIA rows (exit 0).
- Radeon 780M (RADV, Mesa 26.2.6), job m3-max-73636 (d6bd77d203), and Iris Xe (ANV, Mesa
  26.2.6), job m3-max-73650 (this tree): 7 passed each, export enabled, overlap {4a}, bit draws 0.
- States-only plays of recorded streams, base 0c9db49765 against d6bd77d203, every play in
  states-only mode, made and refused equal, refused 0: lavapipe, jobs m3-max-73632 and
  m3-max-73631 (two streams: render 10643 and 9014, compute 15299 and 221); the RTX 3090 with
  --device-type gpu, job m3-max-73638 (two streams: render 9834 and 10643, compute 214 and
  15299); the RTX 5080, job m3-max-73652 (two streams: render 9014 and 9645, compute 221 and
  250). Those two carry a library holding a [[stencil]] function that no recorded pipeline state
  uses; no stream on either NVIDIA node makes a [[stencil]] pipeline (job m3-max-73646 and
  m3-max-73652's scan).
- Owed: the translator and validation suites of this tree (the suites of d6bd77d203, job
  m3-max-73627, failed in the memory refusal's test on runtime-floor, the runtime guard's hash
  and the golden and inventory cells above; this tree fixes the first two).
This commit is contained in:
Anees Iqbal committed 2026-11-25 10:38:03 -08:00
1 parent d2e8ab2a85
commit 5a722b5c3f
34 files changed
+1810 -317

No files matched your search

+10 -3
View File
@@ -58,7 +58,7 @@ order, and a lower one never overrides a higher one.
limit and memory-type queries. Product code holds no vendor, device or driver ID, and no
runtime policy switch. A test enforces this for `metal2vulkan-runtime`. One form means one form per
Vulkan capability: where the floor cannot require a feature, that feature's query may choose a
second form, for nine only: 16-bit floats, storage-image reads without a format, 64-bit
second form, for ten only: 16-bit floats, storage-image reads without a format, 64-bit
atomics, 64-bit floats, SIMD groups (the subgroup size range with its stages and operations,
and maximal reconvergence), unified memory (decided by
Vulkan's physical device type alone: one copy of a Managed buffer on an integrated or CPU
@@ -66,10 +66,17 @@ order, and a lower one never overrides a higher one.
target through a counted copy of that target, recorded as a known gap), run-time texel
offsets (a device with the maintenance8 feature takes a run-time texel offset as the sampling
or read instruction's own operand; a device without it branches over the offset's values, and
that branch's compile time is recorded as a known gap), and the push window (the device's
that branch's compile time is recorded as a known gap), the push window (the device's
push-constant limit sizes it, up to 256 bytes; on a device below 256 the fields past the window
come from the stage's parameter block, and an indirect command carries fewer vertex slots,
recorded as a known gap). A second form chosen by anything else is not allowed.
recorded as a known gap), and fragment stencil output (a device with
VK_EXT_shader_stencil_export writes a fragment function's [[stencil]] as the fragment's stencil
reference; a device without it draws each draw of such a pipeline once with a stencil reference
of 0, which clears the stencil bits its depth-stencil state can replace and runs its other
stencil operations, then once for each of those bits, and, where the draw writes depth under a
depth compare other than always or never, once more for the depth; those draws, and the note
that fragments of one draw that overlap leave the OR of their values, are recorded as a known
gap). A second form chosen by anything else is not allowed.
3. **Native-like speed.** Structure decides speed: driver-owned memory, optimal images in real
layouts, direct addresses, nothing copied that Metal would not copy. Optimal images have two
exceptions. A texture over a Shared buffer: a linear image on that buffer's memory, in the
@@ -2376,6 +2376,10 @@ shared-exponent-update-float RX 550 refused case/fpv_srgb_update/dispatch Err(Er
shared-exponent-update-half RX 550 refused case/fpv_srgb_update_half/dispatch Err(Error::Unsupported("texture slot 0, which a function writes or reads as storage, bound to a RGB9E5Float texture with no storage element on this device, or one it cannot read without a format, is not built")) The device's own answer (rule 2): this device's format queries offer no storage image of MTLPixelFormatRGB9E5Float, so rt binds no such texture to a read_write or write slot.
shared-exponent-write-float RX 550 refused case/fpv_srgb_write/dispatch Err(Error::Unsupported("texture slot 0, which a function writes or reads as storage, bound to a RGB9E5Float texture with no storage element on this device, or one it cannot read without a format, is not built")) The device's own answer (rule 2): this device's format queries offer no storage image of MTLPixelFormatRGB9E5Float, so rt binds no such texture to a read_write or write slot.
shared-exponent-write-half RX 550 refused case/fpv_srgb_write_half/dispatch Err(Error::Unsupported("texture slot 0, which a function writes or reads as storage, bound to a RGB9E5Float texture with no storage element on this device, or one it cannot read without a format, is not built")) The device's own answer (rule 2): this device's format queries offer no storage image of MTLPixelFormatRGB9E5Float, so rt binds no such texture to a read_write or write slot.
stencil-output NVIDIA refused case/program/renderCommandEncoder Err(Error::Unsupported("a draw with StencilOutput is not built")) A known gap of the runtime (its README, Known gaps of render pipeline states): NVIDIA's 615 and 620 drivers do not list `VK_EXT_shader_stencil_export`, so the runtime draws the fragment function's `[[stencil]]` output by bits, which gives Metal's answer only under a stencil compare of `Always` or `Never`. Metal tests draw 3's back face, `Equal` under the read mask `0x0f`, against that draw's output; the runtime refuses that draw, `Gap::Draw` of `DrawKind::StencilOutput`. Draws 1 and 2 are drawn, draw 1 by bits.
stencil-output NVIDIA divergent case/stencil 4 elements differ (U8), the largest difference 80 Follows from the refused draw 3 (the row above): the stencil holds draw 1's output, drawn by bits, and draw 2's increment, where Metal's draw 3 has applied its back face's `Invert` or `Zero`. The first differing element is at [image 0, row 0, 0] (U8, byte 0): Metal 1 (0x1), ours 17 (0x11).
stencil-output-loaded NVIDIA refused case/program/renderCommandEncoder Err(Error::Unsupported("a draw with StencilOutput is not built")) A known gap of the runtime (its README, Known gaps of render pipeline states): NVIDIA's 615 and 620 drivers do not list `VK_EXT_shader_stencil_export`, so the runtime draws the fragment function's `[[stencil]]` output by bits, which gives Metal's answer only under a stencil compare of `Always` or `Never`. Metal tests draw 3's back face, `Equal` under the read mask `0x0f`, against that draw's output; the runtime refuses that draw, `Gap::Draw` of `DrawKind::StencilOutput`. Draws 1 and 2 are drawn, draw 1 by bits.
stencil-output-loaded NVIDIA divergent case/stencil 4 elements differ (U8), the largest difference 80 Follows from the refused draw 3 (the row above): the stencil holds draw 1's output, drawn by bits, and draw 2's increment, where Metal's draw 3 has applied its back face's `Invert` or `Zero`. The first differing element is at [image 0, row 0, 0] (U8, byte 0): Metal 1 (0x1), ours 17 (0x11).
surface-fills-over-planes-and-buffers * refused case/500/b4/texture Err(Unavailable({call: "newTextureWithDescriptor:iosurface:plane: of a two-plane YCbCr format"})) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture descriptor of a pixel format above 260, so none of Metal's two-plane YCbCr formats, 500 on). A texture of a two-plane YCbCr format over a surface's planes, which converts both planes' codes as it reads; rt has no texture of one, and the replay streams' surface textures are of ordinary formats (surface_textures).
surface-textures-420v-chroma-rg8 NVIDIA refused case/replace-region Err(Error::Refused("the CPU reaches no Private or Memoryless texture")) rt's own gap: this device lays the case's two-plane surface in place under neither the dma-buf nor the opaque fd (53626: 0 in place, 2 copied), so the surface takes the copy form, in which a plane's texture is a texture over a buffer in the exported block, whose memory is Private, and rt refuses the CPU's replaceRegion: of it; Metal's texture over an IOSurface plane takes the CPU's write. The one-plane cases are in place here and compare. Why each handle took the copy form (SurfaceCopy) this run does not record.
surface-textures-420v-luma-r8 NVIDIA refused case/replace-region Err(Error::Refused("the CPU reaches no Private or Memoryless texture")) rt's own gap: this device lays the case's two-plane surface in place under neither the dma-buf nor the opaque fd (53626: 0 in place, 2 copied), so the surface takes the copy form, in which a plane's texture is a texture over a buffer in the exported block, whose memory is Private, and rt refuses the CPU's replaceRegion: of it; Metal's texture over an IOSurface plane takes the CPU's write. The one-plane cases are in place here and compare. Why each handle took the copy form (SurfaceCopy) this run does not record.
Can't render this file because it is too large.
@@ -173,6 +173,8 @@ pub enum Degradation {
VertexSimdgroupGrouping,
/// `metal2vulkan-degrade-restricted-depth-upload`.
RestrictedDepthUpload,
/// `metal2vulkan-degrade-stencil-output-overlap`.
StencilOutputOverlap,
}
impl Degradation {
@@ -259,6 +261,7 @@ impl Degradation {
Degradation::DeviceOcclusionCount,
Degradation::VertexSimdgroupGrouping,
Degradation::RestrictedDepthUpload,
Degradation::StencilOutputOverlap,
];
/// The kind's code, `metal2vulkan-degrade-<kind>`.
@@ -387,6 +390,7 @@ impl Degradation {
"metal2vulkan-degrade-vertex-simdgroup-grouping"
}
Degradation::RestrictedDepthUpload => "metal2vulkan-degrade-restricted-depth-upload",
Degradation::StencilOutputOverlap => "metal2vulkan-degrade-stencil-output-overlap",
}
}
@@ -476,6 +480,7 @@ impl Degradation {
PrecisionNote::DeviceOcclusionCount => Degradation::DeviceOcclusionCount,
PrecisionNote::VertexSimdgroupGrouping => Degradation::VertexSimdgroupGrouping,
PrecisionNote::RestrictedDepthUpload => Degradation::RestrictedDepthUpload,
PrecisionNote::StencilOutputOverlap => Degradation::StencilOutputOverlap,
}
}
}
+21 -5
View File
@@ -3993,10 +3993,26 @@ cache is answered compile-required on both.
states (jobs m3-max-63105 to 63108, and m3-max-63132 and m3-max-63156 for the two streams that
ran past those jobs' 300-second limit).
- On a device that does not list `VK_EXT_shader_stencil_export`, a fragment function's `[[stencil]]`
output is refused at creation, an `Error::Translation` naming `StencilExport`: the translator has
no other form. The runtime has refused it on such a device all along, worded otherwise before:
the translator's other form bound a storage image through a descriptor, which the identity
domains hold none of. Metal's feature set tables give stencil
output is drawn by bits (`RuntimeFact::StencilBitDraws`). Each draw through its state is drawn
once under the stencil reference 0, then once for each bit of the low 8 of the write masks of
the faces whose operations replace, each keeping only the fragments whose output holds that bit
(`PushField::StencilBit`), under the reference 255, that bit's write mask, `Replace` kept and
every other operation `Keep`, and no depth write; where the state writes the depth under a
compare other than `Always` and `Never`, the first draw writes none and a last draw writes it.
That is up to 10 draws where Metal draws once (`Metrics::stencil_bit_draws`), and a draw whose
state replaces no bit, or tests no stencil, is drawn once. Two fragments of one draw on one
sample store the OR of their outputs where Metal stores the later one, and under a depth test
that writes, each fragment's stencil operation is chosen against the depth from before the
draw: the static note `PrecisionNote::StencilOutputOverlap` on the fragment stage of every such
function. Refused at creation there, an `Error::Translation` naming `StencilExport`: a function
that also writes a colour or memory, one whose returns cannot discard, a mesh pipeline, and a
state made for indirect command buffers. Refused at a draw, `Gap::Draw` of
`DrawKind::StencilOutput`: a stencil compare other than `Always` and `Never` on a face, whose
answer the output decides, and, where the state replaces a bit, a draw inside a `Counting`
visibility result's segment, whose count every one of the draws would add to. A colour beside
the output can be built under this form when a guest needs it: every draw through the one
pipeline, the colour written the same each time, with blending off on every attachment, the
logic operation off and no colour input. Metal's feature set tables give stencil
feedback to the Apple5 family and later and to Metal 3 and Metal 4. NVIDIA's 615 and 620 drivers
on the RTX 2080, RTX 3090 and RTX 5080 Laptop list none (`vulkaninfo`, jobs m3-max-48727, 48729
and 48731); RADV on the RX 7900 XTX, the 780Ms and the RX 550, ANV on the Iris Xe, lavapipe,
@@ -5113,7 +5129,7 @@ Presenting runs on the runtime's own device; nothing is exported or imported.
| `VK_KHR_shader_subgroup_uniform_control_flow` | device, where listed | SIMD groups' reconvergence where maximal reconvergence is not offered |
| `VK_KHR_shader_quad_control` | device, where listed | a fragment function's group operations over other lanes, through the quad-control feature below |
| `VK_EXT_fragment_shader_interlock` | device, where listed | a fragment function's raster order groups on memory it reads and writes, through the pixel-interlock feature below |
| `VK_EXT_shader_stencil_export` | device, where listed | a fragment function's `[[stencil]]` output as the fragment's stencil reference (`FragStencilRefEXT`); RADV, ANV, lavapipe, KosmicKrisp and the UHD 630's Windows driver list it, NVIDIA's 615 and 620 drivers do not |
| `VK_EXT_shader_stencil_export` | device, where listed | a fragment function's `[[stencil]]` output as the fragment's stencil reference (`FragStencilRefEXT`); a device without it draws the output by bits (the known gaps); RADV, ANV, lavapipe, KosmicKrisp and the UHD 630's Windows driver list it, NVIDIA's 615 and 620 drivers do not |
| `VK_KHR_portability_enumeration` | instance, where offered | listing portability devices, each checked against the floor as any other |
| `VK_KHR_portability_subset` | device, where listed | Vulkan requires it enabled where a device lists it; the device is asked for the portability features below |
| `VK_EXT_attachment_feedback_loop_layout` | device, with the feedback loop | a draw's read of an attachment of its own pass through a texture, in the feedback layout, with the colour flag every render pipeline takes (below) |
+14 -1
View File
@@ -317,10 +317,12 @@ pub(crate) enum Metric {
OverlappingCopiesRefused,
/// [`Metrics::heap_moves`].
HeapMoves,
/// [`Metrics::stencil_bit_draws`].
StencilBitDraws,
}
/// The number of [`Metric`]s.
const METRICS: usize = Metric::HeapMoves as usize + 1;
const METRICS: usize = Metric::StencilBitDraws as usize + 1;
/// Every [`Metric`], in its order: each at its own index.
const METRIC_ORDER: [Metric; METRICS] = [
@@ -377,6 +379,7 @@ const METRIC_ORDER: [Metric; METRICS] = [
Metric::AccumulatedVisibilityRefused,
Metric::OverlappingCopiesRefused,
Metric::HeapMoves,
Metric::StencilBitDraws,
];
// Each metric of the order is at its own index.
@@ -804,6 +807,7 @@ struct Atomics {
accumulated_visibility_refused: AtomicU64,
overlapping_copies_refused: AtomicU64,
heap_moves: AtomicU64,
stencil_bit_draws: AtomicU64,
/// Each [`Part`]'s calls, at its index: their count, bytes, total and longest nanoseconds,
/// and those over each of [`OVER_NANOS`].
parts: [[AtomicU64; 7]; PARTS],
@@ -974,6 +978,7 @@ impl Counters {
Metric::AccumulatedVisibilityRefused => &a.accumulated_visibility_refused,
Metric::OverlappingCopiesRefused => &a.overlapping_copies_refused,
Metric::HeapMoves => &a.heap_moves,
Metric::StencilBitDraws => &a.stencil_bit_draws,
}
}
@@ -1915,6 +1920,7 @@ impl Counters {
accumulated_visibility_refused: a.accumulated_visibility_refused.load(Relaxed),
overlapping_copies_refused: a.overlapping_copies_refused.load(Relaxed),
heap_moves: a.heap_moves.load(Relaxed),
stencil_bit_draws: a.stencil_bit_draws.load(Relaxed),
takes: part(Part::Take),
take_lock_waits: part(Part::TakeLock),
take_makes: part(Part::TakeMake),
@@ -2910,6 +2916,13 @@ pub struct Metrics {
/// command buffer of its own that leads the command's part of its command buffer. No Metal
/// counterpart.
pub heap_moves: u64,
/// On a device without `VK_EXT_shader_stencil_export`, the draws recorded beyond a draw's
/// own for a pipeline state whose fragment function writes `[[stencil]]`: one for each
/// stencil bit the draw's depth-stencil state can replace, and one that writes the depth last
/// where the state writes it under a compare other than `Always` and `Never`
/// ([`DrawKind::StencilOutput`](crate::DrawKind::StencilOutput) says where they are refused).
/// 0 on a device with the extension. Metal draws once.
pub stencil_bit_draws: u64,
/// Takes from the pool on the consumer's threads, each whole: a block of
/// [`Device::take_block`](crate::Device::take_block) and a texture block, carved from a free
/// range or from an allocation the take made ([`take_makes`](Self::take_makes)); their bytes
@@ -81,6 +81,132 @@ impl Tests {
}
}
/// The bit a draw through a pipeline whose fragment function's stencil output is drawn by bits
/// pushes to keep every fragment (`PushField::StencilBit` at 8 or more).
pub(crate) const EVERY_FRAGMENT: u32 = 8;
/// The most draws one draw takes: its first, one per stencil bit, and its depth's.
const MOST_DRAWS: usize = 10;
/// One of the draws a draw takes through a pipeline whose fragment function's stencil output is
/// drawn by bits (`RuntimeFact::StencilBitDraws`, on a device without
/// `VK_EXT_shader_stencil_export`): its tests, its stencil reference of each face, and the bit its
/// function keeps (`PushField::StencilBit`).
#[derive(Clone, Copy, PartialEq, Eq)]
pub(crate) struct BitDraw {
pub(crate) tests: Tests,
pub(crate) reference: [u32; 2],
pub(crate) bit: u32,
}
/// The draws one draw takes through such a pipeline, in order ([`BitDraws::of`]).
pub(crate) struct BitDraws {
draws: [BitDraw; MOST_DRAWS],
len: usize,
}
impl BitDraws {
/// The draws of a draw under the encoder's `tests` and `reference`. Where the stencil test
/// replaces no bit (it is off, no operation of a face is `Replace`, or those faces' write
/// masks are 0), the draw alone, every fragment kept: its output is no reference anything
/// reads. Otherwise, with `w` the low 8 bits of the write masks of the faces with a `Replace`
/// operation:
///
/// 1. every fragment kept, under the tests but the reference 0 on both faces, so `Replace`
/// zeroes the bits of `w` and every other operation runs once;
/// 2. for each bit `k` of `w`, the fragments whose output holds bit `k`, under the reference
/// 255, each face's write mask cut to bit `k`, its `Replace` operations kept and its others
/// `Keep`, and no depth write, so `Replace` sets bit `k` where the output holds it;
/// 3. where the tests write depth under a compare other than `Always` and `Never`, the first
/// draw writes none, and a last one, every fragment kept, writes it under the tests with
/// stencil write masks of 0: each draw before it tests against the depth from before the
/// draw, as Metal's draw does.
///
/// Each draw takes the same fragments through the same tests where the compare is `Always`
/// or `Never` on both faces, which the reference does not change, so a sample one fragment
/// reaches stores Metal's value.
///
/// `None` for a stencil test that compares by another function on a face, whose answer the
/// reference decides.
pub(crate) fn of(tests: Tests, reference: [u32; 2]) -> Option<BitDraws> {
let own = BitDraw {
tests,
reference,
bit: EVERY_FRAGMENT,
};
let mut draws = BitDraws {
draws: [own; MOST_DRAWS],
len: 1,
};
if !tests.stencil {
return Some(draws);
}
let fixed = |compare| matches!(compare, vk::CompareOp::ALWAYS | vk::CompareOp::NEVER);
if !tests.faces.iter().all(|face| fixed(face.compare)) {
return None;
}
let replaces = |f: &&Face| [f.fail, f.pass, f.depth_fail].contains(&vk::StencilOp::REPLACE);
let bits = (tests.faces.iter().filter(replaces)).fold(0, |bits, f| bits | f.write_mask);
let bits = bits & 0xff;
if bits == 0 {
return Some(draws);
}
let last = tests.depth_write && !fixed(tests.depth_compare);
draws.draws[0] = BitDraw {
tests: Tests {
depth_write: tests.depth_write && !last,
..tests
},
reference: [0; 2],
bit: EVERY_FRAGMENT,
};
let kept = |op| match op {
vk::StencilOp::REPLACE => op,
_ => vk::StencilOp::KEEP,
};
for k in (0..8).filter(|k| bits & (1 << k) != 0) {
let face = |f: Face| Face {
fail: kept(f.fail),
pass: kept(f.pass),
depth_fail: kept(f.depth_fail),
write_mask: f.write_mask & (1 << k),
..f
};
draws.push(BitDraw {
tests: Tests {
depth_write: false,
faces: tests.faces.map(face),
..tests
},
reference: [255; 2],
bit: k,
});
}
if last {
let unwritten = |f: Face| Face { write_mask: 0, ..f };
draws.push(BitDraw {
tests: Tests {
faces: tests.faces.map(unwritten),
..tests
},
reference,
bit: EVERY_FRAGMENT,
});
}
Some(draws)
}
fn push(&mut self, draw: BitDraw) {
self.draws[self.len] = draw;
self.len += 1;
}
/// The draws, in order: at least one.
pub(crate) fn draws(&self) -> &[BitDraw] {
&self.draws[..self.len]
}
}
impl Device {
/// `newDepthStencilStateWithDescriptor:`.
pub fn new_depth_stencil_state(
+9
View File
@@ -1829,6 +1829,15 @@ pub enum DrawKind {
/// word is not built. Counted in
/// [`Metrics::accumulated_visibility_refused`](crate::Metrics::accumulated_visibility_refused).
AccumulatedVisibilityResults,
/// On a device without `VK_EXT_shader_stencil_export`, a draw through a pipeline state whose
/// fragment function writes `[[stencil]]`, which the runtime draws once and then once per
/// stencil bit the depth-stencil state can replace (`Metrics::stencil_bit_draws`), where
/// those draws do not give Metal's answer: under a stencil test whose compare function is
/// other than `Always` and `Never` on a face, as the fragment's output is that test's
/// reference; and, where the state replaces a bit, inside a `Counting` visibility result's
/// segment, whose count each draw would add to. Metal tests and writes the stencil against the
/// output in one draw.
StencilOutput,
}
/// What a render pass asks that the runtime does not build ([`Gap::RenderPass`]).
+21
View File
@@ -72,6 +72,7 @@
use crate::cache::{self, Lowerings};
use crate::counters::{Counters, FirstUse, Gauge, Metric};
use crate::depth_stencil::EVERY_FRAGMENT;
use crate::device::{lock, Core};
use crate::error::{Error, Gap, Refusal, RenderPipelineKind, StageGap};
use crate::hazard::Access;
@@ -191,6 +192,11 @@ pub(crate) struct Draws {
/// (`GraphicsState::writes_viewport_index`): its primitives reach every viewport the encoder
/// set, where any other function's reach viewport 0.
pub(crate) selects_viewport: bool,
/// The push offset of the bit the fragment function keeps its fragments for
/// (`PushField::StencilBit`), where its stencil output is drawn by bits
/// (`RuntimeFact::StencilBitDraws`): each draw takes the draws of
/// [`BitDraws`](crate::depth_stencil::BitDraws), each pushing its bit there.
pub(crate) stencil_bit: Option<u32>,
}
/// The state Vulkan 1.3 lets a draw set, which every render `VkPipeline` takes as dynamic.
@@ -669,6 +675,9 @@ fn draws(
// past the encoder's viewport count, read from its push field
// (`FieldValue::ViewportCount`).
RuntimeFact::ViewportCount => {}
// A fragment function's stencil output on a device without stencil export, which each
// draw takes by bits through its push field (`Draws::stencil_bit`).
RuntimeFact::StencilBitDraws => {}
// `RuntimeFact` is non-exhaustive: a fact this match does not name is one a draw does
// not supply.
_ => return Err(draw_input()),
@@ -713,6 +722,7 @@ fn draws(
let mut levels = Vec::new();
let mut push_len = 0;
let mut blocks = [None; 2];
let mut stencil_bit = None;
for placement in &translated.push {
let at = table(placement.stage)?;
if let Some((offset, size)) = placement.push_range {
@@ -852,6 +862,16 @@ fn draws(
PushField::IndirectRange if at == VERTEX => FieldValue::IndirectRange,
PushField::IndirectSequence if at == VERTEX => FieldValue::IndirectSequence,
PushField::IndirectBase if at == VERTEX => FieldValue::IndirectBase,
// The bit a fragment function whose stencil output is drawn by bits keeps its
// fragments for: every fragment, but in a draw's bit draws, which write their own
// bit over it. One in the parameter block is not supplied.
PushField::StencilBit if at == FRAGMENT => match offset {
DrawPlace::Push(pushed) => {
stencil_bit = Some(pushed);
FieldValue::Word(EVERY_FRAGMENT)
}
DrawPlace::Block(..) => return Err(draw_input()),
},
_ => return Err(draw_input()),
};
fields.push((offset, at, value));
@@ -902,6 +922,7 @@ fn draws(
first_instance_zero: divided && !nonzero_first_instance,
patches: pipeline.graphics.tessellation.is_some(),
selects_viewport: pipeline.graphics.writes_viewport_index,
stencil_bit,
};
Ok((draws, (numbered, constexprs)))
}
+239 -157
View File
@@ -87,7 +87,7 @@ use crate::alias;
use crate::buffer::{Buffer, BufferInner, BufferObject};
use crate::command::{Building, CommandBuffer};
use crate::counters::Metric;
use crate::depth_stencil::{DepthStencilState, Face, Tests};
use crate::depth_stencil::{BitDraws, DepthStencilState, Face, Tests, EVERY_FRAGMENT};
use crate::device::Core;
use crate::encoder::{
check_alignment, merge, Declared, Resource, ResourceUsage, BUFFER_SLOTS, SAMPLER_SLOTS,
@@ -1540,7 +1540,8 @@ impl RenderCommandEncoder {
let query = self.building().take_query()?;
// SAFETY: as above.
unsafe { self.results.end(&self.core.device, self.command) };
self.results.start(offset, query);
self.results
.start(offset, query, mode == VisibilityResultMode::Counting);
Ok(())
}
@@ -2491,6 +2492,17 @@ impl RenderCommandEncoder {
if lines && self.line_width != 1.0 {
return gap(DrawKind::LineWidth);
}
// A fragment function's stencil output drawn by bits: the draws this draw takes and the
// push offset of the bit each keeps, where it takes more than one.
let bits = match draws.stencil_bit {
None => None,
Some(at) => match BitDraws::of(self.tests, self.stencil_reference) {
None => return gap(DrawKind::StencilOutput),
Some(each) if each.draws().len() == 1 => None,
Some(_) if self.results.counts_samples() => return gap(DrawKind::StencilOutput),
Some(each) => Some((at as usize, each)),
},
};
// Points Metal does not rasterize: the vertex function runs, behind an empty scissor.
let hidden = topology == vk::PrimitiveTopology::POINT_LIST && !compiled.rasterizes_points();
let pipeline = compiled.pipeline(topology, self.raster)?;
@@ -2627,6 +2639,10 @@ impl RenderCommandEncoder {
self.push_filled = !commands;
}
let push = !self.push.is_empty() && building.push_needed(&self.push);
// A draw by bits records each of its draws' tests and reference before that draw.
if bits.is_some() {
self.dirty &= !(DEPTH | STENCIL | REFERENCE);
}
let core = &*self.core;
let command = self.command;
// SAFETY: the command buffer is inside the pass's rendering, which the pipeline renders
@@ -2678,127 +2694,153 @@ impl RenderCommandEncoder {
if push {
device.cmd_push_constants(command, core.layout, PUSH_STAGES, 0, &self.push);
}
match (call, index) {
(
Call::Indexed {
index_count,
base_vertex,
..
},
Some((_, buffer, offset, ty)),
) => {
device.cmd_bind_index_buffer(command, buffer, offset, ty);
device.cmd_draw_indexed(
command,
index_count,
instance_count,
0,
base_vertex,
base_instance,
);
}
(
Call::Direct {
vertex_start,
vertex_count,
},
_,
) => device.cmd_draw(
command,
vertex_count,
instance_count,
vertex_start,
base_instance,
),
(
Call::Patches {
patch_start,
patch_count,
},
_,
) => device.cmd_draw(
command,
patch_count,
instance_count,
patch_start,
base_instance,
),
(
Call::Indirect {
arguments, offset, ..
},
index,
) => {
let (reached, at) = arguments.device_range();
let stride = indirect_bytes(index.is_some()) as u32;
match index {
Some((_, buffer, index_offset, ty)) => {
device.cmd_bind_index_buffer(command, buffer, index_offset, ty);
device.cmd_draw_indexed_indirect(
command,
reached,
at + offset,
1,
stride,
);
// A draw by bits: each of its draws after its tests, its reference and, past the
// first, whose bit is the one the push bytes hold, its bit.
let bit_draws = bits
.as_ref()
.map_or(&[][..], |(_, bit_draws)| bit_draws.draws());
for at in 0..bit_draws.len().max(1) {
if let (Some(draw), Some((offset, _))) = (bit_draws.get(at), &bits) {
record_tests(device, command, draw.tests, self.recorded, (true, true));
self.recorded = Some(draw.tests);
if at == 0 || bit_draws[at - 1].reference != draw.reference {
record_reference(device, command, draw.reference);
}
if at > 0 {
let offset = *offset;
let bit = draw.bit.to_le_bytes();
self.push[offset..offset + 4].copy_from_slice(&bit);
if building.push_needed(&self.push) {
let pushed = &self.push;
device.cmd_push_constants(command, core.layout, PUSH_STAGES, 0, pushed);
}
None => device.cmd_draw_indirect(command, reached, at + offset, 1, stride),
}
}
(
Call::Commands {
buffer,
first,
sequences,
counts,
..
},
_,
) => {
if let (Some(indirect), Some((shape, _, preprocess))) =
(&core.indirect, &execution)
{
// One execution of each part, in order, each part's first command pushed
// at the base field; the first part's push is the draw's own. Over a
// range a buffer holds, each part runs as many as its count says.
let layout = buffer.layout();
let info = crate::dgc::PipelineInfo::new(pipeline);
let base = shape.base as usize;
for (part, from) in (0..sequences).step_by(shape.part as usize).enumerate()
{
let count = (sequences - from).min(shape.part);
let counted = match counts {
0 => 0,
counts => counts + 4 * part as u64,
};
if part > 0 {
let command_index = first + from;
self.push[base..base + 4]
.copy_from_slice(&command_index.to_le_bytes());
device.cmd_push_constants(
match (call, index) {
(
Call::Indexed {
index_count,
base_vertex,
..
},
Some((_, buffer, offset, ty)),
) => {
device.cmd_bind_index_buffer(command, buffer, offset, ty);
device.cmd_draw_indexed(
command,
index_count,
instance_count,
0,
base_vertex,
base_instance,
);
}
(
Call::Direct {
vertex_start,
vertex_count,
},
_,
) => device.cmd_draw(
command,
vertex_count,
instance_count,
vertex_start,
base_instance,
),
(
Call::Patches {
patch_start,
patch_count,
},
_,
) => device.cmd_draw(
command,
patch_count,
instance_count,
patch_start,
base_instance,
),
(
Call::Indirect {
arguments, offset, ..
},
index,
) => {
let (reached, at) = arguments.device_range();
let stride = indirect_bytes(index.is_some()) as u32;
match index {
Some((_, buffer, index_offset, ty)) => {
device.cmd_bind_index_buffer(command, buffer, index_offset, ty);
device.cmd_draw_indexed_indirect(
command,
core.layout,
PUSH_STAGES,
0,
&self.push,
reached,
at + offset,
1,
stride,
);
}
let stream =
buffer.records().memory.address + layout.command(first + from);
let size = u64::from(count) * u64::from(layout.stride());
let at = *preprocess + shape.part_stride() * part as u64;
let generated = crate::dgc::CommandsInfo::new(
&info,
shape.layout.handle(),
(stream, size),
(at, shape.preprocess_size()),
(count, counted),
);
(indirect.dgc.execute)(command, vk::FALSE, &generated);
None => {
device.cmd_draw_indirect(command, reached, at + offset, 1, stride)
}
}
}
(
Call::Commands {
buffer,
first,
sequences,
counts,
..
},
_,
) => {
if let (Some(indirect), Some((shape, _, preprocess))) =
(&core.indirect, &execution)
{
// One execution of each part, in order, each part's first command pushed
// at the base field; the first part's push is the draw's own. Over a
// range a buffer holds, each part runs as many as its count says.
let layout = buffer.layout();
let info = crate::dgc::PipelineInfo::new(pipeline);
let base = shape.base as usize;
for (part, from) in
(0..sequences).step_by(shape.part as usize).enumerate()
{
let count = (sequences - from).min(shape.part);
let counted = match counts {
0 => 0,
counts => counts + 4 * part as u64,
};
if part > 0 {
let command_index = first + from;
self.push[base..base + 4]
.copy_from_slice(&command_index.to_le_bytes());
device.cmd_push_constants(
command,
core.layout,
PUSH_STAGES,
0,
&self.push,
);
}
let stream =
buffer.records().memory.address + layout.command(first + from);
let size = u64::from(count) * u64::from(layout.stride());
let at = *preprocess + shape.part_stride() * part as u64;
let generated = crate::dgc::CommandsInfo::new(
&info,
shape.layout.handle(),
(stream, size),
(at, shape.preprocess_size()),
(count, counted),
);
(indirect.dgc.execute)(command, vk::FALSE, &generated);
}
}
}
(Call::Indexed { .. }, None) => {}
}
(Call::Indexed { .. }, None) => {}
}
}
// An execution holds its records, layout and region until the command buffer retires,
@@ -2809,6 +2851,16 @@ impl RenderCommandEncoder {
building.keep_executed(executed);
building.pushes_lost();
}
// After a draw by bits, the push bytes keep every fragment again, and the next draw
// records the encoder's tests and reference where they differ from the last draw's.
if let Some((offset, bit_draws)) = &bits {
let every = EVERY_FRAGMENT.to_le_bytes();
self.push[*offset..*offset + 4].copy_from_slice(&every);
self.dirty |= DEPTH | STENCIL | REFERENCE;
for _ in 1..bit_draws.draws().len() {
building.count(Metric::StencilBitDraws);
}
}
if self.facts.levels {
building.count(Metric::LevelFieldCommands);
}
@@ -3358,7 +3410,6 @@ impl RenderCommandEncoder {
let command = self.command;
let dirty = self.dirty;
self.dirty = 0;
let both = [vk::StencilFaceFlags::FRONT, vk::StencilFaceFlags::BACK];
// SAFETY: the command buffer records; each state is dynamic in every render pipeline.
unsafe {
// As many scissors as viewports, as Vulkan's with-count states require.
@@ -3398,50 +3449,12 @@ impl RenderCommandEncoder {
// Of the tests, the fields that differ from the ones last recorded; every field
// before the first draw. A draw whose tests are not dirty copies none of them.
if dirty & (DEPTH | STENCIL) != 0 {
let (t, was) = (self.tests, self.recorded);
if dirty & DEPTH != 0 {
if was.is_none_or(|w| w.depth_test != t.depth_test) {
device.cmd_set_depth_test_enable(command, t.depth_test);
}
if was.is_none_or(|w| w.depth_write != t.depth_write) {
device.cmd_set_depth_write_enable(command, t.depth_write);
}
if was.is_none_or(|w| w.depth_compare != t.depth_compare) {
device.cmd_set_depth_compare_op(command, t.depth_compare);
}
}
if dirty & STENCIL != 0 {
if was.is_none_or(|w| w.stencil != t.stencil) {
device.cmd_set_stencil_test_enable(command, t.stencil);
}
for (at, face) in both.iter().enumerate() {
let f = &t.faces[at];
let old = was.map(|w| w.faces[at]);
let ops = |f: &Face| (f.fail, f.pass, f.depth_fail, f.compare);
if old.is_none_or(|o| ops(&o) != ops(f)) {
device.cmd_set_stencil_op(
command,
*face,
f.fail,
f.pass,
f.depth_fail,
f.compare,
);
}
if old.is_none_or(|o| o.compare_mask != f.compare_mask) {
device.cmd_set_stencil_compare_mask(command, *face, f.compare_mask);
}
if old.is_none_or(|o| o.write_mask != f.write_mask) {
device.cmd_set_stencil_write_mask(command, *face, f.write_mask);
}
}
}
self.recorded = Some(t);
let parts = (dirty & DEPTH != 0, dirty & STENCIL != 0);
record_tests(device, command, self.tests, self.recorded, parts);
self.recorded = Some(self.tests);
}
if dirty & REFERENCE != 0 {
for (face, reference) in both.iter().zip(self.stencil_reference) {
device.cmd_set_stencil_reference(command, *face, reference);
}
record_reference(device, command, self.stencil_reference);
}
if dirty & BLEND != 0 {
device.cmd_set_blend_constants(command, &self.blend_color);
@@ -3648,6 +3661,75 @@ impl RenderCommandEncoder {
}
}
/// Records the fields of `tests` that differ from `was`, the tests last recorded (every field
/// where none were), of its depth part and of its stencil part where `parts` says so.
///
/// # Safety
///
/// `command` records; each state is dynamic in every render pipeline.
unsafe fn record_tests(
device: &ash::Device,
command: vk::CommandBuffer,
t: Tests,
was: Option<Tests>,
(depth, stencil): (bool, bool),
) {
let both = [vk::StencilFaceFlags::FRONT, vk::StencilFaceFlags::BACK];
// SAFETY: by the caller.
unsafe {
if depth {
if was.is_none_or(|w| w.depth_test != t.depth_test) {
device.cmd_set_depth_test_enable(command, t.depth_test);
}
if was.is_none_or(|w| w.depth_write != t.depth_write) {
device.cmd_set_depth_write_enable(command, t.depth_write);
}
if was.is_none_or(|w| w.depth_compare != t.depth_compare) {
device.cmd_set_depth_compare_op(command, t.depth_compare);
}
}
if stencil {
if was.is_none_or(|w| w.stencil != t.stencil) {
device.cmd_set_stencil_test_enable(command, t.stencil);
}
for (at, face) in both.iter().enumerate() {
let f = &t.faces[at];
let old = was.map(|w| w.faces[at]);
let ops = |f: &Face| (f.fail, f.pass, f.depth_fail, f.compare);
if old.is_none_or(|o| ops(&o) != ops(f)) {
device.cmd_set_stencil_op(
command,
*face,
f.fail,
f.pass,
f.depth_fail,
f.compare,
);
}
if old.is_none_or(|o| o.compare_mask != f.compare_mask) {
device.cmd_set_stencil_compare_mask(command, *face, f.compare_mask);
}
if old.is_none_or(|o| o.write_mask != f.write_mask) {
device.cmd_set_stencil_write_mask(command, *face, f.write_mask);
}
}
}
}
}
/// Records `reference`, each face's stencil reference.
///
/// # Safety
///
/// As [`record_tests`].
unsafe fn record_reference(device: &ash::Device, command: vk::CommandBuffer, reference: [u32; 2]) {
let both = [vk::StencilFaceFlags::FRONT, vk::StencilFaceFlags::BACK];
for (face, reference) in both.iter().zip(reference) {
// SAFETY: by the caller.
unsafe { device.cmd_set_stencil_reference(command, *face, reference) };
}
}
/// The topology of a draw of `primitive_type`, and whether it restarts strips.
fn primitives(primitive_type: PrimitiveType) -> (vk::PrimitiveTopology, bool) {
let (topology, restart) = input_assembly(primitive_type);
@@ -87,6 +87,7 @@ fn draws(fields: Vec<(DrawPlace, usize, FieldValue)>) -> Draws {
first_instance_zero: false,
patches: false,
selects_viewport: false,
stencil_bit: None,
}
}
File diff suppressed because it is too large. Load diff
+12 -2
View File
@@ -151,6 +151,8 @@ pub(crate) struct Results {
/// The `Boolean` or `Counting` mode set last, where no mode set or end of the encoder ended
/// it: its offset, its query, and whether a draw began the query.
segment: Option<(u64, Query, bool)>,
/// Whether that segment's mode is `Counting`, whose result each draw's passing samples add to.
counted: bool,
/// The segments ended, in order.
ended: Vec<(u64, Query)>,
/// The offsets the encoder's modes took.
@@ -174,10 +176,18 @@ impl Results {
matches!(self.segment, Some((_, _, true)))
}
/// A segment of `query` at `offset` starts, the one before it ended ([`end`](Self::end)).
pub(crate) fn start(&mut self, offset: u64, query: Query) {
/// A segment of `query` at `offset` starts, of mode `Counting` where `counted`, the one before it
/// ended ([`end`](Self::end)).
pub(crate) fn start(&mut self, offset: u64, query: Query, counted: bool) {
self.taken.insert(offset);
self.segment = Some((offset, query, false));
self.counted = counted;
}
/// Whether a `Counting` mode's segment holds the draws: each draw adds its passing samples to
/// the result.
pub(crate) fn counts_samples(&self) -> bool {
self.segment.is_some() && self.counted
}
/// Before a draw: begins the segment's query where no draw of it began it.
@@ -1 +1 @@
5f611d76cc7fe24cedb2197787d0796be5a8eb5a228d33aecb08e4a0e7d1a302
b484a6b037e2ae562f5a3c89313babecbce60262b0adbe70508e73426167dff8
@@ -184,6 +184,8 @@ impl UlpTable {
/// otherwise.
/// - `RestrictedDepthUpload`: unbounded: a depth uploaded outside `[0, 1]` is the device's, which
/// Vulkan does not define without `VK_EXT_depth_range_unrestricted`.
/// - `StencilOutputOverlap`: unbounded: a sample two fragments of one draw reach stores the OR of
/// their stencil outputs where Metal stores the later one, which moves any of its 8 bits.
/// - `CubeGradientFootprint`: unbounded: Apple's approximate length and truncated level against the
/// device's can select another level or filter near a boundary, which changes whole texels, not
/// lanes.
@@ -334,7 +336,8 @@ pub fn allowance(note: PrecisionNote) -> Allowance {
| N::DeviceFragmentRuns
| N::DeviceOcclusionCount
| N::VertexSimdgroupGrouping
| N::RestrictedDepthUpload => Allowance::Unbounded,
| N::RestrictedDepthUpload
| N::StencilOutputOverlap => Allowance::Unbounded,
}
}
@@ -90,6 +90,7 @@ fn every_precision_note_has_its_table_row() {
(N::DeviceOcclusionCount, Allowance::Unbounded),
(N::VertexSimdgroupGrouping, Allowance::Unbounded),
(N::RestrictedDepthUpload, Allowance::Unbounded),
(N::StencilOutputOverlap, Allowance::Unbounded),
];
for (note, expected) in rows {
assert_eq!(allowance(note), expected, "{note:?}");
+3
View File
@@ -899,6 +899,7 @@ codec_enum! {
IndirectSequence,
IndirectBase,
TextureLevelBase(f0),
StencilBit,
}
Symbol { Binding(f0), DescriptorSet(f0), Location(f0), Component(f0), SpecId(f0) }
}
@@ -1266,6 +1267,7 @@ codec_enum! {
AddressAlignment { slot, align },
GridTiles,
PrivateArena { slot_bytes },
StencilBitDraws,
}
Mechanism {
Specialization, Variant, PushConstant, DynamicState, DynamicStateOrPushConstant,
@@ -1446,6 +1448,7 @@ codec_enum! {
DeviceOcclusionCount,
VertexSimdgroupGrouping,
RestrictedDepthUpload,
StencilOutputOverlap,
}
BindingSource {
Buffer(f0), Texture(f0), Sampler(f0), CombinedTextureSampler { texture, sampler },
+2 -2
View File
@@ -60,7 +60,7 @@ mod tests;
/// unchanged version, and its bless records the version. Independent of the crate's version and of
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
/// history.
pub const SEMANTICS_VERSION: u32 = 2301;
pub const SEMANTICS_VERSION: u32 = 2302;
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
@@ -70,7 +70,7 @@ pub const SEMANTICS_VERSION: u32 = 2301;
/// re-typed in an encoded type, its `codec` body or its `envelope`. A variant removed while its tag
/// stays unused needs no bump: an entry holding it fails to decode, which is a miss. The commit that
/// bumps it says what changed; this comment keeps no history.
pub const ARTIFACT_FORMAT_VERSION: u32 = 595;
pub const ARTIFACT_FORMAT_VERSION: u32 = 596;
/// The version of what this crate gives a runtime for the runs of a compiled pipeline, beside the
/// compile: the device a run opens and what it enables, the Vulkan and Metal vocabularies a runtime
+16
View File
@@ -716,6 +716,22 @@ fn the_version_535_member_round_trips() {
assert_ne!(encode(&facts), encode(&KernelFacts::default()));
}
/// The members format version 596 appends encode and decode as themselves: a stencil output drawn
/// by bits, `PushField::StencilBit`, `RuntimeFact::StencilBitDraws` and
/// `PrecisionNote::StencilOutputOverlap`.
#[test]
fn the_version_596_members_round_trip() {
use crate::pipeline::artifact::PrecisionNote;
use crate::pipeline::facts::RuntimeFact;
use crate::pipeline::sym::PushField;
let field = PushField::StencilBit;
assert_eq!(decode::<PushField>(&encode(&field)), Ok(field));
let fact = RuntimeFact::StencilBitDraws;
assert_eq!(decode::<RuntimeFact>(&encode(&fact)), Ok(fact));
let note = PrecisionNote::StencilOutputOverlap;
assert_eq!(decode::<PrecisionNote>(&encode(&note)), Ok(note));
}
/// The members format versions 153, 154, 155, 157 and 161 joined from every side encode and
/// decode together in one render pipeline: `PrecisionNote::CubeGradientFootprint` and
/// `CombinedSampler`, `RuntimeFact::SrgbTexture` and
@@ -166,6 +166,9 @@ pub fn mechanism(fact: &RuntimeFact, profile: &DeviceProfile) -> Mechanism {
// The runtime pushes its arena's address, and sizes and orders the arena's slots by the
// slot's bytes.
RuntimeFact::PrivateArena { .. } => Mechanism::PushConstant,
// The consumer draws each draw once and then once per stencil bit its state can replace,
// pushing the bit for each.
RuntimeFact::StencilBitDraws => Mechanism::PushConstant,
// Keyed by the slots bound to a texture buffer of more texels than one view holds.
RuntimeFact::TexelBufferParts { .. } => Mechanism::Variant,
// The runtime refuses a dispatch whose slot address is not a multiple of the alignment.
@@ -200,6 +200,7 @@ fn every_fact() -> Vec<RuntimeFact> {
payload: None,
},
RuntimeFact::PrivateArena { slot_bytes: 28_704 },
RuntimeFact::StencilBitDraws,
]
}
@@ -294,6 +295,7 @@ fn variant(f: &RuntimeFact) -> usize {
RuntimeFact::AddressAlignment { .. } => 66,
RuntimeFact::GridTiles => 51,
RuntimeFact::PrivateArena { .. } => 70,
RuntimeFact::StencilBitDraws => 87,
}
}
@@ -301,7 +303,7 @@ fn variant(f: &RuntimeFact) -> usize {
fn mechanism_is_total_over_every_fact_and_profile() {
let facts = every_fact();
let covered: std::collections::BTreeSet<usize> = facts.iter().map(variant).collect();
assert_eq!(covered, (0..87).collect(), "every_fact misses a variant");
assert_eq!(covered, (0..88).collect(), "every_fact misses a variant");
for (stem, _) in super::committed_profiles() {
let dev = device(&stem);
let p = dev.profile();
@@ -424,7 +426,8 @@ fn mechanism_is_total_over_every_fact_and_profile() {
| RuntimeFact::StorageTextureIntegerChannels { .. }
| RuntimeFact::AccelerationStructureInstanceCount { .. }
| RuntimeFact::ViewportCount
| RuntimeFact::PrivateArena { .. } => Mechanism::PushConstant,
| RuntimeFact::PrivateArena { .. }
| RuntimeFact::StencilBitDraws => Mechanism::PushConstant,
RuntimeFact::AliasedImageblock { .. } => Mechanism::None,
RuntimeFact::CallStackDepth { .. } | RuntimeFact::OpenClMode => Mechanism::None,
};
+10 -2
View File
@@ -18,8 +18,12 @@
//! specialization constant (`RuntimeFact::SampleCount`, default 1), which the binder sets to the
//! pipeline's `rasterizationSamples`. A call with another operand is refused: no other operand's
//! meaning is established.
//! - **Stencil output**: a `[[stencil]]` output needs `VK_EXT_shader_stencil_export`
//! (`stage_io`), refused naming it on a device without the extension.
//! - **Stencil output**: a `[[stencil]]` output is `FragStencilRefEXT` where the device has
//! `VK_EXT_shader_stencil_export` (`stage_io`). Without it the function stores no reference and
//! keeps a fragment only where its output holds the bit the draw pushes, and the consumer draws
//! once per stencil bit (`RuntimeFact::StencilBitDraws`); a function whose returns cannot kill
//! (an interlocked body, a loop over the covered samples) refuses the output naming the
//! extension ([`finish`]).
//! - **Coverage at sample rate** (`coverage`): a function that reads `[[sample_mask]]` and that
//! Metal runs once per covered sample runs, compiled for a multisampled pipeline, once per pixel,
//! and its body once per covered sample from a loop over the pixel's coverage ([`wrap_entry`]),
@@ -269,6 +273,10 @@ pub fn finish(cx: &mut SelectCx<'_>, m: &mut Meter) -> Result<(), Error> {
fp.guarded = guarded;
fp.terminate_invocation = terminate;
fp.interlock = interlock;
// A stencil output drawn by bits kills at each return the fragments the draw does not keep.
if cx.families.stage_io.stencil_bits.is_some() && fp.return_kill().is_none() {
return Err(crate::lower::stage_io::stencil_export_refused());
}
Ok(())
}
+2 -2
View File
@@ -193,8 +193,8 @@ pub const fn shape(f: PushField) -> FieldShape {
// A draw's depth bias: its constant, slope and clamp as `f32`s' bits, and a zero word.
// Base vertex, base instance.
PushField::BaseVertexInstance => FieldShape::UVec2,
// The draw's vertices per primitive.
PushField::VerticesPerPrimitive => FieldShape::U32,
// The draw's vertices per primitive, and the stencil bit a draw keeps.
PushField::VerticesPerPrimitive | PushField::StencilBit => FieldShape::U32,
// A zero word, the index count, the first instance, and the base vertex.
PushField::CaptureLayout => FieldShape::UVec4Array(1),
// A constexpr sampler's index in its use's sampler array, and the sampled-texture array's
+4 -1
View File
@@ -1868,7 +1868,9 @@ fn identity_unsourced(f: &RuntimeFact) -> bool {
/// reference code a fragment function under the private alpha test compares with
/// (`PushField::AlphaTestReference`); the index of the sampled-texture array's element a
/// fragment function reads a colour attachment through (`PushField::FetchedColor`, framebuffer
/// fetch on a device with neither ordered form); the render pass's length, at or past which a
/// fetch on a device with neither ordered form); the stencil bit a fragment function whose
/// stencil output is drawn by bits keeps (`PushField::StencilBit`); the render pass's length, at
/// or past which a
/// vertex function that writes `[[render_target_array_index]]` stores `Layer` 0
/// (`PushField::RenderTargetArrayLength`); the address of the runtime's memory that holds a
/// kernel's private arena past the floor (`PushField::PrivateArenaAddress`); the draw's viewport
@@ -1916,6 +1918,7 @@ fn identity_refusal(plan: &Plan) -> Option<String> {
| PushField::VertexBufferStride(_)
| PushField::AlphaTestReference
| PushField::FetchedColor { .. }
| PushField::StencilBit
| PushField::RenderTargetArrayLength
| PushField::PrivateArenaAddress
| PushField::ViewportCount
+48 -1
View File
@@ -178,7 +178,8 @@ use crate::spirv::ir::{
};
pub(crate) use plan::{
amplification_count_form, finish_merged, note_device_point_size, view_index_enabled,
amplification_count_form, finish_merged, note_device_point_size, stencil_export_refused,
view_index_enabled,
};
pub use plan::{DrawBase, Link, Place, Shape};
@@ -434,6 +435,10 @@ pub struct StageIoPlan {
/// The render pipeline's private alpha test the fragment function runs at each return
/// (`LoweringInputs::alpha_test`).
pub alpha_test: Option<AlphaTest>,
/// A fragment function's `[[stencil]]` output on a device without stencil export
/// (`RuntimeFact::StencilBitDraws`): the field of a returned struct (0 for a returned value
/// itself) whose bit `PushField::StencilBit` each return tests ([`stencil_bit`]).
pub stencil_bits: Option<u32>,
/// The second outputs a fragment function writes for attachments held with their channels
/// rotated (`LoweringInputs::rotated_factors`), each beside its first output there.
pub rotated_seconds: Vec<RotatedSecond>,
@@ -1793,6 +1798,7 @@ pub fn emit_return(
let (outputs, returned, point) = (plan.outputs.clone(), plan.returned, plan.point_size_default);
let seconds = plan.rotated_seconds.clone();
let depth_clamp = plan.depth_clamp;
let stencil_bits = plan.stencil_bits;
let primitive_id = plan.primitive_id;
// The private masks: the pixel's ANDed into the function's own `[[sample_mask]]` output
// where this return stores one, else stored as that output.
@@ -1803,6 +1809,12 @@ pub fn emit_return(
let x = cx.operand(fb, v)?;
alpha_test(cx, fb, test, x, returned)?;
}
// The stencil output's bit, before any output is stored: a fragment the draw does not keep
// is killed.
if let (Some(v), Some(field)) = (v, stencil_bits) {
let x = cx.operand(fb, v)?;
stencil_bit(cx, fb, field, x, returned)?;
}
match (v, returned) {
(None, Returned::Void) => {}
(None, _) => return Err(cx.fail("an entry with outputs returns no value")),
@@ -2333,6 +2345,41 @@ fn alpha_test(
}
}
/// A fragment function's `[[stencil]]` output on a device without stencil export
/// (`RuntimeFact::StencilBitDraws`), field `field` of the returned `x`: where the draw's
/// `PushField::StencilBit` `k` is below 8 and bit `k` of the output is 0, the fragment is killed,
/// and at 8 or more every fragment is kept. The shift takes `k`'s low 3 bits, so no shift reaches
/// the value's width.
fn stencil_bit(
cx: &mut EmitCx<'_>,
fb: &mut FunctionBuilder<'_>,
field: u32,
x: SValue,
returned: Returned,
) -> BResult<()> {
let Some(form) = cx.plan.families.fragment.return_kill() else {
return Err(
cx.fail("a stencil output drawn by bits in a function whose returns cannot kill")
);
};
let value = match returned {
Returned::Struct => fb.composite_extract(x, &[field])?,
Returned::Value | Returned::Void => x,
};
let bit = cx.push_field(fb, PushField::StencilBit)?;
let low = u32_constant(fb, 7)?;
let shift = fb.binary(BinOp::BitwiseAnd, bit, low)?;
let shifted = fb.binary(BinOp::ShiftRightLogical, value, shift)?;
let one = u32_constant(fb, 1)?;
let held = fb.binary(BinOp::BitwiseAnd, shifted, one)?;
let zero = u32_constant(fb, 0)?;
let lacks = fb.binary(BinOp::IEqual, held, zero)?;
let eight = u32_constant(fb, 8)?;
let tested = fb.binary(BinOp::ULessThan, bit, eight)?;
let kill = fb.binary(BinOp::LogicalAnd, tested, lacks)?;
crate::lower::fragment::kill_if(fb, kill, form)
}
/// How the entry's returns drop a positive NaN depth, or `None` in a function looping over its
/// covered samples, where a kill would drop every sample's outputs.
fn nan_drop(cx: &mut EmitCx<'_>) -> BResult<Option<NanDrop>> {
+31 -7
View File
@@ -2094,16 +2094,19 @@ pub fn entry(cx: &mut SelectCx<'_>) -> Result<(), Error> {
if let OutputRole::ImageblockData(_) = &o.role {
return Err(Unsupported::not_implemented(Feature::Imageblocks).into());
}
// A stencil output needs stencil export.
// A stencil output on a device without stencil export is no output: each return keeps
// the fragment only where the output holds the bit the draw pushes, and the consumer
// draws once per stencil bit (`RuntimeFact::StencilBitDraws`).
if matches!(o.role, OutputRole::Stencil)
&& cx.stage == Stage::Fragment
&& !cx.profile.fields().fragment.stencil_export
{
return Err(Unsupported::needs(
Feature::StencilExport,
Capability::Extension(VkExtension::ExtShaderStencilExport),
)
.into());
int_scalar(io_form(cx, ty)?)?;
cx.families.stage_io.stencil_bits = Some(o.field);
cx.push.insert(PushField::StencilBit);
cx.facts.insert(RuntimeFact::StencilBitDraws);
cx.precision.insert(PrecisionNote::StencilOutputOverlap);
continue;
}
// An output to a color the pass lacks is stored nowhere, as plain Metal drops it: no
// output variable, so the pipeline writes no location without an attachment. So is one to a
@@ -2300,6 +2303,15 @@ pub fn entry(cx: &mut SelectCx<'_>) -> Result<(), Error> {
.map_err(|e| e.at_attachment(Attachment::Color(attachment)))?;
cx.families.stage_io.rotated_seconds.push(second);
}
// A stencil output drawn by bits runs the function once more for each bit, so a color it
// writes is written again: kept to one write only with blending and the logic operation off
// on every attachment and no color read, which is not built.
let sp = &cx.families.stage_io;
if sp.stencil_bits.is_some()
&& (sp.interface.outputs.iter()).any(|o| matches!(o.role, IoRole::Color { .. }))
{
return Err(stencil_export_refused());
}
// The indices a draw of one amplification stores though the function writes none: `Layer`
// in a pass of at least two layers, and `ViewportIndex` under mappings that offset the
// viewport, each the amplification's offset held below its count as an index the function
@@ -2827,7 +2839,7 @@ fn output(cx: &mut SelectCx<'_>, o: &OutputBinding, ty: AirTypeId) -> Result<Lin
cx.families.fragment.depth_output = true;
link
}
// A device without stencil export refuses the output (`entry`).
// A device without stencil export draws the output by bits (`entry`).
OutputRole::Stencil if !vertex && frag.stencil_export => {
let f = io_form(cx, ty)?;
int_scalar(f)?;
@@ -3000,6 +3012,18 @@ fn half_color(e: &crate::air::Entry, ty: AirTypeId) -> bool {
matches!(scalar, Some(Type::Half))
}
/// The refusal of a stencil output on a device without `VK_EXT_shader_stencil_export` where its
/// draws by bits (`RuntimeFact::StencilBitDraws`) do not give Metal's answer: a function that also
/// writes a color or memory, whose returns cannot kill a fragment, or of a pipeline whose draws do
/// not take the repeats (a mesh pipeline, one made for indirect command buffers).
pub(crate) fn stencil_export_refused() -> Error {
Unsupported::needs(
Feature::StencilExport,
Capability::Extension(VkExtension::ExtShaderStencilExport),
)
.into()
}
/// The refusal of a private alpha test the translation has not built (`PrivateRenderField`'s
/// `AlphaTest`): a fragment function under the test that writes no color 0, or one that is not
/// four `float` or `half` lanes.
@@ -2113,6 +2113,27 @@ pub enum PrecisionNote {
/// Validation derives no tolerance from it: a difference stays a mismatch, which the note
/// explains.
RestrictedDepthUpload,
/// A fragment function writes `[[stencil]]` on a device without
/// `VK_EXT_shader_stencil_export` (`RuntimeFact::StencilBitDraws`): each draw of its pipeline
/// is drawn once with a stencil reference of 0, which clears the stencil bits its
/// depth-stencil state can replace and runs its other stencil operations, then once for each
/// of those bits, keeping the fragments whose output has that bit and replacing it with 1,
/// and, where the draw writes depth under a depth compare other than always or never, once
/// more for the depth. Fragments of one draw that overlap leave the OR of their values: a
/// sample two fragments of one draw reach under `Replace` stores the bitwise OR of their
/// outputs' low 8 bits within the write mask, where Metal stores the later fragment's value.
/// On an RTX 3090 (NVIDIA 620.70.06), two triangles of one draw whose outputs are `0x35` and
/// then `0x4a` store `0x7f` where both reach, where Metal stores the later fragment's `0x4a`.
/// Under a depth test that writes, each fragment's stencil operation is also chosen against
/// the depth from before the draw, where Metal tests a later fragment against the depth an
/// earlier one wrote. A draw whose fragments cover each sample at most once (a quad of two
/// triangles, one fullscreen triangle) stores Metal's values.
/// Static per function: recorded on the fragment stage of every such function on every device
/// without the extension.
///
/// Validation derives no tolerance from it: a difference stays a mismatch, which the note
/// explains.
StencilOutputOverlap,
}
/// Which lowering strategies a module used, with their word costs.
@@ -58,6 +58,7 @@ use crate::pipeline::descriptor::{
LinkedFunctions, LinkedList, MeshPipelineDescriptor, RenderPipelineDescriptor,
VertexDescriptor,
};
use crate::pipeline::facts::RuntimeFact;
use crate::pipeline::interface::{SlotInterface, StageInterface};
use crate::pipeline::sym::{SlotClass, SlotRef, Stage, VaryingKey};
use crate::reflection;
@@ -3091,6 +3092,11 @@ fn lower_bounded<K>(
// The function's own side effects; the `ExecutionStatus` buffer's words (the resident-miss
// count's) are the product's.
let writes_memory = crate::spirv::requirements::writes_memory(&module)?;
// A stencil output drawn by bits runs the function once more for each bit, so its memory
// writes would be made again.
if writes_memory && plan.facts.contains(&RuntimeFact::StencilBitDraws) {
return Err(crate::lower::stage_io::stencil_export_refused());
}
// A fragment function's texture slots read only at the fragment's own pixel.
let own_pixel_textures = crate::spirv::requirements::own_pixel_textures(&module, m)?;
// The levels of its bound view each texture slot's reads reach.
@@ -541,6 +541,7 @@ impl Device {
}
None => None,
};
refuse_stencil_bits(fragment.as_ref())?;
let compiled: Vec<&CompiledFunction> = object
.iter()
.chain(std::iter::once(&mesh))
@@ -833,6 +834,9 @@ impl Device {
if let Some(f) = &fragment {
check_call_stack(f.artifact(), d.max_fragment_call_stack_depth)?;
}
if d.support_indirect_command_buffers {
refuse_stencil_bits(fragment.as_ref())?;
}
let compiled: Vec<&CompiledFunction> = std::iter::once(&vertex).chain(&fragment).collect();
let artifacts: Vec<&FunctionArtifact> = compiled.iter().map(|c| c.artifact()).collect();
let linked = link(&artifacts, &LinkInputs::render_variant(d, v), p)?;
@@ -1413,6 +1417,16 @@ fn check_open_cl_mode(a: &FunctionArtifact, given: bool) -> Result<(), Error> {
Ok(())
}
/// A fragment stage whose stencil output is drawn by bits (`RuntimeFact::StencilBitDraws`) in a
/// pipeline whose draws do not take the repeats, a mesh pipeline or one made for indirect command
/// buffers, refuses the output as a device without stencil export does (`Feature::StencilExport`).
fn refuse_stencil_bits(fragment: Option<&CompiledFunction>) -> Result<(), Error> {
match fragment.is_some_and(|f| (f.artifact().facts).contains(&RuntimeFact::StencilBitDraws)) {
true => Err(crate::lower::stage_io::stencil_export_refused()),
false => Ok(()),
}
}
/// The stage of artifact `a` has the call stack its pipeline's `maxCallStackDepth` for it,
/// `given`, sizes: a `Compiled` stage whose stack was sized for another depth is
/// `InvalidDescriptor(MaxCallStackDepth)` (a `Function` stage is compiled under `given`).
+17
View File
@@ -607,6 +607,22 @@ pub enum RuntimeFact {
/// them in its own slots' memory or ordered after the last one that used it. The kernel's own
/// bytes decide it, never a device fact.
PrivateArena { slot_bytes: u32 },
/// The fragment function writes `[[stencil]]` on a profile without
/// `VK_EXT_shader_stencil_export` (`FragmentCaps::stencil_export`): it stores no stencil
/// reference, and keeps a fragment only where its output's low 8 bits hold the bit
/// `PushField::StencilBit` names, every fragment at 8 or more. The consumer draws each draw of
/// its pipeline first at 8, under the draw's own depth-stencil state but a reference of 0 on
/// both faces; then at each bit `k` of the stencil write masks of the faces whose operations
/// include `Replace`, under a reference of 255, each face's write mask cut to bit `k`, its
/// `Replace` operations kept and its others `Keep`, and no depth write; and, where the state
/// writes depth under a compare other than `Always` and `Never`, the first draw writes none
/// and a last one at 8 writes it under stencil write masks of 0. Under a stencil compare of
/// `Always` or `Never` on both faces that stores Metal's values, but where fragments of one
/// draw meet at a sample (`PrecisionNote::StencilOutputOverlap`). The function writes no color
/// and no memory, and its pipeline is no mesh pipeline and is not made for indirect command
/// buffers, so each draw takes the repeats; anything else refuses the output
/// (`Feature::StencilExport`).
StencilBitDraws,
}
impl RuntimeFact {
@@ -703,6 +719,7 @@ impl RuntimeFact {
RuntimeFact::AddressAlignment { .. } => "AddressAlignment",
RuntimeFact::GridTiles => "GridTiles",
RuntimeFact::PrivateArena { .. } => "PrivateArena",
RuntimeFact::StencilBitDraws => "StencilBitDraws",
}
}
}
+5
View File
@@ -861,6 +861,11 @@ pub enum PushField {
/// Residual bind offset of a descriptor-form slot: the bind offset minus the descriptor base,
/// modulo 2^32.
SlotBindOffset(SlotRef),
/// The stencil bit a fragment function that writes `[[stencil]]` on a device without
/// `VK_EXT_shader_stencil_export` keeps its fragment for (`RuntimeFact::StencilBitDraws`): one
/// `u32`, `k`. Below 8 the function discards a fragment whose output's bit `k` is 0; at 8 or
/// more it keeps every fragment. Ordered before the slot addresses, as `FetchedColor` is.
StencilBit,
/// Under the identity domains, the element of the set-1 sampled-texture array
/// through which a fragment function reads color attachment `color` (`[[color(n)]]`): one
/// `u32`, the index of an element holding a 2D view of the attachment's level and slice
+185 -49
View File
@@ -1,21 +1,31 @@
//! A fragment function's `[[stencil]]` output end to end: the direct `FragStencilRefEXT` where the
//! device has stencil export, and elsewhere a refusal naming the extension, of the function and of
//! its render pipeline. The public fixture `fragment_depth_stencil` returns a depth and a stencil.
//! No GPU is used.
//! device has stencil export, and elsewhere the output drawn by bits
//! (`RuntimeFact::StencilBitDraws`): no stencil reference, the bit test against
//! `PushField::StencilBit`, the static note `PrecisionNote::StencilOutputOverlap`; and the
//! refusals naming the extension where draws by bits do not give Metal's answer: a function that
//! also writes a color or memory, a pipeline made for indirect command buffers, a mesh pipeline.
//! The public fixture `fragment_depth_stencil` returns a depth and a stencil; the engine fixture
//! `stx_stencil` and `stx_stencil_ms` hold a stencil alone, one beside memory writes, and one beside
//! a color. No GPU is used.
//!
//! `llvm-as` assembles the fixture; a missing tool skips visibly.
//! `llvm-as` assembles the fixtures; a missing tool skips visibly.
use crate::budget::Budget;
use crate::device::requirements::VkExtension;
use crate::device::{Device, DeviceDescription, DevicePolicy};
use crate::error::{Capability, Error, Feature, Needs};
use crate::library::Library;
use crate::library::{FunctionArtifact, Library};
use crate::metal::PixelFormat;
use crate::pipeline::descriptor::{FunctionDescriptor, RenderPipelineDescriptor, StageSource};
use crate::pipeline::descriptor::{
FunctionDescriptor, MeshPipelineDescriptor, RenderPipelineDescriptor, StageSource,
};
use crate::pipeline::facts::{Mechanism, RuntimeFact};
use crate::pipeline::stage_io::StageBuiltin;
use crate::pipeline::sym::PushField;
use crate::pipeline::testing::{
compile, engine_dir, fixtures_dir, link_and_validate, llvm_assemble, AssembleError,
};
use crate::pipeline::{PrecisionNote, RuntimeDependency};
use crate::spirv::testing::committed_profiles;
fn assemble(path: &std::path::Path) -> Option<Vec<u8>> {
@@ -45,81 +55,207 @@ fn needs_export() -> (Feature, Needs) {
)
}
/// Whether `result` is the refusal naming the extension.
fn refused<T>(result: Result<T, Error>, what: &str) {
match result {
Err(Error::Unsupported(u)) => assert_eq!((u.feature, u.needs), needs_export(), "{what}"),
Err(other) => panic!("{what}: {other}"),
Ok(_) => panic!("{what}: not refused"),
}
}
/// The stencil output drawn by bits: no stencil reference stored, the fact and the bit's push
/// field stated, and the note recorded.
fn assert_drawn_by_bits(a: &FunctionArtifact, what: &str) {
assert!(
!a.interface.io.builtins.contains(&StageBuiltin::StencilRef),
"{what}: {:?}",
a.interface.io.builtins
);
assert!(
a.facts.contains(&RuntimeFact::StencilBitDraws),
"{what}: {:?}",
a.facts
);
let pushed = (a.interface.push.fields.iter()).any(|f| f.field == PushField::StencilBit);
assert!(pushed, "{what}: {:?}", a.interface.push);
assert!(
a.precision.contains(&PrecisionNote::StencilOutputOverlap),
"{what}: {:?}",
a.precision
);
}
/// On every committed profile the output is the direct `FragStencilRefEXT` where the device has
/// stencil export, the module passing L3, and is otherwise refused naming the extension alone.
/// stencil export, and is drawn by bits elsewhere, the module passing L3 in both forms.
#[test]
fn the_stencil_output_takes_the_extension_or_a_refusal_naming_it() {
fn the_stencil_output_takes_the_extension_or_draws_by_bits() {
let Some(bc) = stencil_fixture() else {
return;
};
// [exported, refused]
// [exported, by bits]
let mut forms = [0usize; 2];
for (stem, p) in committed_profiles().expect("profiles") {
let result = compile(&bc, ENTRY, &p);
let a = compile(&bc, ENTRY, &p).unwrap_or_else(|e| panic!("{stem}: {e}"));
if p.fields().fragment.stencil_export {
forms[0] += 1;
let a = result.unwrap_or_else(|e| panic!("{stem}: {e}"));
assert!(
a.interface.io.builtins.contains(&StageBuiltin::StencilRef),
"{stem}: {:?}",
a.interface.io.builtins
);
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{stem}: L3: {e}"));
assert!(!a.facts.contains(&RuntimeFact::StencilBitDraws), "{stem}");
assert!(
!a.precision.contains(&PrecisionNote::StencilOutputOverlap),
"{stem}"
);
} else {
forms[1] += 1;
match result {
Err(Error::Unsupported(u)) => {
assert_eq!((u.feature, u.needs), needs_export(), "{stem}")
}
other => panic!("{stem}: {:?}", other.map(|_| ())),
}
assert_drawn_by_bits(&a, &stem);
}
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{stem}: L3: {e}"));
}
// The committed profiles cover each kind of device.
assert!(forms.iter().all(|&n| n > 0), "{forms:?}");
}
/// The device of committed profile `stem` under `policy`.
fn device(stem: &str, policy: DevicePolicy) -> Device {
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join(format!("../metal2vulkan-validation/profiles/{stem}.json"));
let text = std::fs::read_to_string(path).expect("profile");
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
Device::from_queries(desc, policy).expect("device")
}
fn function(bc: &[u8], name: &str) -> StageSource {
StageSource::Function(FunctionDescriptor::new(
Library::from_air(bc)
.expect("library")
.function(name)
.expect("function"),
))
}
/// A render pipeline of `stage_io_vertex_position` and the fixture's fragment, on a device without
/// stencil export (`nvidia-rtx50-linux`), is refused naming the extension, with a combined
/// depth/stencil attachment and without one, at one sample and at four.
/// stencil export (`nvidia-rtx50-linux`), under the runtime's identity domains and the resident
/// tables, with a combined depth/stencil attachment and without one, at one sample and at four:
/// made, its fragment stage depending on `StencilBitDraws` through a push field and noting the
/// overlap; and refused naming the extension where it is made for indirect command buffers.
#[test]
fn a_render_pipeline_without_stencil_export_is_refused_naming_it() {
fn a_render_pipeline_without_stencil_export_draws_the_output_by_bits() {
let (Some(io), Some(stencil)) = (
assemble(&engine_dir().join("stage_io.ll")),
stencil_fixture(),
) else {
return;
};
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../metal2vulkan-validation/profiles/nvidia-rtx50-linux.json");
let text = std::fs::read_to_string(path).expect("profile");
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
let dev = Device::from_queries(desc, DevicePolicy::RESIDENT_TABLES).expect("device");
assert!(!dev.profile().fields().fragment.stencil_export);
let function = |bc: &[u8], name: &str| {
StageSource::Function(FunctionDescriptor::new(
Library::from_air(bc)
.expect("library")
.function(name)
.expect("function"),
))
};
for attached in [true, false] {
for samples in [1, 4] {
let mut d = RenderPipelineDescriptor::new(function(&io, "stage_io_vertex_position"));
d.fragment = Some(function(&stencil, ENTRY));
if attached {
d.depth_format = Some(PixelFormat::Depth32FloatStencil8);
d.stencil_format = Some(PixelFormat::Depth32FloatStencil8);
}
d.raster_sample_count = samples;
let what = format!("attached {attached}, {samples} samples");
match dev.compile_render_pipeline(&d, &Budget::standard()) {
Err(Error::Unsupported(u)) => {
assert_eq!((u.feature, u.needs), needs_export(), "{what}")
for policy in [DevicePolicy::default(), DevicePolicy::RESIDENT_TABLES] {
let dev = device("nvidia-rtx50-linux", policy);
assert!(!dev.profile().fields().fragment.stencil_export);
for attached in [true, false] {
for samples in [1, 4] {
let mut d =
RenderPipelineDescriptor::new(function(&io, "stage_io_vertex_position"));
d.fragment = Some(function(&stencil, ENTRY));
if attached {
d.depth_format = Some(PixelFormat::Depth32FloatStencil8);
d.stencil_format = Some(PixelFormat::Depth32FloatStencil8);
}
other => panic!("{what}: {:?}", other.map(|_| ())),
d.raster_sample_count = samples;
let what = format!("{policy:?}, attached {attached}, {samples} samples");
let pipeline = dev
.compile_render_pipeline(&d, &Budget::standard())
.unwrap_or_else(|e| panic!("{what}: {e}"));
let bits =
RuntimeDependency::new(RuntimeFact::StencilBitDraws, Mechanism::PushConstant);
assert!(pipeline.dependencies.contains(&bits), "{what}");
let notes = &pipeline.stages[1].precision_notes;
assert!(
notes.contains(&PrecisionNote::StencilOutputOverlap),
"{what}"
);
d.support_indirect_command_buffers = true;
refused(
dev.compile_render_pipeline(&d, &Budget::standard()),
&format!("{what}, made for indirect command buffers"),
);
}
}
}
}
/// Without stencil export, a function that writes its stencil and a color
/// (`stx_stencil_ms_color`), and one that writes its stencil and memory (`stx_stencil_in_order`),
/// refuse the output naming the extension; one that writes its stencil alone
/// (`stx_stencil_by_pixel`), one beside its depth (`stx_stencil_with_depth`) and one that discards
/// (`stx_stencil_discard`) draw it by bits.
#[test]
fn without_stencil_export_a_function_that_writes_a_color_or_memory_refuses_the_output() {
let (Some(stx), Some(ms)) = (
assemble(&engine_dir().join("stx_stencil.ll")),
assemble(&engine_dir().join("stx_stencil_ms.ll")),
) else {
return;
};
let mut seen = 0;
for (stem, p) in committed_profiles().expect("profiles") {
if p.fields().fragment.stencil_export {
continue;
}
seen += 1;
refused(
compile(&ms, "stx_stencil_ms_color", &p),
&format!("{stem}: a color"),
);
let memory = compile(&stx, "stx_stencil_in_order", &p);
if p.fields().fragment.pixel_interlock {
refused(memory, &format!("{stem}: memory"));
} else {
// The function's raster order group is refused first, without the interlock.
match memory {
Err(Error::Unsupported(u)) => {
assert_eq!(u.feature, Feature::RasterOrderGroups, "{stem}: memory")
}
Err(other) => panic!("{stem}: memory: {other}"),
Ok(_) => panic!("{stem}: memory: not refused"),
}
}
for entry in [
"stx_stencil_by_pixel",
"stx_stencil_with_depth",
"stx_stencil_discard",
] {
let what = format!("{stem}: {entry}");
let a = compile(&stx, entry, &p).unwrap_or_else(|e| panic!("{what}: {e}"));
assert_drawn_by_bits(&a, &what);
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
}
}
assert!(seen > 0, "no committed profile lacks stencil export");
}
/// A mesh pipeline whose fragment function writes its stencil, on a device with mesh shading and
/// without stencil export, refuses the output naming the extension.
#[test]
fn without_stencil_export_a_mesh_pipeline_refuses_the_output() {
let (Some(outputs), Some(stx)) = (
super::engine_mesh::fixture("mesh_outputs"),
assemble(&engine_dir().join("stx_stencil.ll")),
) else {
return;
};
let mut seen = 0;
for (stem, p) in super::engine_mesh::mesh_profiles() {
if p.fields().fragment.stencil_export {
continue;
}
seen += 1;
let dev = device(&stem, DevicePolicy::RESIDENT_TABLES);
let mut d = MeshPipelineDescriptor::new(function(&outputs, "mesh_outputs_points"));
d.fragment = Some(function(&stx, "stx_stencil_by_pixel"));
d.stencil_format = Some(PixelFormat::Stencil8);
refused(dev.compile_mesh_pipeline(&d, &Budget::standard()), &stem);
}
assert!(seen > 0, "no mesh profile lacks stencil export");
}
@@ -1567,6 +1567,7 @@ field metal2vulkan-runtime::Metrics.staging_buffer_allocations pub staging_buffe
field metal2vulkan-runtime::Metrics.staging_region_allocations pub staging_region_allocations: SiteAllocations
field metal2vulkan-runtime::Metrics.staging_sleeps pub staging_sleeps: u64
field metal2vulkan-runtime::Metrics.stamps_not_available pub stamps_not_available: u64
field metal2vulkan-runtime::Metrics.stencil_bit_draws pub stencil_bit_draws: u64
field metal2vulkan-runtime::Metrics.submissions pub submissions: u64
field metal2vulkan-runtime::Metrics.submissions_during_frees pub submissions_during_frees: u64
field metal2vulkan-runtime::Metrics.submit_call_max_nanos pub submit_call_max_nanos: u64
@@ -8376,6 +8377,7 @@ variant metal2vulkan-runtime::DrawKind::FetchedAttachment FetchedAttachment
variant metal2vulkan-runtime::DrawKind::FillMode FillMode
variant metal2vulkan-runtime::DrawKind::LineWidth LineWidth
variant metal2vulkan-runtime::DrawKind::PatchIndexBuffer PatchIndexBuffer
variant metal2vulkan-runtime::DrawKind::StencilOutput StencilOutput
variant metal2vulkan-runtime::DrawKind::Viewport Viewport
variant metal2vulkan-runtime::DrawKind::Viewports Viewports
variant metal2vulkan-runtime::DrawKind::VisibilityResultInterrupt VisibilityResultInterrupt
@@ -8575,6 +8577,7 @@ variant metal2vulkan-runtime::PrecisionNote::SimdgroupAccessOrder SimdgroupAcces
variant metal2vulkan-runtime::PrecisionNote::SnormMinimumKept SnormMinimumKept
variant metal2vulkan-runtime::PrecisionNote::SparseResidency SparseResidency
variant metal2vulkan-runtime::PrecisionNote::SrgbTexelDecode SrgbTexelDecode
variant metal2vulkan-runtime::PrecisionNote::StencilOutputOverlap StencilOutputOverlap
variant metal2vulkan-runtime::PrecisionNote::SwizzledOpaqueBlackBorder SwizzledOpaqueBlackBorder
variant metal2vulkan-runtime::PrecisionNote::TessellationFactorEdgeCases TessellationFactorEdgeCases
variant metal2vulkan-runtime::PrecisionNote::TessellationFactorInstance TessellationFactorInstance
@@ -9893,6 +9896,7 @@ variant metal2vulkan::pipeline::PrecisionNote::SimdgroupAccessOrder SimdgroupAcc
variant metal2vulkan::pipeline::PrecisionNote::SnormMinimumKept SnormMinimumKept
variant metal2vulkan::pipeline::PrecisionNote::SparseResidency SparseResidency
variant metal2vulkan::pipeline::PrecisionNote::SrgbTexelDecode SrgbTexelDecode
variant metal2vulkan::pipeline::PrecisionNote::StencilOutputOverlap StencilOutputOverlap
variant metal2vulkan::pipeline::PrecisionNote::SwizzledOpaqueBlackBorder SwizzledOpaqueBlackBorder
variant metal2vulkan::pipeline::PrecisionNote::TessellationFactorEdgeCases TessellationFactorEdgeCases
variant metal2vulkan::pipeline::PrecisionNote::TessellationFactorInstance TessellationFactorInstance
@@ -9939,6 +9943,7 @@ variant metal2vulkan::pipeline::PushField::SlotBounds SlotBounds(SlotRef)
variant metal2vulkan::pipeline::PushField::SlotGuestBase SlotGuestBase(SlotRef)
variant metal2vulkan::pipeline::PushField::StageInRegion StageInRegion
variant metal2vulkan::pipeline::PushField::StageInStride StageInStride(u32)
variant metal2vulkan::pipeline::PushField::StencilBit StencilBit
variant metal2vulkan::pipeline::PushField::TailWord TailWord
variant metal2vulkan::pipeline::PushField::TessellationFactorAddress TessellationFactorAddress
variant metal2vulkan::pipeline::PushField::TessellationFactorInstanceStride TessellationFactorInstanceStride
@@ -10036,6 +10041,7 @@ variant metal2vulkan::pipeline::RuntimeFact::SparseTextureWrites SparseTextureWr
variant metal2vulkan::pipeline::RuntimeFact::SrgbTexture SrgbTexture { slot: SlotRef }
variant metal2vulkan::pipeline::RuntimeFact::StageInRegion StageInRegion
variant metal2vulkan::pipeline::RuntimeFact::StageInStride StageInStride { layout: u32 }
variant metal2vulkan::pipeline::RuntimeFact::StencilBitDraws StencilBitDraws
variant metal2vulkan::pipeline::RuntimeFact::StorageTextureFormat StorageTextureFormat { slot: SlotRef }
variant metal2vulkan::pipeline::RuntimeFact::StorageTextureIntegerChannels StorageTextureIntegerChannels { slot: SlotRef }
variant metal2vulkan::pipeline::RuntimeFact::StorageTextureLevelViews StorageTextureLevelViews { slot: SlotRef }
Can't render this file because it is too large.
+27 -1
View File
@@ -938,7 +938,13 @@ Where Metal's rules differ from Vulkan's, the pipeline gives Metal's answer:
its channels rotated. A raster order group on a color input, or on a color output of an
attachment the function reads, orders that read alone and takes no interlock; a group on
anything else needs the pixel interlock (`Unsupported{RasterOrderGroups}`). A `[[stencil]]` output uses
`VK_EXT_shader_stencil_export`; a device without it refuses the function
`VK_EXT_shader_stencil_export`; on a device without it the function discards a fragment whose
output lacks the bit its push field names (`PushField::StencilBit`, every fragment kept at 8 or
more) and states `RuntimeFact::StencilBitDraws`: the runtime draws each draw once and then once
for each bit its depth-stencil state can replace (`metal2vulkan-degrade-stencil-output-overlap`).
There a function that also writes a color or memory, one whose returns cannot discard (an
interlocked body, a loop over its covered samples), a mesh pipeline and a pipeline made for
indirect command buffers refuse the output
(`Unsupported{StencilExport}` naming the extension).
- `[[barycentric_coord]]` reads `BaryCoordKHR` or `BaryCoordNoPerspKHR`, whose vertex order is
Vulkan's first-vertex order and Metal's for every primitive type. A `float3` read takes the
@@ -1931,6 +1937,26 @@ bound.
of these copies. Cost: a depth uploaded outside `[0, 1]` is the device's, and so is every read,
sample, comparison and copy of it; one within it is copied exactly, except a denormal or
`-0.0`, which a device may store as `+0.0` (`metal2vulkan-degrade-depth-denormals`).
- `metal2vulkan-degrade-stencil-output-overlap` (precision).
`PrecisionNote::StencilOutputOverlap`: A fragment function that writes `[[stencil]]`, on a
device without `VK_EXT_shader_stencil_export`, recorded on its fragment stage on every such
device (`RuntimeFact::StencilBitDraws`). `metal2vulkan-runtime` draws each draw of its pipeline
once with a stencil reference of 0, which clears the stencil bits its depth-stencil state can
replace and runs its other stencil operations, then once for each of those bits (the low 8 of
the write masks of the faces that replace), keeping the fragments whose output holds that bit,
under the reference 255, that bit's write mask, `Replace` kept and every other operation
`Keep`, and no depth write; and, where the draw writes depth under a depth compare other than
always or never, once more for the depth, with stencil write masks of 0, the first draw then
writing none. Cost: fragments of one draw that overlap leave the OR of their values. Where two
fragments of one draw reach one sample under `Replace`, the sample stores the bitwise OR of
their outputs' low 8 bits within the write mask, where Metal stores the later fragment's value.
Measured on an RTX 3090 (NVIDIA 620.70.06) under the validation layer: two triangles of one
draw whose outputs are `0x35` and then `0x4a` store `0x7f` on the 32 texels both reach, where
Metal stores the later fragment's `0x4a`, and `0x35` on the 32 that one reaches. Under a depth
test that writes, each fragment's stencil operation is also chosen against the depth from
before the draw, where Metal tests a later fragment against the depth an earlier one wrote. A
draw whose fragments reach each sample at most once (a quad of two triangles, one fullscreen
triangle) stores Metal's values.
- `metal2vulkan-degrade-cube-gradient-footprint` (precision).
`PrecisionNote::CubeGradientFootprint`: An explicit-gradient sample of a cube texture takes
Metal's footprint in the form Vulkan's rule reads, in every stage on every device. Cost: the
+2 -2
View File
@@ -116,7 +116,7 @@ Columns:
| `ClipDistance` | Clip or cull distances | devices without VkFeature::ShaderClipDistance; devices without VkLimit::MaxClipDistances | `device` | 2: `crates/metal2vulkan/src/lower/mesh/mod.rs (select, 2 sites)` | `rare`: clip distances on a device without them |
| `DualSourceBlending` | Dual-source blending | devices without VkFeature::DualSrcBlend; devices without VkLimit::MaxFragmentDualSrcAttachments | `device` | 3: `crates/metal2vulkan/src/metal/state.rs (blend_factor)`, `crates/metal2vulkan/src/pipeline/link/graphics.rs (check_outputs)` (+1) | `rare`: dual-source blending on a device without it |
| `Barycentrics` | Barycentric coordinates | devices without VkFeature::FragmentShaderBarycentric | `device` | 2: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)` | `rare`: barycentric coordinates |
| `StencilExport` | Stencil export | devices without VkExtension::ExtShaderStencilExport | `device` | 1: `crates/metal2vulkan/src/lower/stage_io/plan.rs (entry)` | `rare`: stencil from the shader |
| `StencilExport` | Stencil export | devices without VkExtension::ExtShaderStencilExport | `device` | 1: `crates/metal2vulkan/src/lower/stage_io/plan.rs (stencil_export_refused)` | `rare`: stencil from the shader |
| `SampleRateShading` | Per-sample shading | devices without VkFeature::SampleRateShading; devices without a capability the site computes (`needs`); every device (not implemented) | `ours` | 3: `crates/metal2vulkan/src/pipeline/link/graphics.rs (sample_invocations, 3 sites)` | `rare`: per-sample shading |
| `PullModelInterpolation` | Metal's pull-model interpolation (`interpolant` fragment inputs and their `interpolate_at_center`, `_centroid`, `_sample` and `_offset` functions)... | devices without VkProperty::InterpolateAtOffsetCentered; devices without VkProperty::InterpolateAtOffsetFromSevenSixteenths; devices without a capability the site computes (`lacks`); every device (not implemented) | `ours` | 5: `crates/metal2vulkan/src/lower/fragment/interpolate.rs (select, 2 sites)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (interpolant, 2 sites)` (+1) | `rare`: interpolant inputs read at the centroid, a sample or an offset |
| `DivergentInterpolation` | Metal's pull-model interpolation at a sample or an offset (`interpolate_at_sample`, `interpolate_at_offset`) outside the fragment function's first... | every device (not implemented) | `ours` | 1: `crates/metal2vulkan/src/lower/stage_io/plan.rs (interpolant_reads)` | `rare`: an interpolant read at a sample or an offset in a branch, a loop or after a discard |
@@ -439,7 +439,7 @@ Each refusal's sites, with the function that builds it.
- `feature::ClipDistance`: `crates/metal2vulkan/src/lower/mesh/mod.rs (select, 2 sites)`
- `feature::DualSourceBlending`: `crates/metal2vulkan/src/metal/state.rs (blend_factor)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (check_outputs)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (rotated_blend)`
- `feature::Barycentrics`: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)`
- `feature::StencilExport`: `crates/metal2vulkan/src/lower/stage_io/plan.rs (entry)`
- `feature::StencilExport`: `crates/metal2vulkan/src/lower/stage_io/plan.rs (stencil_export_refused)`
- `feature::SampleRateShading`: `crates/metal2vulkan/src/pipeline/link/graphics.rs (sample_invocations, 3 sites)`
- `feature::PullModelInterpolation`: `crates/metal2vulkan/src/lower/fragment/interpolate.rs (select, 2 sites)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (interpolant, 2 sites)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (interpolant_reads)`
- `feature::DivergentInterpolation`: `crates/metal2vulkan/src/lower/stage_io/plan.rs (interpolant_reads)`