gfx-rs/wgpu · error

VERTEX_ATTRIBUTE_64BIT feature must be enabled to use Double

Error message

VERTEX_ATTRIBUTE_64BIT feature must be enabled to use Double formats

What it means

The WebGPU (browser) backend's map_vertex_format panics when a vertex buffer layout uses a Float64* VertexFormat, since WebGPU has no double-precision vertex attributes. These formats require the VERTEX_ATTRIBUTE_64BIT feature, which the browser backend does not support.

Source

Thrown at wgpu/src/backend/webgpu.rs:595

        VertexFormat::Float32 => vf::Float32,
        VertexFormat::Float32x2 => vf::Float32x2,
        VertexFormat::Float32x3 => vf::Float32x3,
        VertexFormat::Float32x4 => vf::Float32x4,
        VertexFormat::Uint32 => vf::Uint32,
        VertexFormat::Uint32x2 => vf::Uint32x2,
        VertexFormat::Uint32x3 => vf::Uint32x3,
        VertexFormat::Uint32x4 => vf::Uint32x4,
        VertexFormat::Sint32 => vf::Sint32,
        VertexFormat::Sint32x2 => vf::Sint32x2,
        VertexFormat::Sint32x3 => vf::Sint32x3,
        VertexFormat::Sint32x4 => vf::Sint32x4,
        VertexFormat::Unorm10_10_10_2 => vf::Unorm1010102,
        VertexFormat::Unorm8x4Bgra => vf::Unorm8x4Bgra,
        VertexFormat::Float64
        | VertexFormat::Float64x2
        | VertexFormat::Float64x3
        | VertexFormat::Float64x4 => {
            panic!("VERTEX_ATTRIBUTE_64BIT feature must be enabled to use Double formats")
        }
    }
}

fn map_vertex_step_mode(mode: wgt::VertexStepMode) -> webgpu_sys::GpuVertexStepMode {
    use webgpu_sys::GpuVertexStepMode as sm;
    use wgt::VertexStepMode;
    match mode {
        VertexStepMode::Vertex => sm::Vertex,
        VertexStepMode::Instance => sm::Instance,
    }
}

fn map_extent_3d(extent: wgt::Extent3d) -> webgpu_sys::GpuExtent3dDict {
    let mapped = webgpu_sys::GpuExtent3dDict::new(extent.width);
    mapped.set_height(extent.height);
    mapped.set_depth_or_array_layers(extent.depth_or_array_layers);
    mapped

View on GitHub (pinned to 3e11ff59bf)

Solutions

  1. Convert the vertex data to f32 formats (Float32, Float32x2, ...) before upload.
  2. Pack doubles into two u32 attributes and reassemble in the shader if precision is required.
  3. Keep the 64-bit path behind a check of Features::VERTEX_ATTRIBUTE_64BIT and provide an f32 fallback layout for web.

Example fix

// before
attributes: &[wgpu::VertexAttribute { format: wgpu::VertexFormat::Float64x3, offset: 0, shader_location: 0 }]
// after
attributes: &[wgpu::VertexAttribute { format: wgpu::VertexFormat::Float32x3, offset: 0, shader_location: 0 }]
Defensive patterns

Strategy: validation

Validate before calling

let uses_f64 = layout.attributes.iter().any(|a| matches!(a.format,
    wgpu::VertexFormat::Float64 | wgpu::VertexFormat::Float64x2
    | wgpu::VertexFormat::Float64x3 | wgpu::VertexFormat::Float64x4));
if uses_f64 && !device.features().contains(wgpu::Features::VERTEX_ATTRIBUTE_64BIT) {
    return Err("f64 vertex attributes unsupported on this backend; convert to f32".into());
}

Type guard

fn uses_f64_attributes(layout: &wgpu::VertexBufferLayout) -> bool {
    layout.attributes.iter().any(|a| matches!(a.format,
        wgpu::VertexFormat::Float64 | wgpu::VertexFormat::Float64x2
        | wgpu::VertexFormat::Float64x3 | wgpu::VertexFormat::Float64x4))
}

Prevention

When it happens

Trigger: Creating a render pipeline whose vertex attribute shader_location uses VertexFormat::Float64/Float64x2/Float64x3/Float64x4 on a web-backed device.

Common situations: Reusing native vertex layouts (f64 positions, simulation data) in a wasm build; scientific/geometry data pipelines ported from Vulkan without converting attributes to f32.

Related errors


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