gfx-rs/wgpu · error

Feature `MESH_SHADING` not enabled

Error message

Feature `MESH_SHADING` not enabled

What it means

ExecuteMeshIndirectCount on the DX12 backend requires a pre-created mesh command signature, which wgpu-hal only creates when the experimental MESH_SHADING feature is enabled. If the signature is absent the backend panics rather than silently doing nothing. This indicates a wgpu-core/hal invariant breach: a mesh draw was issued on a device without mesh shading enabled.

Source

Thrown at wgpu-hal/src/dx12/command.rs:1624

                draw_count,
                &buffer.resource,
                offset,
                None,
                0,
            )
        }
    }
    unsafe fn draw_mesh_tasks_indirect(
        &mut self,
        buffer: &<Self::A as crate::Api>::Buffer,
        offset: wgt::BufferAddress,
        draw_count: u32,
    ) {
        self.prepare_dispatch([0; 3]);
        let cmd_list6: Direct3D12::ID3D12GraphicsCommandList6 =
            self.list.as_ref().unwrap().cast().unwrap();
        let Some(cmd_signature) = &self.shared.cmd_signatures.draw_mesh else {
            panic!("Feature `MESH_SHADING` not enabled");
        };
        unsafe {
            cmd_list6.ExecuteIndirect(cmd_signature, draw_count, &buffer.resource, offset, None, 0);
        }
    }
    unsafe fn draw_indirect_count(
        &mut self,
        buffer: &super::Buffer,
        offset: wgt::BufferAddress,
        count_buffer: &super::Buffer,
        count_offset: wgt::BufferAddress,
        max_count: u32,
    ) {
        unsafe { self.prepare_draw(0, 0) };
        unsafe {
            self.list.as_ref().unwrap().ExecuteIndirect(
                &self.shared.cmd_signatures.draw,
                max_count,

View on GitHub (pinned to 3e11ff59bf)

Solutions

  1. Request Features::MESH_SHADING in DeviceDescriptor::required_features when creating the device.
  2. Verify the adapter supports mesh shading via adapter.features() before using mesh draw calls.
  3. Guard mesh draw calls behind a runtime check of device.features().contains(Features::MESH_SHADING).
  4. This is a usage error surfacing a wgpu bug if wgpu-core validation let it through; consider filing an issue after confirming feature requests.

Example fix

// before
encoder.draw_mesh_indirect_count(&mesh_buf, 0, &count_buf, 0, n);
// after
assert!(device.features().contains(wgpu::Features::MESH_SHADING));
encoder.draw_mesh_indirect_count(&mesh_buf, 0, &count_buf, 0, n);
Defensive patterns

Strategy: validation

Validate before calling

fn can_mesh_shading(device: &wgpu::Device) -> bool {
    device.features().contains(wgpu::Features::MESH_SHADING)
}

Type guard

fn require_mesh_shading(device: &wgpu::Device) -> Result<&wgpu::Device, String> {
    if device.features().contains(wgpu::Features::MESH_SHADING) { Ok(device) }
    else { Err("MESH_SHADING not enabled".into()) }
}

Prevention

When it happens

Trigger: Calling CommandEncoder::draw_mesh_indirect_count (or internal hal draw_mesh_indirect_count) on a device whose features do not include Features::MESH_SHADING; submitting a recorded encoder created before enabling mesh shading.

Common situations: Using the experimental mesh shading API without adding Features::MESH_SHADING to DeviceDescriptor::required_features; running on an adapter that lacks mesh shading support so the feature was not granted; DX12 backend where cmd_signatures.draw_mesh was never initialized.

Related errors


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