brendan-duncan / wgsl_reflect

A WebGPU Shading Language parser and reflection library for Javascript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for inferred typed arrays

greggman opened this issue · comments

the current version doesn't like this style of array declaration

  @vertex fn vs(@builtin(vertex_index) vertexIndex : u32) -> @builtin(position) vec4f {
    let pos = array(
      vec2f( 0.0,  0.5),  // top center
      vec2f(-0.5, -0.5),  // bottom left
      vec2f( 0.5, -0.5)   // bottom right
    );

    return vec4f(pos[vertexIndex], 0.0, 1.0);
  }

array works as a constructor if all the arguments are of the same type so in the case above, the type of pos is inferred as array<vec2<f32>, 3>. I'm not sure wgsl_reflect has to figure that out but it probably needs to parse the expression.

I'll get this added.

Made it at least not error parsing. I still need to have it update the reflection info for inferred arrays, but I don't think inferred arrays would be used in a place that needs reflection info.

thanks Brendan!