Files
metal2vulkan/scripts
Anees Iqbal 0d1a32436b vertex input under the identity domains: every attribute in fixed function, no pulled form
Planner ruling 11-18 (final): fixed-function vertex input for every attribute on every device,
the form native Vulkan uses and the fastest measured on every device, one form. Nothing of the
pulled form is taken on Device::from_queries' profile. Before this, the translator's
containment rule (contain::encoding is Check::InShader without buffer robustness) moved every
[[stage_in]] attribute into the shader, a form that reads through a descriptor the identity
domains refuse, so every rt render state with a vertex descriptor was refused as
Unsupported(IdentityDomains).

Translator (metal::vertex::fetch_as, pipeline::link::vertex::resolve), under the identity domains
only (lower::access::identity), so Device::new's profile and the old runtime are unchanged:
- the containment rule no longer moves an attribute: the device bounds the fetch as it bounds
  any (no buffer robustness: a fetch outside its buffer reads what the device gives);
- an unnormalized signed-integer format (Char*, Short*, Int*) is fetched in fixed function into
  a variable declared int, VertexFetch::SignedFixedFunction (new): Vulkan's numeric-type match
  lets a SINT format feed only a signed variable, and the device sign-extends as Metal does. The
  module reads the variable's bits by OpBitcast. Elsewhere such an attribute is still pulled and
  sign-extended in the shader;
- every case that pulled is a typed refusal by what it needs, never a second fetch form.

Metal's vertex descriptor on the rt floor:
- Maps directly:
  - formats: every Metal vertex format to the Vulkan format of its layout and conversion, by the
    device's VERTEX_BUFFER format query. 8/16-bit integer formats read into float attributes go
    through USCALED/SSCALED, signed integer formats into int variables, UChar4Normalized_BGRA is
    B8G8R8A8_UNORM, the 10:10:10:2 formats are A2B10G10R10, and FloatRG11B10 is
    B10G11R11_UFLOAT_PACK32. The validation crate's profiles of RADV (780M x2, RDNA3), ANV (Iris
    Xe, UHD 770), NVIDIA (Pascal, RTX 50) and lavapipe report VERTEX_BUFFER for all of them but
    FloatRGB9E5;
  - steps: PerVertex is VERTEX rate; PerInstance at rate 1 is INSTANCE rate;
  - offsets and strides: the descriptor's, baked into the VkPipeline.
- No fixed-function equivalent on the floor, so a typed refusal:
  - PerInstance rate > 1 and Constant: Unsupported{VertexStepRate}, by query. They need
    VK_KHR_vertex_attribute_divisor's vertexAttributeInstanceRateDivisor (plus ZeroDivisor for
    Constant) and supportsNonZeroFirstInstance, which the floor does not enable, so it is
    refused on every rt device today. Its needs name the missing feature, or the
    maxVertexAttribDivisor limit;
  - a format the device does not report for VERTEX_BUFFER: Unsupported{Format} with that format
    usage, by query;
  - FloatRGB9E5: Unsupported{Format}, not implemented, by need. Of the profiles above only
    lavapipe's reports it, and its fetch answers 0 for the fourth component, where Metal and
    Vulkan give 1;
  - an offset or stride off the format's component alignment (Metal takes any byte multiple on
    Apple5+), and an offset, stride, attribute count or layout count past
    maxVertexInputAttributeOffset, maxVertexInputBindingStride, maxVertexInputAttributes or
    maxVertexInputBindings: Unsupported{VertexInputLayout}, with the limit where one is passed;
  - PerPatch and PerPatchControlPoint: Unsupported{Tessellation}, as before.

rt: RenderPipelineKind::StepRate is deleted: the translator's VertexStepRate refusal comes first
on every rt device, so no pipeline states a divisor. README: the vertex input bullets, their
refusals, and the known gap that a vertex fetch outside its buffer returns what the device gives.
docs/API.md: the identity domains' vertex input. REFUSALS.md regenerated, with reach marks for the
two new features (VertexStepRate app, VertexInputLayout rare); api_signatures blessed.

Tests:
- engine_identity_render from_queries_fetches_every_attribute_in_fixed_function (lavapipe and
  moltenvk-m3 profiles with buffer robustness and the divisor withheld): ima_vertex's float2
  and short attributes are R32G32_SFLOAT and R16_SINT, nothing pulled, L3-valid; a rate-2 layout
  is VertexStepRate needing vertexAttributeInstanceRateDivisor. It fails without this commit (the
  attributes were pulled, then refused as IdentityDomains);
- rt draw every_device_fetches_a_signed_attribute_in_fixed_function: a short of -2 reaches the
  fragment's uint output as 0xFFFFFFFE on every texel; a rate-2 layout is refused as
  VertexStepRate. The existing stage-in test (vertex buffer and set_vertex_bytes) now makes its
  pipeline.

Verified: the next lint job and the device legs on every device.
2026-11-18 03:13:48 -08:00
..