Commit Graph

1286 Commits

Author SHA1 Message Date
Jim Blandy
93db57c12b [wgsl-in] Test validation of arrays with zero and negative lengths. 2021-08-23 15:57:23 -04:00
Jim Blandy
9713dbbbc1 [spv-out] Quick tests for capability requests. 2021-08-23 09:10:16 -07:00
Jim Blandy
b56349e9bf [spv-out] Fix the processing of cube array images.
Using 1D images should require either the `Sampled1D` or `Image1D` capability.

Using cube array images should require either the `SampledCubeArray` or
`ImageCubeArray` capability.
2021-08-23 09:10:16 -07:00
Dzmitry Malyshau
ea883d98e2 [spv-in] track function parameter sampling flags across handle permutation 2021-08-23 01:48:45 -04:00
Jim Blandy
901e2c0694 [spv-out] Implement BoundsCheckPolicy for image access 2021-08-22 23:41:27 -04:00
Jim Blandy
c6ecd973e7 [spv-out] Use Selection for building conditionals.
Introduce a helper type that manages the details of emitting SPIR-V
conditionals, tracking labels, branches, merge annotations and phi nodes.

Change index bounds checks to use this helper.
2021-08-22 23:41:27 -04:00
Jim Blandy
99de387302 [spv-out] Move image operations into their own module.
For ease of review, there should be no meaningful code changes in this commit.
Match arms are merely moved out into their own functions, whose arguments are
the enum variant's fields, along with any free variables from the function
containing the match.
2021-08-22 23:41:27 -04:00
Jim Blandy
3f4cd9dc88 [spv-out] Add GlobalVariable helper functions. 2021-08-22 23:41:27 -04:00
Jim Blandy
c1121a1e62 [spv-out] Use 'image' instead of 'texture', consistent with SPIR-V. 2021-08-22 23:41:27 -04:00
Jim Blandy
de114e479b Rename IndexBoundsCheckPolicy to BoundsCheckPolicy. 2021-08-22 23:41:27 -04:00
João Capucho
fd10b7d9e8
[glsl-out] Modulo operator on float must be converted to mod function (#1271)
Fixes #1266
2021-08-22 22:43:52 -04:00
Dzmitry Malyshau
81f4ff032f
HLSL: rewrite handling of interface matching rules (#1276)
* [hlsl-out] flatten the entry point inputs

Previously, the logic was re-ordering the inputs according to the binding.
This breaks if one of the inputs is a struct. With this change, the struct
fields are also flattened into the fake entry point struct. We also
construct the original arguments at the beginning of the function.

* hlsl-out: completely separate the flattened IO structs from the original IR structs

Previously, we had heuristics to detect if a particular struct needs the fields
to be re-ordered. We'd re-order interface structs without layout, and the detection
was very fragile and easily wrong.
The new logic is spawning separate struct types if we need any re-ordering to happen.
It's solid, there are no heuristics.
2021-08-22 22:40:31 -04:00
Jim Blandy
63e58f2022
[wgsl-in] Print errors nicely in convert_wgsl snapshot tests. (#1274) 2021-08-22 22:31:11 -04:00
Igor Shaposhnik
464788dc8d
[hlsl-out] Implement switch statement (#1265)
* [hlsl-out] Implement switch statement

* [hlsl-out] Implement switch statement

* Add switch tests to control-flow snapshot
2021-08-22 22:30:22 -04:00
João Capucho
b0569d9593 [glsl-in] Add support for derivative functions 2021-08-22 22:21:30 -04:00
Mikko Lehtonen
222e0949bd [msl-out] Fix gradient sampling typo 2021-08-22 22:20:42 -04:00
Connor Fitzgerald
800f910103 Allow newer bitflags 2021-08-22 22:19:27 -04:00
Dzmitry Malyshau
70be72d9b9 [spv-in] fix expression emit in image store 2021-08-20 21:35:48 -04:00
João Capucho
c09354c78e [glsl-in] Add support for float encoding/decoding builtins
Fixes #1246
2021-08-20 20:41:13 -04:00
João Capucho
fd3f9543b5 Fix round in backends and add support for roundEven in frontends 2021-08-20 19:04:03 -04:00
Jim Blandy
ea168baf56 [spv-out] Clean up capability handling.
Remove `forbidden_caps`.

Accumulate capabilities actually used separately from the permitted
capabilities, so that the latter can be retained across Writer resets, while the
former is cleared between modules.
2021-08-20 18:04:23 -04:00
Zicklag
897afbd710 [wgsl-in] [wgsl-out] Implement bitcast() 2021-08-20 17:19:23 -04:00
João Capucho
778049f97a Apply comments 2021-08-20 16:57:18 -04:00
João Capucho
bbf3e465f3 Add support for inverse hyperbolic trignometric functions
Hlsl and wgsl don't support them directly so a polyfill is used taken
from the msl spec.

`asinh` = `log(x + sqrt(x * x + 1.0))`
`acosh` = `log(x + sqrt(x * x - 1.0))`
`atanh` = `0.5 * log((1.0 + x) / (1.0 – x))`
2021-08-20 16:57:18 -04:00
Dzmitry Malyshau
644fa684ba Fix quad testcase parameters 2021-08-20 16:56:32 -04:00
sigaloid
9050108a95 Fix some clippy suggestions 2021-08-20 16:42:47 -04:00
João Capucho
8d6647d369 [glsl-in] Add support for radians and degrees builtins 2021-08-20 11:59:16 -04:00
João Capucho
846ea0ec09 [glsl-in] Align child structs 2021-08-20 10:59:28 -04:00
João Capucho
0b0d2ab0f3 [glsl-in] Use power of two alignment for bad type in struct
Fixes #1243
2021-08-19 20:38:10 -04:00
João Capucho
448ea65940 [glsl-in] Add support for more builtins
Fixes #1245
2021-08-19 19:58:51 -04:00
João Capucho
0dd32219c5 [glsl-in] Cast grad sampling on shadow image into zero sampling 2021-08-19 19:24:38 -04:00
João Capucho
a741e4b86d [glsl-in] parse shared qualifier 2021-08-19 19:24:00 -04:00
Jim Blandy
2b08525ed1 [spv-out] Request Sample1D capability when texture_1d is used.
Fixes #1241.
2021-08-19 19:23:10 -04:00
João Capucho
ca405e3acf [glsl-in] Allow dynamic indexing on constant variables
Previously we always set the lhs flag when lowering to generate a
pointer so that dynamic indexing would work, this would produce an error
on constant variables since they can't be in a lhs context.

Now we introduce an enum which distinguishes not only between lhs and
rhs but also in array base, if lowering in a lhs context the base is
also lowered in a lhs context but if lowering in rhs the base is lowered
in a special array base context which bypasses the mutability check.

Fixes #1237
2021-08-19 17:37:05 -04:00
João Capucho
fc47008d0c [glsl-in] Allow expression statements to begin with ++ or --
This would otherwise cause the parser to enter an infinite loop.

Fixes #1232
2021-08-19 16:51:10 -04:00
João Capucho
f14817e8a0 [wgsl-in] Store expression position in context 2021-08-19 13:13:13 -04:00
João Capucho
02142d0980 [wgsl-in] Add support for the dereference operator 2021-08-19 13:13:13 -04:00
Connor Fitzgerald
dfcb79880f
[hlsl-out] Fix pointer-to-array arguments (#1240) 2021-08-19 16:55:29 +00:00
Dzmitry Malyshau
dad4b1bb10 [hlsl-out] fix array arguments in functions 2021-08-19 10:05:57 -04:00
Jim Blandy
6ab6d6fc46 ImageLoad doc fix: Depth images can be multisampled, now. 2021-08-18 15:15:10 -04:00
Jim Blandy
cefaa396d4 [spv-out] Generating constants is not, in fact, fallible. 2021-08-18 14:40:00 -04:00
Hans Christian Schmitz
01250b85fe Fix WGSL vector splat constructor's type handling
Previously the constructor just used the type of the scalar argument
regardless of whether or not it actually matched the vector splat
constructors target type. This resulted in e.g. `vec2<f32>(0)`
erroneously getting the type of a bi-vector of Sints with width 4.

Now the splat constructor checks that the kind and width of the scalar
argument is the same as that of the target specified in the
constructor's type parameter.
2021-08-18 10:41:00 -04:00
Dzmitry Malyshau
7a45d73465 Release v0.6 version, changelog, and spirv update 2021-08-18 00:39:25 -04:00
João Capucho
4e181d6af4 [glsl-in] Only add builtins with double arguments if needed 2021-08-17 22:22:30 -04:00
João Capucho
b05ca6e403 [glsl-in] Builtin redefinition and calls fixes 2021-08-17 22:22:30 -04:00
Dzmitry Malyshau
79d899fe4c Support num_workgroups builtin 2021-08-17 22:22:22 -04:00
Connor Fitzgerald
73be8c7454 [hlsl-out] Implicitly transpose all matrices 2021-08-17 14:05:27 -04:00
Connor Fitzgerald
91ea6e3d83 [hlsl-out] Fix reading from mat3 2021-08-17 14:05:27 -04:00
João Capucho
ba92640482 [wgsl-in] Parse function storage class 2021-08-17 13:39:31 -04:00
João Capucho
b11f094287 [wgsl-out] Write pointers types and loads 2021-08-17 13:39:31 -04:00