Commit Graph

678 Commits

Author SHA1 Message Date
Jim Blandy
a1e8805360 Use ExpressionContext::resolve_type where appropriate. 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
João Capucho
79233ba5e5 glsl-out: Fix array constants constructor 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
Dzmitry Malyshau
2738ad80b9 msl: fix packed vec access (#1634) 2021-12-28 05:13:13 +00: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
8caa2bd87e Gather operations 2021-12-18 11:46:49 -05:00
Dzmitry Malyshau
6df9656e96 spv-out: Force wrapping of push constant structs 2021-12-16 16:21:06 -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
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
Jim Blandy
8a2fbd360d [msl-out] Add log tracing for functions and entry points. 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
Jim Blandy
e8f564dc83 [spv-out] Add comment about AccessIndex on non-pointer values. 2021-12-06 15:53:41 -05:00
Jim Blandy
61e3af2989 [msl-out] Move Statement::Store handling into its own function. 2021-12-06 15:53:41 -05:00
Jim Blandy
17398e761f [msl-out] Move Expression::Load handling into its own function.
No changes in behavior.
2021-12-06 15:53:41 -05:00
Jim Blandy
840bbaffcc [msl-out] Rename put_dynamic_array_length, make it take a global. 2021-12-06 15:53:41 -05:00
Jim Blandy
89cc21ef43 [spv-out] BlockContext::write_expression_pointer doc fix. 2021-12-06 15:53:41 -05:00
Jim Blandy
6912cb3594 [spv-out] Move ExpressionPointer to back::spv::block, remove pub. 2021-12-06 15:53:41 -05:00
Dzmitry Malyshau
c69f676609 glsl: reflect textures without samplers 2021-12-04 12:19:36 -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
Igor Shaposhnik
7c2fdf94c0 [wgsl-out] Add double underscores as a reserved prefix 2021-11-26 09:36:18 -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
Igor Shaposhnik
cb6d3fa815 [wgsl] Move backend keyword list into its own module 2021-11-24 16:34:17 -05:00
Igor Shaposhnik
ae0c7355ca [wgsl] Remove IsInf and IsNan 2021-11-24 16:05:03 -05:00
Jim Blandy
7fd172515d [spv-out] Don't support arguments pointing to unsized types.
Functions with such arguments could never have been called anyway, and now they
are forbidden in validation.
2021-11-18 17:39:56 -05:00
Layl Bongers
29571cc4cf Add multiview wgsl builtin 2021-11-18 09:57:37 -05:00
Jim Blandy
6a5b33fa24 Move BoundsCheckPolicy/Policies into proc, from back. (#1537) 2021-11-17 19:15:59 -08:00
Jim Blandy
3d6cbcf8a6 Remove IndexableLength::Specializable variant.
Specializable constants are no longer permitted as array lengths, so this case
should not arise in valid code.
2021-11-16 09:12:42 -05:00
Jay Oster
66c3499df8 [spv-out] Fix scalar-times-matrix operations (#1524) 2021-11-14 19:07:38 -05:00
Jonathan Behrens
098e4af52f [spv-out] Fix word order for constants 2021-11-07 14:51:40 +00:00
Dzmitry Malyshau
28c45321e5 hlsl: respect array stride in storage buffers (#1507) 2021-11-03 22:44:46 -04:00
Igor Shaposhnik
9d2b357214 [glsl\wgsl out] Remove unnecessary clones (#1492)
* [glsl-out] Remove unnecessary clones

* [wgsl-out] Remove unnecessary clones
2021-10-28 13:54:32 -04:00
João Capucho
63dbd38edc Make default a switch case (#1477)
* 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
2021-10-26 13:31:54 -04:00
João Capucho
c3a0d71f8b [spv-out] Write function arguments names (#1472) 2021-10-23 23:20:12 -04:00
Dzmitry Malyshau
c4ab9a3956 hlsl: Fix mat3 stores (#1467) 2021-10-18 01:04:06 -04:00
Jim Blandy
528f52fba0 [msl-out] Put serde(default) on the whole struct, not on each field. (#1463)
This has no effect, but makes the code more legible.
2021-10-16 10:55:31 -04:00
Jim Blandy
62cc5fc646 [msl-out] Delete Writer::runtime_sized_buffers. (#1462)
This is just a table mapping handles to their indices, but we can just fetch the
index directly from the handle. We never iterate over its entries, but even if
we did, we could at least use a HashSet instead of a HashMap.
2021-10-15 00:44:28 -04:00
Dzmitry Malyshau
ee450c1ee4 Fix float-bool casts in MSL, SPV, and HLSL backends (#1459) 2021-10-12 11:42:20 -04:00