Wgsl: index array w/ varlable?

If we look at Fixed-Size Arrays | Tour of WGSL it apperas it is okay to index n array with a variable, example:

fn get_two_fibs(i: u32, j: u32) -> array<i32,2> {
   // This constructor infers the element type and element count.
   return array(first_fibs[i], first_fibs[j]);

however, in rust / wgpu I get the following error:

panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_shader_module
      note: label = `Shader`
Shader validation error: 
   ┌─ Shader:72:17
72 │     var idx = ((idxs [ i32(face_idx) ]) >> vert_idx) % 8;
   │                 ^^^^^^^^^^^^^^^^^^^^^^ naga::Expression [30]

    Entry point vs_main at Vertex is invalid
    Expression [30] is invalid
    The expression [27] may only be indexed by a constant

Is this a problem with wgpu-0.16.1, or is this a wgsl limitation ?

Hmm, seems like I am not the only one having this issue:

Nasty. I thought it might be something like the *_NON_UNIFORM_INDEXING features, which you need for eg texture arrays, but that's more annoying.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.