Metal's shading language leaves a primitive whose vertices write different indices undefined:
"You must return the same value of [[render_target_array_index]] for every vertex in a primitive.
If values differ, the behavior and value passed to the fragment function are undefined." The same
sentence covers [[viewport_array_index]]. The selected index store answered that case with the
first vertex's index, through the synthesized geometry stages, and MoltenVK's profile could take
DriverDeviation::MetalFirstVertexIndices to store it as written. Both reproduced undefined Metal.
The runtime never reached either: it enables no geometryShader, and no profile takes the
deviation.
After this change every profile has one form. An index that the function's structure shows to be
the same at every vertex of a primitive is stored to Layer or ViewportIndex where
shaderOutputLayer or shaderOutputViewportIndex is enabled. Without that feature it is refused as
Unsupported(LayeredRendering), or as Unsupported(VertexAmplification) for an index the
amplification's offset alone sets. The refusal needs the output feature only; geometryShader is
no longer offered. An index not shown the same is refused as NotImplemented(LayeredRendering) on
every device. index_store's comment cites the two spec sentences as the reason for that refusal.
It cites Vulkan's same-value rule (VUID-VkPipelineShaderStageCreateInfo-stage-02596 for Layer,
-02597 for ViewportIndex) as the reason the index is not stored as written. A device without
multiViewport still stores no viewport index.
Removed:
- IndexStore::Selected, indices_selected, selected_index;
- StageIoPlan::indices_selected and first_vertex_indices_by_device, and the compile layer's
requirement;
- IoRole::SelectedLayer and SelectedViewport, with their codec tags;
- VaryingKey::selected_layer and selected_viewport, with their key tags;
- GeometryStages::layer and viewport, the stages' Layer and ViewportIndex stores, and the
Reason's index half;
- RuntimeFact::SynthesizedGeometry's layer and viewport fields;
- DriverDeviation::MetalFirstVertexIndices, its last variant, and with it the DriverDeviation type
and DeviceProfile::takes_driver_deviation;
- VkProperty::MetalFirstVertexIndices and its codec tag.
The geometry stages keep the barycentric weights and the fan-out. A fan-out stage past the
geometry limits is now refused as RasterizationRateMap needing the limit. Before, it was refused
as LayeredRendering with an empty alternative, because the stage's reason held neither weights
nor an index.
Rule 1: no note stops being raised. The first-vertex form raised none. The input it served is now
a typed refusal, so no difference goes silent. The catalogue is unchanged.
The command line: no code there names a removed item. Translating a vertex function whose index
is not shown the same now prints FALLBACK (NotImplemented LayeredRendering) on a geometryShader
profile, where before it compiled with the stages. Validation: four authored cases compiled on
every profile-leg but moltenvk-m3 through the stages: 07f125464dac, 434e73e03189, 7ce6dea0475e
and a013a2bcbe56. On moltenvk-m3 they were refused needing geometryShader. They are now refused
on every leg; the authored compile census takes them at the next named pin, not in this change.
The coverage census test that read three geometry stages from engine/rt6_first_vertex now reads
them from engine/bary_weights on the 780M profile without fragmentShaderBarycentric.
Fixture: engine/vertex_amplification's amp_vertex and amp_vertex_layer now take their viewport
and slice from the instance (iid & 1) instead of the vertex (vid & 1). The amplification and
render-target-slice tests then still compile them, and engine/rt6_first_vertex carries the
per-vertex case. The fixture was regenerated by scripts/regen-air-fixtures (Apple metal
32023.922, llvm-dis 21.1.8).
Tests:
- engine_selected_indices becomes engine_target_indices, covering:
- a uniform slice or viewport takes the output or nothing else;
- no multiViewport stores nothing;
- per-vertex indices are refused on every device;
- the floor's zero reads;
- the weights' stage beside a vertex Layer is not implemented.
- link/tests/geometry.rs loses its two selected-index tests.
- engine_amplification, engine_render_target_slice and engine_stage_io now expect the builtin and
the output-only refusal.
- runtime-floor now requires shaderOutputLayer, so the tests that need a device without it
withhold the feature from the floor's description (engine_target_indices, engine_amplification,
engine_stage_io).
Bless due until the next named pin, where the M3 bless job takes them; nothing is blessed here:
- tests::air_input::engine_fixtures_match_their_golden_printout: vertex_amplification's printout;
- tests::public_fixtures_engine (the inventory):
- rt6_first_vertex and rt6_first_vertex_point become NotImplemented(LayeredRendering) on every
profile;
- amp_vertex and amp_vertex_layer become ok on moltenvk-m3;
- each LayeredRendering cell that offered GeometryShader loses that alternative;
- tests::golden_hashes, and pipeline::compile::tests::the_old_render_descriptor_key_keeps_its_value
(the render key): the profiles' fingerprints change with VkProperty's codec;
- the authored compile census.
SEMANTICS_VERSION 2245 -> 2246 and ARTIFACT_FORMAT_VERSION 582 -> 583.
SEMANTICS: an index store changes form. ARTIFACT: the codec loses two IoRole tags, a VkProperty tag
and two RuntimeFact fields. RUNTIME_VERSION stays; runtime-sources.sha256 takes the new hash, and
api_signatures is blessed. docs/REFUSALS.md is regenerated. The runtime README's known gap for a
differing index names the refusal as not implemented and drops the geometry stage form. API.md's
layered-rendering bullet, its RenderPipeline stage list and its profile accessors, and
ARCHITECTURE.md's link line drop the selected index.
Consumer check (consumer_check.sh, consumer development b76d6ac4a9):
- MetalFirstVertexIndices, SelectedLayer, SelectedViewport, selected_layer, selected_viewport,
SynthesizedGeometry, driver_deviations and DriverDeviation: 0 hits.
- GeometryStages and takes_driver_deviation: in crates/reims-vgpu-c/link-order.txt only.
- DriverDeviation and takes_driver_deviation are named in crates/reims-vgpu-vulkan/src/gpu/rgbx.rs
and encode_render/tests/metal_tests.rs on some of the consumer's steelbrain/* branches, for
MetalSampler, MetalHalfConversion and MetalVertexSimdgroups, which the stack below already
removed. development has neither file.
Verified (jobs read):
- m3-max-61766: lint in every configuration and the suites at this change on the earlier stack
(eeef281428); its reds were the bless-due goldens above.
- At the stack's tip over this change (dvl-5 1fa4aed963 and dvl-6 92fe40c38f): 61978 and 61987,
fmt, clippy in every configuration, Rustdoc, each feature alone, the API docs and the Windows
clippy, green; 61891, the suites at dvl-4: 13 failures, each a bless-due golden above or
development's own (the raster state test, the inventory's sample_fill rows); 61968, the lavapipe
device suite of metal2vulkan-validation, 1483 of 1483.
- m3-max-62042: the metal2vulkan-validation suite at dvl-5, 1378 of 1378 passed.
- States-only play of this change's player (p-si.zst) over the 36 streams on um870 (61909),
gem10 (61912), ms01 (61958), um790 (61990) and msi (62045): 502,920 render and 108,189 compute
states made, 0 refused, every stream exit 0.