Commit Graph

506 Commits

Author SHA1 Message Date
João Capucho
91ca923553 glsl-out: Add support for push constant emulation 2022-01-16 19:32:51 -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
70b5ddaaad spv-out: use OpFRem instead of OpFMod 2022-01-07 20:19:15 -05:00
Dzmitry Malyshau
09d35f3631 gl-out: skip unsized types if unused 2022-01-05 23:11:43 -05:00
Jim Blandy
53eeb654aa [msl-out] Don't give level in texture1d accesses.
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.
2022-01-04 15:33:23 -08:00
João Capucho
743d058b49 glsl-out: Use constructors shorthand for zero init 2022-01-04 13:52:00 +00:00
João Capucho
b9c4893112 glsl-out: Write struct initializers 2022-01-04 13:52:00 +00:00
João Capucho
32205e3097 glsl-out: write array initializers 2022-01-04 13:52:00 +00:00
Vinh Truong
6aca3e0b36
Fix data packing functions on MSL (#1637)
* Fix data packing functions on MSL

`snorm` and `unorm` got mixed up.

* Fix bits.msl
2021-12-31 16:44:54 +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
Dzmitry Malyshau
2738ad80b9
msl: fix packed vec access (#1634) 2021-12-28 05:13:13 +00: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
Dzmitry Malyshau
b1ab59925d
msl: fix packed float support (#1630) 2021-12-27 02:57:47 +00:00
Dzmitry Malyshau
f2832b8999
hlsl: support arrays of matrices (#1629) 2021-12-27 00:30:57 +00:00
Luke Street
0d1fc2131f
[wgsl-in] Support radians/degrees builtin functions (#1627) 2021-12-27 00:29:33 +00:00
Igor Shaposhnik
8df5421e2e
[glsl-out] Add stage postfix to generated global name (#1616) 2021-12-23 22:19:07 -05:00
Jay Oster
924ab17b62
Fixes for fma function (#1580)
* [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
2021-12-22 09:41:07 -05: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
c2328fea75 Release v0.8 2021-12-18 12:05:12 -05:00
Dzmitry Malyshau
8caa2bd87e Gather operations 2021-12-18 11:46:49 -05:00
Jim Blandy
db98743a5a [glsl-out] Don't return early from snapshot tests. 2021-12-17 20:27:27 -05:00
Ashley
75ce45d4f3 spv-in: fix support for degrees and radians conversion 2021-12-17 11:56:47 -05:00
João Capucho
e1552fd9d5 wgsl-in: Implement matrix construction from scalar 2021-12-17 10:39:31 -05:00
Dzmitry Malyshau
6df9656e96 spv-out: Force wrapping of push constant structs 2021-12-16 16:21:06 -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
4334f0e6a9 Support bitwise And on booleans 2021-12-15 23:53:23 -05:00
João Capucho
c64d5eff50 Support bitwise Or on booleans 2021-12-15 23:53:23 -05:00
Dzmitry Malyshau
8ffd6ba929 Remove top_level property of structs 2021-12-15 09:33:33 -05:00
Jim Blandy
3867ef4f6c [msl-out] Correctly construct out-of-bounds values for all types. 2021-12-14 23:00:03 -05:00
Lain-dono
e200e44ede
[spv-out] Fixing incorrect pack/unpack (#1587)
* [spv-out] Fixing incorrect pack/unpack

* [spv-out] Fixing incorrect pack/unpack: make tests happy

* [spv-out] Fixing incorrect pack/unpack: remove unexpected newline
2021-12-11 21:29:31 -05:00
Jim Blandy
f51f468a47 [msl-out] Implement index bounds check policies for non-texture accesses. 2021-12-06 15:53:41 -05:00
João Capucho
14719553a6 glsl-in: fix pre/postfix ops on swizzles 2021-12-05 22:16:28 -05:00
Dzmitry Malyshau
6fbd668bd3 Add missing GLSL tests 2021-12-02 13:11:23 -05:00
João Capucho
9fac7c48a6 glsl-in: Allow vector/matrix in vector constructor
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
2021-11-29 11:06:18 -05:00
Igor Shaposhnik
dba6beb941 [wgsl-in] Don't allow redefinition of module scope identifiers 2021-11-28 21:23:22 -05:00
Igor Shaposhnik
20b96ef47b Avoid function name redefinition in tests 2021-11-28 21:23:22 -05:00
Dzmitry Malyshau
daa61b5fcb Fix shapshots to run without deserialize feature 2021-11-26 12:16:50 -05:00
Dzmitry Malyshau
74132ba947 Actually disable explicit types on most WGSL outputs 2021-11-26 11:36:46 -05:00
Dzmitry Malyshau
f4ba74544a Refactor snapshot test arguments to avoid checking for deserialize feature too often.
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.
2021-11-26 11:36:46 -05:00
Dzmitry Malyshau
ddbc1c4b1f WGSL: use underscore prefix like the other backends 2021-11-25 16:23:24 -05:00
Igor Shaposhnik
2107b20561 [wgsl-in] Don't allow keywords to be used as identifiers 2021-11-24 16:34:17 -05:00
Jim Blandy
cc930180d9 Tighten checks on pointers to unsized values, and pointer arguments.
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.
2021-11-18 17:39:56 -05:00
Jim Blandy
633f1b3377 [wgsl-in] Don't be confused by pointers to globals.
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.
2021-11-18 17:39:56 -05:00
Jim Blandy
6a5b33fa24
Move BoundsCheckPolicy/Policies into proc, from back. (#1537) 2021-11-17 19:15:59 -08:00
Igor Shaposhnik
30a0a37af0 Update dependencies 2021-11-16 23:46:54 -05:00
Jim Blandy
ce18eba695 Check that stores are permitted by the pointer's storage access.
Fixes #1533.
2021-11-16 23:40:56 -05:00
Boris-Chengbiao Zhou
1dcde48d09
[valid] Check that switches have a default case (#1529)
From the WGSL spec: "Each switch statement must have exactly one default clause."
2021-11-15 00:07:55 +00:00
Jay Oster
66c3499df8
[spv-out] Fix scalar-times-matrix operations (#1524) 2021-11-14 19:07:38 -05:00
Jim Blandy
e69a70bfb7
[spv-in] Permit pointers to runtime arrays only in StorageBuffer. (#1522)
* [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.
2021-11-10 16:58:57 -05:00