gfx-rs/wgpu · error

not implemented

Error message

not implemented

What it means

The MSL backend's built-in writer hits `unimplemented!()` for the `PointIndex`, `LineIndices`, and `TriangleIndices` built-ins, meaning naga cannot yet translate a shader that references these vertex-stage built-ins to Metal Shading Language. This is an unimplemented-feature panic in the backend, not a validation error in the shader.

Source

Thrown at naga/src/back/msl/mod.rs:688

                    Bi::SampleMask => "sample_mask",
                    // compute
                    Bi::GlobalInvocationId => "thread_position_in_grid",
                    Bi::LocalInvocationId => "thread_position_in_threadgroup",
                    Bi::LocalInvocationIndex => "thread_index_in_threadgroup",
                    Bi::WorkGroupId => "threadgroup_position_in_grid",
                    Bi::WorkGroupSize => "dispatch_threads_per_threadgroup",
                    Bi::NumWorkGroups => "threadgroups_per_grid",
                    // subgroup
                    Bi::NumSubgroups => "simdgroups_per_threadgroup",
                    Bi::SubgroupId => "simdgroup_index_in_threadgroup",
                    Bi::SubgroupSize => "threads_per_simdgroup",
                    Bi::SubgroupInvocationId => "thread_index_in_simdgroup",
                    Bi::CullDistance | Bi::DrawIndex => {
                        return Err(Error::UnsupportedBuiltIn(built_in))
                    }
                    Bi::CullPrimitive => "primitive_culled",
                    // TODO: figure out how to make this written as a function call
                    Bi::PointIndex | Bi::LineIndices | Bi::TriangleIndices => unimplemented!(),
                    // These aren't real builtins passed into MSL. They are extracted by the
                    // wrapper function which actually sets the outputs.
                    Bi::MeshTaskSize
                    | Bi::VertexCount
                    | Bi::PrimitiveCount
                    | Bi::Vertices
                    | Bi::Primitives
                    | Bi::RayInvocationId
                    | Bi::NumRayInvocations
                    | Bi::InstanceCustomData
                    | Bi::GeometryIndex
                    | Bi::WorldRayOrigin
                    | Bi::WorldRayDirection
                    | Bi::ObjectRayOrigin
                    | Bi::ObjectRayDirection
                    | Bi::RayTmin
                    | Bi::RayTCurrentMax
                    | Bi::ObjectToWorld

View on GitHub (pinned to 3e11ff59bf)

Solutions

  1. Restructure the shader to avoid these built-ins — pass point/primitive indices via vertex attributes or a storage buffer instead
  2. Use `draw_indexed` with an index buffer so the vertex stage only needs `vertex_index`/`instance_index`
  3. Track/file an issue on naga for MSL support of PointIndex/LineIndices/TriangleIndices and use another backend (Vulkan/DX12) meanwhile

Example fix

// before (WGSL vertex shader)
fn vs(@builtin(point_index) pi: u32) -> VSOut { ... }
// after
struct VSIn { @location(0) point_id: u32 }
fn vs(in_: VSIn, @builtin(vertex_index) vi: u32) -> VSOut { ... } // pass index as attribute/buffer
Defensive patterns

Strategy: fallback

Try / catch

match naga::msl::compile_string(..., options) {
    Err(naga::Error::...) | panic-prone unimplemented => fall back to another backend or shader variant,
}

Prevention

When it happens

Trigger: Compiling (via naga or wgpu on Metal) a WGSL/GLSL vertex shader that reads `builtin(point_index)`, `builtin(line_indices)`, or `builtin(triangle_indices)` — i.e. using non-indexed point/line-list topology inputs in the vertex stage.

Common situations: Porting a Vulkan/GL renderer that uses gl_VertexID-style point rendering or primitive-restart line/triangle indices directly in the vertex shader to Metal via wgpu; the TODO notes MSL has no direct builtin for these and they would need wrapper-function extraction that is not yet implemented.

Related errors


AI-assisted analysis of gfx-rs/wgpu@3e11ff59bf (2026-09-03). Data as JSON: /api/errors/b5e742b2fe06ae1f. Report an issue: GitHub.