Some SPIR-V texture access instructions take coordinates as integers, others as
floats. The types of coordinates in Naga expressions generally match those in
SPIR-V, but Naga indices for arrayed textures are always integers, whereas
SPIR-V combines coordinates and array indices into a single vector, so indices
need to be cast to match the coordinate component type.
This commit makes `write_texture_coordinates` properly cast array indices to
match the coordinates' component type before combining them all into a single
result vector.
Fixes#1186.
* Proof of concept for "span" feature, with WGSL parsing augmented.
* Review:
1) add_span was actually a bad idea, make it set_span and add
set_span_if_unknown too.
2) panics on getting/setting span for invalid handles.
3) only set span for constants with a name
4) don't overwrite spans for types.
* Added spans to blocks & more expressions getting spans in frontends.
Definitely the shotgunny type of commit, but what can you do. The design
I went with made spans mandatory to specify, so I had to go and wire
them through wherever I could.
* Moved Block to a separate module, +clippy
* More spans for types in GLSL.
* Remove pointless body method.
* Make Arena interface require spans.
Another shotgun commit, oh boy...
* Fix tests.
My loathsome habit to "quickly fix things along the way" made a lot of
extra work for me here, having to fix my "fixes" for WGSL parser.
* Rustfmt + clippy.
* Fix compile-errors with span feature enabled.
* Nuked set_span* from orbit. Deleting code feels great!
* Code review - move feature flags inside functions.
* Fix build with "deserialize" feature enabled.
In `back::spv::Writer::write_texture_coordinates`, OpCompositeConstruct can
concatenate scalars and vectors, so when combining coordinates with an array
index, there is no need to extract the coordinate vector's components
individually: once the index has been converted to the appropriate component
type, it can be combined with the coordinates in a single instruction.
The new api allows for reuse while keeping some allocations and to
please the borrow checker in future work, it also splits the parser into
logical modules to make it easier to work on.
Glsl defines that if a matrix constructor is called with only a scalar
it's result will be the matrix where the scalar is used if the row and
column are equal and everywhere else a zero
Glsl allows things such as
```glsl
layout (location = 0) in vec4 a;
vec4 b = a;
```
In this case `b` depends on `a` which can't be known at compile time,
so it's necessary to add a small prologue to the entry point to
initialize it.