gfx-rs/wgpu · error

{:?} is not enabled for this backend

Error message

{:?} is not enabled for this backend

What it means

The WebGPU (browser) backend's map_primitive_state panics when a render pipeline requests PolygonMode::Line, because the browser WebGPU API has no line polygon mode. This mode is gated behind the POLYGON_MODE_LINE feature, which this backend cannot support.

Source

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

    mapped.set_front_face(map_front_face(primitive.front_face));

    if let Some(format) = primitive.strip_index_format {
        mapped.set_strip_index_format(map_index_format(format));
    }

    mapped.set_topology(match primitive.topology {
        PrimitiveTopology::PointList => pt::PointList,
        PrimitiveTopology::LineList => pt::LineList,
        PrimitiveTopology::LineStrip => pt::LineStrip,
        PrimitiveTopology::TriangleList => pt::TriangleList,
        PrimitiveTopology::TriangleStrip => pt::TriangleStrip,
    });

    mapped.set_unclipped_depth(primitive.unclipped_depth);

    match primitive.polygon_mode {
        wgt::PolygonMode::Fill => {}
        wgt::PolygonMode::Line => panic!(
            "{:?} is not enabled for this backend",
            wgt::Features::POLYGON_MODE_LINE
        ),
        wgt::PolygonMode::Point => panic!(
            "{:?} is not enabled for this backend",
            wgt::Features::POLYGON_MODE_POINT
        ),
    }

    mapped
}

fn map_compare_function(compare_fn: wgt::CompareFunction) -> webgpu_sys::GpuCompareFunction {
    use webgpu_sys::GpuCompareFunction as cf;
    use wgt::CompareFunction;
    match compare_fn {
        CompareFunction::Never => cf::Never,
        CompareFunction::Less => cf::Less,

View on GitHub (pinned to 3e11ff59bf)

Solutions

  1. Use PolygonMode::Fill on web, or emulate wireframes with index buffers / a geometry technique.
  2. Gate the pipeline: check adapter features for POLYGON_MODE_LINE and choose Fill when absent.
  3. Build a wireframe variant of the mesh (edge list) instead of relying on polygon mode.

Example fix

// before
let mut primitive = wgpu::PrimitiveState::default();
primitive.polygon_mode = wgpu::PolygonMode::Line;
// after
let polygon_mode = if device.features().contains(wgpu::Features::POLYGON_MODE_LINE) {
    wgpu::PolygonMode::Line
} else {
    wgpu::PolygonMode::Fill
};
primitive.polygon_mode = polygon_mode;
Defensive patterns

Strategy: fallback

Validate before calling

let line_mode = device.features().contains(wgpu::Features::POLYGON_MODE_LINE);
let polygon_mode = if line_mode { wgpu::PolygonMode::Line } else { wgpu::PolygonMode::Fill };

Prevention

When it happens

Trigger: Creating a render pipeline with primitive.polygon_mode = PolygonMode::Line through a device backed by the web (WebGPU) backend.

Common situations: Sharing pipeline descriptors between native (Vulkan/Metal, which support line mode behind a feature) and web builds; porting a wireframe-rendering native app to wasm.

Related errors


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