Commit Graph

655 Commits

Author SHA1 Message Date
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
Igor Shaposhnik
943235cd5e [glsl-out] Convert modulo operator on float to SPIR-V OpFRem equivalent function (#1452) 2021-10-07 16:59:39 -04:00
Connor Fitzgerald
2f5a41cce9 Add insert/extractBits and pack/unpack functions (#1449) 2021-10-05 20:32:57 -04:00
João Capucho
71a75d727d [glsl-out] Es: convert 1D images to 2D (#1436) 2021-10-03 23:01:44 -04:00
Jim Blandy
4ea2d96cfb Various doc fixes. (#1440) 2021-09-30 08:56:09 -04:00
Jim Blandy
4ef1cc403b Remove Namer::call_unique. (#1439)
Replace uses of `call_unique` with uses of `call` and `call_or`, which becomes
public. It's not clear when `call_unique` is correct to use, and avoiding a few
numeric suffixes here and there isn't worth it.
2021-09-29 19:33:38 -04:00
Igor Shaposhnik
a4bf25a0d5 Emit std430 layout qualifiers for storage buffers (#1435)
* Remove unused petgraph dependency from glsl-out

* Emit std430 layout qualifiers for storage buffers
2021-09-29 12:24:34 -04:00
Dzmitry Malyshau
004a12e21d [spv-out] option to clamp frag_depth (#1431) 2021-09-27 23:00:10 +00:00
Dzmitry Malyshau
21324b8fea Update WGSL grammar for pointer access. (#1312)
* Update WGSL grammar for pointer access.

Comes with a small test, which revealed a number of issues in the backends.

* Validate pointer arguments to functions to only have function/private/workgroup classes.

Comes with a small test. Also, "pointer-access.spv" test is temporarily disabled.
2021-09-27 18:49:28 -04:00
Jim Blandy
8122598fe7 [wgsl-out] Correct handling of named pointer expressions.
Treat expressions in `Function::named_expressions` like WGSL `let` declarations,
assuming that the Load Rule was applied to the rhs of the declaration, meaning
that their values are always `Indirection::Ordinary`.

Split `write_expr_plain_form` out from `write_expr_with_indirection`, to clean
up the parenthesis generation: no more `opened_paren` variable, just function
calls. This makes the early return for named expressions neater.

Fixes #1382.
2021-09-27 16:01:43 -04:00
Jim Blandy
7b023ce396 [wgsl-out] Make plain_form_indirection an associated fn of Writer. 2021-09-27 16:01:43 -04:00
Jim Blandy
f3ea2130a4 [wgsl-in]: Correctly compare pointer types.
Treat `TypeInner::ValuePointer` and `TypeInner::Pointer` as equivalent by
converting them to a canonical form before comparison.

Support `ValuePointer` in WGSL type output.

Fixes #1318.
2021-09-27 16:01:43 -04:00
Jim Blandy
944a693ae5 Use UniqueArena for types.
Ensure that each distinct type occurs only once in `Module::types`, so that we
can use `Eq` on `Type` or `TypeInner` for type equivalence, without being
confused by differing `Handle<Type>` values that point to identical types.

This removes a number of duplicate types from the ir snapshots.

Fixes #1385.
2021-09-27 15:17:41 -04:00
João Capucho
d5fc05e8a4 Allow unsigned integers in switch 2021-09-21 17:16:51 -04:00
João Capucho
6a57559070 [glsl-out] Improve handling of samplerCubeArrayShadow
Adds checks that it isn't used in an unsupported function and emits the
depth_ref as a separate argument.
2021-09-21 16:54:05 -04:00
Dzmitry Malyshau
115d170584 wgsl-out: update reserved words 2021-09-21 13:51:12 -04:00
Aleksi Sapon
42db64628e wgsl-out: vector bitcast 2021-09-21 15:50:10 +01:00
João Capucho
60d0bf850b Add support for multi view extensions 2021-09-19 17:38:27 -04:00
João Capucho
7895e7f036 Don't output identifiers starting with _ 2021-09-19 15:18:17 -04:00
Dzmitry Malyshau
52d74e91a4 spv-out: option to emit PointSize 2021-09-15 18:48:18 -04:00
Jim Blandy
5d3c93e8c7 [wgsl-out] Properly parenthesize address-of expressions.
Fixes #1352.
2021-09-15 18:46:55 -04:00
Jim Blandy
045ec6db32 [spv-out] Various doc fixes. 2021-09-15 18:41:07 -04:00
Dzmitry Malyshau
807accd7de wgsl-in: require storage class to be given 2021-09-13 15:44:05 -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