Commit Graph

262 Commits

Author SHA1 Message Date
Kristoffer Søholm
8618a8a207 [ir] Make the interface visitor traverse local variable initializers
Otherwise the backends will panic on e.g. `vec4 local = Global;` if the global
isn't used anywere else in the function.
2020-11-02 19:34:01 -05:00
Kristoffer Søholm
a89191c234 [glsl-out] Handle initializers for locals
This pretty trivial change unfortunately required a loop to mutably borrow both
builder and manager at the same time, so I had to separate them. Perhaps a
cleaner solution would be to use an object with internal state instead of free
functions.
2020-11-02 18:15:06 -05:00
Pelle Johnsen
0101ea7319 [glsl-in] Handle assign ops: +=, *=, etc 2020-11-02 10:06:01 -05:00
Pelle Johnsen
602367c062 [glsl-in] Add initial texture handling 2020-11-01 14:52:11 -05:00
Matúš Talčík
173bb0de42 spv-in: more loop fixes 2020-10-31 10:02:47 -04:00
Dzmitry Malyshau
0893d912be [msl] fix floating point modulo, return value from compute entry point 2020-10-30 23:08:20 -04:00
Dzmitry Malyshau
f811b69aa8 [msl] avoid bad identifiers 2020-10-30 23:08:20 -04:00
Kristoffer Søholm
4a10aab5f6 [glsl-in] Add iteration statements
while, do-while and for loops
2020-10-30 21:29:53 -04:00
Kristoffer Søholm
3b8b7e28dd [glsl-in] Add selection statements
i.e. if-else and switch-case
2020-10-30 21:29:53 -04:00
Dzmitry Malyshau
80bdd23fd4 Add scalar_kind() accessor to IR Type (#251) 2020-10-30 21:25:55 -04:00
Matus Talcik
871139431a spv-in: fix while loop traverse (#253) 2020-10-30 20:58:29 -04:00
João Capucho
d45d11e4c5 msl-out: Use io::Write instead of fmt::Write (#250)
* msl-out: Use io::Write instead of fmt::Write

* msl-out: merge std use
2020-10-30 16:51:50 -04:00
Dzmitry Malyshau
529225ce4c Option to dump spirv flow graphs (#249) 2020-10-30 16:44:59 -04:00
Matus Talcik
4b43e282fc spv-in: fix flowgraph (#247)
Header blocks were incorrectly overwritten.
format
2020-10-29 10:43:12 -04:00
Dzmitry Malyshau
587dc01a2c [msl] refactor the options, add override stages 2020-10-28 00:30:22 -04:00
Dzmitry Malyshau
ce49afa391 Clean up the storage classes (#245) 2020-10-27 09:10:55 -04:00
Dzmitry Malyshau
c1830901c7 Simplify bitshift IR (#244) 2020-10-27 09:05:14 -04:00
Dzmitry Malyshau
621af3cbcb Bump thiserror to 1.0.21 (#241) 2020-10-20 14:44:56 -04:00
João Capucho
a718992acb Added new external functions to the glsl backend to make it on par with the typifier (#240) 2020-10-19 09:40:30 -04:00
Pelle Johnsen
78c9e45182 [glsl-in] Add initial pre-processor (#238)
* [glsl-in] Add initial pre-processor

* [glsl-in] Tweak preprocessor after review

- Add IfState struct
- Use FastHashMap to pre-defines
- Use ok-or() for some errors

* [glsl-in] Remove Option in defines arg
2020-10-15 13:38:02 -04:00
Pelle Johnsen
6fb195cdc8 [clippy] Fix clippy issues after upgrading to 1.47 (#237)
* [clippy] disable match_like_matches_macro for now

* [wgsl-in] Return error instead of panic

* [typifier] Convert panics to return error

Still one panic in clone impl for Resolution,
disabled clippy for that one

* [spv-in] REturn error instead of panic'ing

* [spv-out] Return error instead of panic'ing

* [typifier] Use IncompatibleOperand(s) error

Instead of just Other

* [typifier] Use Expression for op in Error

For IncompatibleOperands

* [typifier] revert last commit
2020-10-13 17:14:40 -04:00
João Capucho
b76dff9d9c Added the new method to the msl Writer (#236) 2020-10-12 11:49:53 -04:00
Pelle Johnsen
2b268c926c [glsl-in] Extraxt lexer next_line method (#232)
Have single place where advancing to next line
2020-10-08 13:14:05 -04:00
Dzmitry Malyshau
aa35110471 Allow output variables to be read 2020-10-07 16:08:05 -04:00
Timo de Kort
4420258001 [ir] Remove Matrix Kind from the IR (#230) 2020-10-06 17:19:29 -04:00
Timo de Kort
f67dfd251a [spv-out] Add multiply instructions (#219) 2020-10-06 16:57:30 -04:00
Pelle Johnsen
773408663b [glsl-in] make consume_token a lexer method (#227)
* [glsl-in] make consume_token a lexer method

* [glsl-in] fix lex for 1.41
2020-10-06 10:31:41 -04:00
Capucho
34e46d0a76 Added support for matrix access on the typifier 2020-10-05 16:11:41 -04:00
Timo de Kort
99f829b3cc [spv-out] Add check for global variables if name is set 2020-10-05 09:43:59 -04:00
Timo de Kort
90c56aca2f [spv-out] Add scalar conversion support 2020-10-03 19:50:09 -04:00
Timo de Kort
98167103c2 [spv-out] Remove instruction spec tests 2020-10-03 19:49:22 -04:00
Pelle Johnsen
842079a3cd [glsl-in] Handle spacing for preproces directives 2020-10-02 00:50:18 -04:00
Timo de Kort
e0f593f35f [spv-out] Add matrix construct support 2020-10-01 15:41:42 -04:00
Timo de Kort
b56c2ddbdc [spv-out] Fix write_function returning block id 2020-09-30 16:43:56 -04:00
Dzmitry Malyshau
6de675313b [spv] fix stack overflow in type writing 2020-09-28 23:29:23 -04:00
Dzmitry Malyshau
8323521b83 [valid] move out the integer interpolation check to the entry point 2020-09-28 10:15:35 -04:00
Dzmitry Malyshau
d03c95a576 Add more methods recognized by the typifier 2020-09-28 10:15:35 -04:00
Dzmitry Malyshau
53627c5cd8 [valid] allow dynamic access into vectors 2020-09-28 10:15:35 -04:00
Dzmitry Malyshau
e57d877dbc [spv] fix storage buffer detection 2020-09-28 10:15:35 -04:00
Dzmitry Malyshau
541d1dcb8b Fix convert_phong_lighting test feature checks 2020-09-28 01:10:57 -04:00
Dzmitry Malyshau
7e809c605a Remove validation error lifetime 2020-09-28 01:10:57 -04:00
Pelle Johnsen
df9834258f [glsl-in] Implement swizzle for r-values (#213)
* [glsl-in] Implement swizzle for r-values

Related to #210

* [glsl-in] Just return Result from field_selection

Removed unneccessary Otion in return type

* [glsl-in] Always match on type in field_selection

* [glsl.in] Borrow by value in field_selection
2020-09-25 10:32:50 -04:00
Nicholas Rishel
7ce99774d5 Add legend for supported end-points (#212)
There's no legend explaining what symbols mean for supported end-points, but it seems to be following the same format at wgpu. This PR copies wgpu's legend.
2020-09-23 00:48:31 -04:00
Pelle Johnsen
e5d17e878b [glsl-in] Support anonymous global uniforms (#211)
* [glsl-in] Support anonymous global uniforms

Partly fixes #210

* [glsl-in] Handle anon global structs in fn prelude
2020-09-22 11:52:51 -04:00
Pelle Johnsen
8c48ae51ce [glsl-in] consolidate tests (#206)
* [glsl-in] consolidate tests

- remove simple lex test as was covered by others
- combine related tests to single function
- remove redundant prefix in test names

* [glsl-in] Consolidtae lex tests further
2020-09-22 11:50:56 -04:00
Dzmitry Malyshau
0651eb8fab Complete expression/statement support in MSL, refactor conversion methods in WGSL, and remove Statement::Empty 2020-09-19 16:16:17 -04:00
Dzmitry Malyshau
ca492e43e6 [glsl] write the entry point (#207) 2020-09-18 17:26:32 -04:00
Timo de Kort
40f37c5c8c [spv-out] Combined all instruction spec tests to one test (#208) 2020-09-18 17:02:00 -04:00
João Capucho
0aae8ae6f8 glsl-out: More glsl versions (#191)
* Added support for glsl core version up to 400

* Added 330 to the list supported versions

* Added links to all extensions and fixed a extension being wrongfully activated

* Cleanup and check for image formats

* Removed useless extension and location on layout

* Added support for external functions and fixed global names

* Typefier allow Scalars in distance and length

* Addressed comments

* Fixed extension appearing after body

* Fixed entry point not being generated
2020-09-18 17:01:05 -04:00
Dzmitry Malyshau
d25ab1b1e8 Refactor image sampling arguments, add textureLoad support to WGSL 2020-09-18 10:53:26 -04:00