gfx-rs / naga

Universal shader translation in Rust

Home Page:https://github.com/gfx-rs/wgpu/tree/trunk/naga

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

extractBits unimplemented

Brad-Hesson opened this issue · comments

Got the following error during compilation using WGPU

2023-06-01T22:10:20.973603Z ERROR wgpu::backend::direct: Shader translation error for stage ShaderStages(NONE | VERTEX): HLSL: Unimplemented("write_expr_math ExtractBits")
2023-06-01T22:10:20.973856Z ERROR wgpu::backend::direct: Please report it to https://github.com/gfx-rs/naga
2023-06-01T22:10:20.974506Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default
thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_render_pipeline
      note: label = `Render Pipeline`
    Internal error in ShaderStages(NONE | VERTEX) shader: HLSL: Unimplemented("write_expr_math ExtractBits")

'

This is the code:

@vertex
fn vs_main(
    vertex: VertexInput,
    @location(2) instance: u32,
    @location(3) color: u32
) -> VertexOutput {
    var coords = vec2<f32>(hilbert_decode(instance, N));
    coords = coords / f32(1u << 16u) * 2. - 1.;
    var pos = vertex.position.xy;
    pos = pos / f32(1u << 16u) + coords;
    pos += pan_zoom.pan;
    pos *= pan_zoom.zoom;
    var out: VertexOutput;
    out.color = vec4<f32>(
        f32(extractBits(color, 0u, 8u)),
        f32(extractBits(color, 8u, 8u)),
        f32(extractBits(color, 16u, 8u)),
        f32(extractBits(color, 24u, 8u))
    );
    out.clip_position = vec4<f32>(pos, 1., 1.0);
    return out;
}

Duplicate of #1929
Will be solved by #2353

my bad, should've searched harder for an existing issue. Thanks

No worries at all! Would much rather too many issues get filled than we miss an issue.