Commit Graph
738 Commits
Author SHA1 Message Date
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
Dzmitry Malyshau 2ddc8d1929 Rename StorageClass to AddressSpace 2022-01-31 16:25:06 -05:00
rhysd d6f8958b34 wgsl: Do not make error output colorful when the terminal is dumb 2022-01-29 08:52:36 -05:00
Dzmitry Malyshau 4c91abe5b3 wgsl: remove stride 2022-01-24 16:44:12 -05:00
Dzmitry Malyshau 4bd1efc34d wgsl: declare attribtues with @ 2022-01-20 19:44:05 -05:00
Dávid Kocsis adc6821751 implement block comments (#1675) 2022-01-19 19:48:04 +00:00
Dzmitry Malyshau a89e248d68 layouter: let size() panic 2022-01-14 12:52:30 -05:00
Dzmitry Malyshau b12ed2cc9e Fix arbitrary for MSRV 2022-01-14 12:44:27 -05:00
Dzmitry Malyshau 68b1ae1499 typifier: handle forward expression dependencies 2022-01-14 12:44:27 -05:00
Dzmitry Malyshau ab02ec7904 layouter: rich and careful errors 2022-01-14 12:44:27 -05:00
Dzmitry Malyshau c0b7ac7f54 WGSL: assignment binary operators 2022-01-11 11:01:24 -05:00
Igor Shaposhnik 298a8c30bd [wgsl-in] Write a real type in type mismatch error 2022-01-10 10:02:05 -05:00
João Capucho a8929603ac spv-in: OpVectorInsertDynamic allow unsigned index 2022-01-07 11:08:04 -05:00
João Capucho eeb3de6f86 spv-in: sign agnostic unary operations 2022-01-07 11:03:44 -05:00
João Capucho e2fc32387b spv-in: more sign agnostic binary operations 2022-01-07 11:03:44 -05:00
Ibiyemi Abiodun 9a0f1b395c Add a way to emit errors with a path (#1640)
* Add a way to emit errors with a path

I am using `naga` in my build script to validate all of my shaders, and it would be nice to be able to display the file path inside of the diagnostic, so I added a method `emit_to_stderr_with_path` to `naga::front::wgsl::ParserError`.

* change path to &str

* fix rustfmt
2022-01-04 18:21:44 +00:00
João Capucho 1d0f484b37 glsl-in: fix composite constructors (#1631)
* 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.
2021-12-28 20:16:56 -05:00
João Capucho 5a26606a09 glsl-in: Fix using swizzle as out arguments (#1632)
This worked at one point but because of some changes to the IR it was
temporarily broken.
2021-12-27 19:09:33 -05:00
Luke Street 0d1fc2131f [wgsl-in] Support radians/degrees builtin functions (#1627) 2021-12-27 00:29:33 +00:00
Jonathan Behrens f9b348557a Add FindLsb / FindMsb (#1473)
* 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
2021-12-20 14:48:54 -05:00
Dzmitry Malyshau 8caa2bd87e Gather operations 2021-12-18 11:46:49 -05:00
Ashley 75ce45d4f3 spv-in: fix support for degrees and radians conversion 2021-12-17 11:56:47 -05:00
Christofer Nolander d13e9e3b83 wgsl-in: correctly parse else if (#1611)
* wgsl-in: correctly parse `else if`

* wgsl-in: use early exit in `else if` parsing
2021-12-17 16:19:38 +00:00
João Capucho e1552fd9d5 wgsl-in: Implement matrix construction from scalar 2021-12-17 10:39:31 -05:00
João Capucho 33c1daecee glsl-in: Cull the body of do while if needed 2021-12-16 18:42:59 -05:00
João Capucho 322be0772e spv-in: Implement CompositeInsert for arrays
Only adds support for unspecialized arrays
2021-12-16 16:31:51 -05:00
Dzmitry Malyshau 7bb886bf36 Enforce casting width better, fix IEqual/INotEqual in spv 2021-12-16 16:14:56 -05:00
João Capucho 12baa1e909 spv-in: Implement OpCopyObject
Treat it as a noop since the IR has no concept of copying objects
2021-12-16 13:11:20 -05:00
João Capucho 2a8d64fc59 spv-in: Implement remaining sign agnostic ops 2021-12-16 11:22:16 -05:00
João Capucho cf0c31cc85 spv-in: Allow branch weights in OpBranchConditional 2021-12-16 10:58:27 -05:00
João Capucho 9c75f3cdce glsl-in: Flatten entry point arguments
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.
2021-12-16 10:55:06 -05:00
João Capucho 049b48b319 spv-in: Remove if when both branches are equal 2021-12-15 23:55:20 -05:00