Commit Graph
769 Commits
Author SHA1 Message Date
Igor Shaposhnik fbb77aa0dc [wgsl-in] Update entry point stage attributes 2022-04-15 18:02:48 +01:00
Jakob Hellermann 6427a661f7 add methods on the error types for reusability in wgsl-analyzer (#1827) 2022-04-15 11:13:39 +02:00
teoxoy dd75579d7c fix typos 2022-04-14 13:47:18 -07:00
Jim Blandy 170faab6db Move invariant bit from Binding::Builtin to Builtin::Position. (#1822)
Use the type system to enforce the rule that the invariant attribute
may only appear on `Position` builtins.
2022-04-13 14:57:05 -07:00
João Capucho 954c1f6f4b glsl-in: Add tests for constants NaN handling (#1817) 2022-04-11 16:53:03 -07:00
Shohei JinnoandJCapucho b21634ac61 [glsl-in] Implement MathFunction::Clamp (#1502)
* Implement Clamp function.

* Fix the return error type.

Change `ConstantSolvingError::InvalidMathArg` to `ConstantSolvingError::NotImplemented`
for the clamp function with the input of unimplemented types.

Unimplemented types:
    - vec2
    - vec3
    - vec4

* [glsl-in] Add helpers that implement the glsl's `max` and `min` functions.

Co-authored-by: JCapucho <jcapucho7@gmail.com>

* Fix grammar.

Co-authored-by: JCapucho <jcapucho7@gmail.com>
2022-04-11 12:02:34 -07:00
Shohei JinnoandJCapucho 8f5d8f61a8 glsl-in: better errors for bad constant expression (#1501)
Co-authored-by: JCapucho <jcapucho7@gmail.com>
2022-04-11 11:22:04 -07:00
teoxoy 5ba2d4d079 [spv-in] error on unsupported matrix stride 2022-04-10 22:27:32 -07:00
teoxoy d3957c1186 implement invariant attribute 2022-04-10 21:49:23 -07:00
Teodor Tanasoaia fa44d9d536 [glsl-in] error on a matCx2 used with the std140 layout (#1806) 2022-04-10 21:42:02 -07:00
Igor Shaposhnik 43cd0ecedd [wgsl] Make colon in case optional (#1801) 2022-03-30 14:32:01 -04:00
Igor Shaposhnik 6bbba0d0d5 [wgsl] Rename smoothStep to smoothstep (#1800) 2022-03-30 14:31:26 -04:00
Teodor Tanasoaia cfcf625019 [wgsl-in] Constructor improvements (#1790)
* 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
2022-03-29 22:51:54 -07:00
João Capucho 4146cb24d0 glsl-in: Allow nested accesses in lhs positions
Also fixes access to runtime sized arrays behind named blocks
2022-03-27 21:47:51 -07:00
João Capucho 21f89b65e4 glsl-in: use forced conversions for vector/matrix constructors
The spec defines that for vector and matrix constructors all arguments
should use the same conversions as scalar constructors (forced conversions)
2022-03-27 21:44:17 -07:00
Jonathan Behrens 26537c1a60 Call ctx.emit_start after flushing 2022-03-27 21:43:16 -07:00
Jonathan Behrens a48faf543f Add glsl barrier function 2022-03-27 21:43:16 -07:00
João Capucho 767d970312 glsl-in: Resume expression emit after imageStore
This wasn't done before which caused the frontend to crash if anything
appeared after it.
2022-03-27 21:42:02 -07:00
teoxoy 800fc7471f fix msrv incompatibility 2022-03-27 00:34:53 -07:00
teoxoy 9dddfeec37 [wgsl-in] implement increment and decrement 2022-03-27 00:34:53 -07:00
Pu Xingyu 3c313564ac wgsl-in: Make semicolon after struct decl optional 2022-03-27 00:22:58 -07:00
João Capucho 54ef2e39a0 glsl-in: Allow multiple array specifiers 2022-03-27 00:18:20 -07:00
João Capucho b568bfbbdf glsl-in: Fix memory qualifiers being inverted
Adds some documentation to better explain how the memory qualifier works
troughout the parser and some storage textures tests.
2022-03-27 00:02:26 -07:00
teoxoy cf992a9a95 [wgsl-in] implement while loop 2022-03-22 22:47:47 -07:00
Igor Shaposhnik 816fa347ad [wgsl-in] Uses commas to separate struct members instead of semicolons 2022-03-12 22:07:06 -08:00
João Capucho f054aa94f4 glsl-in: Support arrays as input/output types
Like it was already done for structs, arrays are flattened and each
element is attributed a location that is it's index + the array base
location.
2022-03-03 21:42:48 -08:00
João Capucho a2bcdda81c glsl-in: Fix freestanding constructor parsing 2022-03-03 21:39:45 -08:00
João Capucho 51e66eceb2 glsl-in: Allow backtracking in the parser 2022-03-03 21:39:45 -08:00
João Capucho af8dd4b3bd glsl-in: Fix matrix by scalar operations 2022-03-02 22:27:24 -08:00
João Capucho 48320db507 glsl-in: Fix matrix by matrix division 2022-03-02 22:27:24 -08:00
João Capucho 7f485d262b glsl-in: Fix matrix comparisons 2022-03-02 22:27:24 -08:00
João Capucho d449d2e665 glsl-in: Add support for texelFetchOffset 2022-03-01 21:06:50 -08:00
Jim Blandy 62f267a140 [wgsl-in] consume_number: Check uint_suffix flag at top of match.
This makes it unnecessary to check that field in every other pattern
in the match.
2022-02-27 22:43:44 -05:00
Jim Blandy f24018dc36 [wgsl-in] Remove unused field Token::Number::width. 2022-02-27 22:43:10 -05:00
Jim Blandy 72e197fc1b [wgsl-in] Use unwrap_or to placate Clippy. 2022-02-27 10:23:43 -08:00
Dzmitry Malyshau a45b9a6cc6 wgsl: update find msb/lsb names (#1735) 2022-02-21 22:40:00 -08:00
João Capucho 9f62feee87 glsl-in: inject sampler2DMSArray builtins on use 2022-02-19 10:42:44 -05:00
João Capucho 66d59eb7ac glsl-in: inject samplerCubeArray builtins on use
Arrayed cube images require a special capabilities in some backends, so
like how we already do with doubles, we now only inject them if a call
uses one as an argument.

This required some refractoring on the builtins handling of variations
but now the interface is cleaner and adding new variations (if needed)
should be easier.
2022-02-18 20:29:23 -05:00
Jim Blandy 07f9cf670c Give Expression::ImageLoad separate sample and level operands. 2022-02-18 17:11:40 -05:00
Dzmitry Malyshau d0a4a193e3 Fix resetting WGSL parser 2022-02-17 09:09:40 -05:00
João Capucho 2ad4c13c98 Add support for image builtin functions 2022-02-16 21:56:32 +00:00
João Capucho 27cbce5b5d glsl-in: Add support for image declarations 2022-02-16 21:56:32 +00:00
Igor Shaposhnik c356b93962 [wgsl-in] Optional parentheses for if and switch 2022-02-15 09:57:07 -05:00
João Capucho d40522329b spv-in: align array stride for undecorated arrays 2022-02-12 23:26:12 -05:00
João Capucho 1f14f7ea2a glsl-in: Texture builtins fixes
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
2022-02-10 10:11:28 -05:00
João Capucho e621acc09d glsl-in: Type qualifiers rework (#1713)
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.
2022-02-04 15:06:49 -05:00
João Capucho 5f948e9b12 glsl-in: texelFetch accept multisampled textures (#1715) 2022-02-04 15:05:49 -05:00
Jim Blandy f3e61530cf Fix a few stray uses of "storage class". (#1712) 2022-02-04 14:31:35 -05:00
João Capucho 54c3f5190c glsl-in: Fix panic when culling nested block (#1714)
Under certatin circumstances the parser would panic because of culling
using an index out of bound, for example take the following code:

```glsl
{
    x = 1; // Index 0 on nested block
    discard; // Index 1 on nested block
} // Index 0 on block
```

The parser seeing this would attempt to cull the block using the start
index of 1 which would be out of bound and panic. Now instead the nested
block properly does it's internal culling and the outer block culls
everything after the nested block only.
2022-02-04 14:21:16 -05:00
Noel Tautges 42bf3545c9 Standardize some docs (#1660)
* 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
2022-02-03 13:27:21 -05:00