Commit Graph

51 Commits

Author SHA1 Message Date
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
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
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
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
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
João Capucho
9e4f678c13 glsl-in: Add tests for images 2022-02-16 21:56:32 +00: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
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
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
14719553a6 glsl-in: fix pre/postfix ops on swizzles 2021-12-05 22:16:28 -05:00
João Capucho
d168f15d81
[glsl-in] Allow constructors from non-scalar to scalar (#1520) 2021-11-10 12:15:43 -05:00
João Capucho
c3c4ab7548 [glsl-in] Add test for matrix from matrix constructor 2021-11-09 15:15:11 +00:00
Jim Blandy
c1b378842e
Make tests properly exercise Some("") global names. (#1503)
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.
2021-11-01 14:07:11 -04:00
Igor Shaposhnik
00bbbed90a
Handle empty variable names in namer (#1484)
* Handle empty variable names in namer

* Add glsl-in test with empty global name
2021-10-26 17:46:27 -04:00
Dzmitry Malyshau
fd5085277a Switch the constant in bevy-pbr to avoid display incosistencies 2021-10-23 23:39:49 -04:00
Connor Fitzgerald
2f5a41cce9
Add insert/extractBits and pack/unpack functions (#1449) 2021-10-05 20:32:57 -04:00
João Capucho
38d74a7f0a [glsl-in] Use intermediate local if storage class isn't function
Automatically spills to a local variable function call arguments to
parameters expecting a pointer where the argument storage class isn't
function since the storage classes wouldn't match.
2021-09-27 21:09:08 +01:00
João Capucho
160ab82fee [glsl-in] Allow array constructors 2021-09-21 18:25:43 -04:00
João Capucho
70db5f681d [glsl-in] Allow use of constructors for user types 2021-09-21 18:25:43 -04:00
João Capucho
d7ca7d43b9 [glsl-in] Improve infix handling
Add support for float, vector and matrices targets.

Fix prefix and postfix being inverted (one was returning the value
of the other).

Remove an unneeded local indirection for prefix handling.

Add tests.
2021-09-17 13:56:42 -04:00
João Capucho
1cb4447ec3 [glsl-in] Add test array constant dynamic indexing 2021-09-17 13:47:38 -04:00
Jasper St. Pierre
27d6e442d2 [glsl-in] Also apply vector splatting to bitwise ops 2021-09-17 10:19:28 -04:00
Jasper St. Pierre
a9d20d8ef4 [glsl-in] Add support for a large number of texture sample overrides 2021-09-16 23:00:19 +01:00
Jasper St. Pierre
0e66930aff [glsl-in] Fix sampling texture array types
Fixes #1349.
2021-09-12 09:44:14 -04:00
Jasper St. Pierre
ba39fd47c3
Output parentheses around dereference (#1348)
Regression from ce676cf130.

We need to output (*d).mx rather than *d.mx, at least according to Tint.
wgsl-in seems to handle *d.mx just fine, which is likely a separate bug.
2021-09-11 23:32:10 -07:00
João Capucho
1aaf77489b [glsl-in] Improve error api and make more errors deferred 2021-08-09 10:51:15 -04:00
João Capucho
a8a316da15 [glsl-in] API revamp
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.
2021-08-09 10:51:15 -04:00
João Capucho
057dc3100d [glsl-in] Remove support for multiple entry points 2021-08-04 11:06:57 -04:00
João Capucho
677e040462 [glsl-in] Long form matrix support 2021-07-27 11:35:47 -04:00
João Capucho
105a2ae5e1 [glsl-in] Check type dimensions in function calls 2021-07-07 12:59:20 -04:00
Jasper St. Pierre
78e1304d42 [glsl-in] Convert bool -> scalar cast to Select 2021-07-02 01:34:34 -04:00
Jasper St. Pierre
cb8e9f2cad [glsl-in] Implicitly splat the inputs of clamp() 2021-07-01 18:32:33 +01:00
João Capucho
4bc4c60663 [glsl-in] Implicit casts for function calls 2021-06-19 13:58:21 -04:00
Gordon-F
6cdd332cef Reorganize test snapshot folder 2021-06-19 10:19:04 -04:00
Frizi
efd416d964 [glsl-in] parse all math functions 2021-06-17 16:08:34 -04:00
Frizi
20c6fd1862 add license headers to the bevy pbr shaders 2021-06-17 15:21:47 -04:00
Frizi
96980727cb [glsl-in] support nested swizzles and prevent l-value repeated components 2021-06-17 15:21:47 -04:00
Frizi
b261dde77f [glsl-in] revert test case change 2021-06-17 15:21:47 -04:00
Frizi
378ea9d396 add more glsl snapshot tests 2021-06-17 15:21:47 -04:00
João Capucho
06c8588fcd [glsl-in] Add collatz shader and test quad shader 2021-06-09 12:54:58 -04:00
João Capucho
1c3baf4557
[glsl-in] Allow field selection behind pointers (#948) 2021-06-03 16:09:20 -04:00