The error messages of wgsl scripts are very cryptic. I'm struggling to figure out what this thing is upset with.
Here's my attempt to write a function:
fn extract_unsigned(word: u32, width: u32, offset: u32) -> f32 {
var element = (word >> offset) & (!0 >> (32u - width));
return f32(element);
}
And here's my error.
2022-11-22T07:06:53.000595Z ERROR naga::valid::expression: Left: Binary { op: ShiftRight, left: [17], right: [19] } of type Scalar { kind: Uint, width: 4 }
2022-11-22T07:06:53.000610Z ERROR naga::valid::expression: Right: Binary { op: ShiftRight, left: [22], right: [24] } of type Scalar { kind: Sint, width: 4 }
2022-11-22T07:06:53.000654Z ERROR bevy_render::render_resource::pipeline_cache: failed to process shader:
error: Function [7] 'extract_unsigned' is invalid
┌─ wgsl:214:1
│
214 │ ╭ fn extract_unsigned(word: u32, width: u32, offset: u32) -> f32 {
215 │ │ var element = (word >> offset) & (!0 >> (32u - width));
│ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ naga::Expression [26]
216 │ │ return f32(element);
│ ╰────────────────────────^ naga::Function [7]
│
= Expression [26] is invalid
= Operation And can't work with [20] and [25]
I seem to have three errors here.
Let's start with the first. Is this thing upset with my bit shift operations? They seem pretty normal to me.