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
- samplerCubeShadow requires vec3 gradients
- Bias must be written after offset
- sampler1D hack on GLES requires vec2 gradients
- textureSize doesn't accept a lod argument for MS samplers
- sampler1DArray hack on GLES requires a y component on imageLoad
This one grew out of hand quick. Initially it was just replacing the bit
loops with a function driving the declarations to make the code sharing
better and support different scalar kinds.
Now it includes a lot of fixes:
- `textureSize` now also returns the array layers as the last component
on the return (only for arrayed textures)
- `textureSize` now supports multisampled textures
- the `texture` family of functions now consumes a `vec3` coordinate
vector for all 1D shadow textures
- Shadow textures can use the bias version of `texture` functions
(temporarily disabled since naga doesn't support it)
- 3D textures can be used in `textureProj`
- `sampler2DArrayShadow` can't be used in `textureLod` or in `texture` with bias
- Cube textures cannot be used with offsets
Updates the tests to cover all functions
The _buffer_sizes argument should be inserted regardless of whether or not `
`options.fake_missing_bindings` is set, so lift the computation of
`supports_array_length` out of that conditional.
The previous implementation had many issues, most importantly it didn't
allow to implement (at least in a sane way) some future features like
default qualifiers and format qualifiers.
This implementations centralizes the qualifiers into a struct with a
hashmap for layout qualifiers, error reporting is also centralized which
means that `add_global_var` and `add_local_var` no longer need to
duplicate effort and the ugly loop + match combo is gone.
Finally some minor fixes are also done as part of this rework, like
a default location being provided for input/outputs variables and layout
qualifiers being allowed to be repeated (overwriting the previous one)
like the spec defines.
* Allow vecN<i32> and vecN<u32> in `dot()`, first changes
* Added a test case
* Fix the test
* Changes to baking of expressions, incl args of integer dot product
* Implemented requested changes for glsl backend
* Added support for integer dot product on MSL backend
* Removed outdated code for hlsl and wgls writers
* Implement in spv backend
* Commit modified outputs from running the tests
* cargo fmt
* Applied requested changes for both MSL and GLSL back
* Changes to spv back
* Committed all test output changes
* Cargo fmt
* Added a comment w.r.t. VK_KHR_shader_integer_dot_product
* Implemented requested svp change
* Minor change to test case
This is because I wanted to highlight the fact that the correct
id is used in the last sum of the integer dot product expression
* Changed function signature
since it could not fail, changed it to simply return `void`
* Rewrite front/back doc summaries
- Use line comments instead of block comments
- Standardize language for each front/backend
- Add reference link for each format
- Minor punctuation changes
* Add documentation for keywords module
* Clarify contents of keywords module in summary
* Refer to modules by their type name
* Add basic summary for valid module
* Adjust EarlyDepthTest and ConservativeDepth docs
* Remove "in" from list
* Adjust wording
* Standardize format of docstrings
* Adjust module links to be consistent with other links
* Add summary for reserved keywords list
* Remove extraneous doc spaces with `cargo fmt`
* Correct spelling of whether and rewrite some lines
* Fill out GLSL backend docs
* Remove unnecessary link targets
* Fill out DOT backend docs
* Change module line comments to block comments
* Remove unnecessary spaces
* Fix mistake during rebasing
* WGSL storage address space should always correspond to MSL device address space.
See MSL spec section 4.2.
* Update baselines
* Add error for storage address space if MSL version < 2.
* Update default MSL version to 2.0.
Fixes#1642.
Since 1d textures cannot have mipmaps, MSL requires that the `level` argument to
texel accesses and dimension queries be a constexpr 0. For our purposes, just
omit the level argument altogether.
* glsl-in: Remove unneeded mutability from reference
* glsl-in: Fix composite constructors
In the recent rework of the constructors it seems that the logic for
composite types (arrays and structs) was accidentally removed by me.
* [hlsl-out] Write `mad` intrinsic for `fma` function
- This should be enough because we only support f32 for now.
- Adds a new test for WGSL functions, in the spirit of operators.wgsl.
- Closes#1579
* Add FMA feature to glsl backend
- I think this is right. Just iterate all known expressions in all
functions and entry points to locate any `fma` function call.
Should not need to walk the statement DAG.
* Transform GLSL fma function into an airthmetic expression when necessary
* Add tests for GLSL fma function tranformation
* Remove the hazard comment from the webgl test input
* Add helper method for fma function support checks
* Address review comment
* Add FindLsb / FindMsb
* Fixes and tests for FindLsb/FindMsb
* Add findLsb / findMsb as WGSL builtins
* Fix tests
* Fix incompatible type issue with MSL output
* Requested changes
* Test fewer cases of findLsb/findMsb
The IR doesn't allow having structs has bindings for entry point
input/output, so the glsl frontend must flatten them.
Glsl defines that the locations are sequential from the block base location.
The glsl spec defines that vector constructors flatten their arguments
and consume them in order, ignoring the remaining arguments if there are
more than needed
We can safely assume that deserialize is enabled for all output tests.
Supporting other modes of operation has low utility.
This change also adds an option to skip the explicit types for WGSL output.
Pointers should not be `DATA`: they can never be stored in anything. (Function
arguments are not storage; they're like `let` bindings.)
Un-`SIZED` values may only live in the `Storage` storage class, so creating
pointers to them in other storage classes is meaningless.
The `ARGUMENT` flag should be set only on pointers in those storage classes that
are permitted to be passed to functions.
See comments in code for details.
Fixes#1513.
The WGSL front end knows that globals in the `Handle` storage class do not
produce references, but it attempts to manage this in two places which trip over
each other. As a consequence, referring to a `let` binding holding a pointer to
a global flips the variable's type from WGSL `ptr` to WGSL reference, with
bewildering consequences.
* [spv-in] Change shadow.spv test input to use StorageBuffer.
The ecosystem around Naga will generally not be able to use Vulkan adapters that
don't support the SPV_KHR_storage_buffer_storage_class (which was incorporated
into SPIR-V 1.3), so we can assume it is present.
Changing the test not to use runtime-sized arrays in the Uniform storage class
will allow Naga to tighten up some validation checks.
* [spv-in] Permit pointers to runtime arrays only in StorageBuffer.
Fixes#1519.
The GLSL empty-global-name.frag test doesn't suffice because the GLSL front end
doesn't produce the same IR as the SPIR-V included in the bug report. As far as
I know, only a genuine SPIR-V input test can produce a global whose name is
`Some("")`.
Include the SPIR-V assembly source.
* Make default a switch case
Previously the default case of a switch statement was encoded as a block
in the statement but the wgsl spec defines it in such a way that the
default case ordering matters.
* [spv-out] Support for the new switch IR
* [dot-out] Use different labels for default cases