Improve handling of `Access` expressions whose base is an array or
matrix (not a pointer to such), and whose index is not known at
compile time. SPIR-V does not have instructions that can do this
directly, so spill such values to temporary variables, and perform the
accesses using `OpAccessChain` instructions applied to the
temporaries.
When performing chains of accesses like `a[i].x[j]`, do not reify
intermediate values; generate a single `OpAccessChain` for the entire
thing.
Remove special cases for arrays; the same code now handles arrays and
matrices.
Update validation to permit dynamic indexing of matrices.
For details, see the comments on the new tracking structures in
`naga:🔙:spv::Function`.
Add snapshot test `index-by-value.wgsl`.
Fixes#6358.
Fixes#4337.
Alternative to #6362.
Bring https://github.com/gfx-rs/naga/pull/723 back from the dead.
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
Co-authored-by: Jim Blandy <jimb@red-bean.com>
When a label in a WGSL front end error has an undefined span, omit the
label from the error message. This is not great, but because of the
way Naga IR represents local variable references it is hard to get the
right span, and omitting the label better than panicking in `unwrap`,
since the error message has a general message anyway.
When reporting errors in construction expressions, use the span of the
constructor itself (that is, the type name) in preference to the span
of the overall expression. This makes errors easier to follow.
When a constructor builtin has an explicit type parameter, like
`mat2x2<f32>`, it should not produce an abstract matrix, even if its
arguments are abstract.