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.
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.
* Resurrect texture_storage_* tests
* Test parsing of `var<storage,write>`
* Default storage textures to READ
* Restore default features
* Fix glsl/hlsl/msl/spv front and back ends
* Add missing test outputs
* All-around fixes for the storage access
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
* Hack in support for PrimitiveID on Vulkan
* Rename to PrimitiveIndex and add preliminary support for GLSL, HLSL and MSL
* Implement as an extra WGSL built-in
* Update extra.wgsl outputs
* Run rustfmt; fix WGSL writer
* Add rustfmt changes I forgot
* Update extra.wgsl test output for WGSL fix
* Bump macOS version to 10.15 in validate-msl to support primitive_index