Compound assignments on wgsl follow the same semantics as their
underlying operation, this includes the splatting behavior when mixing
scalar and vector operands, which was done for binary operations but not
for compound assignments.
Previously the wgsl frontend wasn't aware of lexical scopes causing all
variables and named expressions to share a single function scope, this
meant that if a variable was defined in a block with the same name as a
variable in the function body, the variable in the function body would
be lost and exiting the block all references to the variable in the
function body would be replaced with the variable of the block.
This commit fixes that by using the previously introduced `SymbolTable`
to track the lexical and perform the variable lookups, scopes are pushed
and popped as defined in the wgsl specification.
The Vulkan decoration rules require us to distinguish vertex shader
inputs, fragment shader inputs, and everything else, so just pass the
stage to `Writer::write_varying`. Together with the SPIRV storage
class, this is sufficient to distinguish all the cases in a way that
closely follows the spec language.
Previously, if a local variable was declared with a constant value, we
would elide the store and instead give the variable an initial value (as
if it was a global variable). This caused variables to not be
re-initialized each time through a loop.
Adds parsing support for methods on the glsl frontend, while `.length` is the only method in the base extensions, there might be more in extensions.
Adds support for the `.length` method and tests for it.
Improves the dot backend output by:
- Linking new nodes to the end of other blocks, instead of the beginning
- Generating merge nodes for conditional statements
- Generating connections from break/continue nodes to their target
- Introducing a "cfg only" mode that only generates statements
* Make some (currently hacky) changes to enable multiview in webgl
* Fix ViewIndex built in for this extension
* Run cargo fmt, fix tests
* Allow specifying if we're targetting webgl in the glsl version
* Document multiview2 extension
* fn embedded -> const fn embedded
* Fix tests
* Fix benches
* Add snapshot tests
* Revamp so that the glsl options have some multiview options. Also add tests
* Make clippy happier
* Go back to having is_webgl be part of Version
* Use wgsl as input for tests
* Rename Version::new_embedded to Version::new_gles, fix glsl validation
* Run cargo fmt
* Fix brand new clippy warnings
* [hlsl-out] fix matCx2 as global uniform
* [hlsl-out] update comments
* [hlsl-out] fix `row_major` not being written on global arrays of matrices and also write it on nested arrays of matrices
* [hlsl-out] fix matCx2's nested inside global arrays
* [hlsl-out] fix struct members of type array<matCx2>
* [hlsl-out] test mat2x4 to make sure our matCx2 code behaves properly
Require at least version 0.7.1 of ron, this version changed how floating points are
serialized by forcing them to always have the decimal part, this makes it backwards
incompatible with our tests because we do a syntatic diff and not a semantic one.
GLSL allows the last case of a switch statement to not have a `break`
statement causing it to be marked as fall-trough, naga's IR on the other
hand doesn't allow the last case to be fall-trough, this is fixed by
force marking it in the glsl frontend as not fall-trough.
GLSL also allows empty switch statements and without default cases,
naga's IR requires there be a default case, this is fixed by adding an
empty default case in the glsl frontend if no default case was present
in the switch statement.
Glsl defines two overloads for smoothstep that accept `min` and `max` as
scalars and the value as a vector, naga's IR is stricter and only allows
operators with the same dimensions, so this inputs must be splatted.
Introduce a new `TypeFlags::CONSTRUCTIBLE` flag, corresponding to
WGSL's "constructible types". Set this on the appropriate types.
Check for this flag on function return types.
The previous check compared rows to rows and columns to columns but
multiplication of matrices only needs the columns of the left matrix to
be equal to the rows of the right matrix.
* glsl-out: Implement bounds checks for `ImageLoad`
* Enable image bounds check snapshot tests for GLSL.
In addition to the snapshot.rs changes, this entails adding an entry
point function to `bounds-check-image-restrict.wgsl` and
`bounds-check-image-rzsw.wgsl`, including appropriate data in the
param.ron files.
* Apply comments
Snapshot test changes:
Co-authored-by: Jim Blandy <jimb@red-bean.com>
The new `check_one_validation` macro permits the source code to be a
computed expression, not just a string literal. This also cleans up
some of the handling of the optional guard expression.
* [hlsl-out] add padding at the end of structs and after struct members of type matrix and array (when necessary)
* use wrapped constructor fn for constants
* add array as fn arg test
* fix glsl array fn arg
* add wrapped constructor for arrays
* [glsl-out] support multidimensional arrays
* address comments
* hlsl-out: don't output interpolation modifier if it's the default (linear/`Interpolation::Perspective`)
* Remove linear interpolation modifiers from HLSL output tests
* add support for zero value constructors and constructors that infer their type from their parameters
* address comments
* extract constructor machinery into new module
* fix doc link