Commit Graph
312 Commits
Author SHA1 Message Date
teoxoy a730236b68 [wgsl-in] eagerly evaluate const-expressions
[wgsl-in] support const-expressions in attributes

allow `Splat` as an evaluated const-expression type
2023-10-12 13:13:26 +02:00
Nicolas Silva 33b75a27d9 [wgsl-in] Parse the bgra8unorm storage format (#2550) 2023-10-10 09:13:19 -07:00
Nicolas Silva 3c7dbc4016 Add StorageFormat::Bgra8Unorm 2023-10-09 17:04:03 +02:00
Teodor Tanasoaia f37db5affc [wgsl] remove outerProduct (#2535) 2023-10-05 19:14:52 +02:00
Teodor Tanasoaia 6668d0694c Add Rgb10a2Uint format (#2525) 2023-10-03 13:36:14 +02:00
Jim Blandy 57bebbcd20 [wgsl-in] Use deterministic ordering for dependency ordering.
Use `FastIndexSet`, rather than `FastHashSet`, for tracking global
declarations' dependencies, so that the order in which functions are
inserted into the `Module` is not dependent on the hash function.
2023-09-21 23:18:18 -07:00
Jim Blandy 6a254d904d [wgsl-in] Use FastIndexMap for temporary named expressions table. 2023-09-21 21:37:32 -07:00
Jim Blandy 54df410b94 [wgsl-in] make RuntimeExpressionContext::local_table a shared ref. (#2481)
The `front::wgsl::lowerer::RuntimeExpressionContext::local_table`
field does not need to be a mutable reference, as expressions never
introduce new local bindings.
2023-09-20 05:12:48 +00:00
Bruce Mitchener ae9c1f7847 clippy: Remove extra Iterator bounds. (#2475)
`Iterator` is a supertrait of `ExactSizeIterator`, so specifying `ExactSizeIterator` is enough.
2023-09-13 15:45:50 +02:00
Fredrik Fornwall 5329aa2bd5 [wgsl-in] Handle modf and frexp (#2454) 2023-09-02 08:55:35 +02:00
Frederik Magnus Johansen Vestreandteoxoy 0491d39232 Support dual source blending (#2427)
Co-authored-by: teoxoy <28601907+teoxoy@users.noreply.github.com>
2023-08-30 21:00:35 +02:00
Fredrik Fornwall 3bd2834b4f [wgsl-in] Handle all(bool) and any(bool) (#2445)
Fixes #1911.
2023-08-29 21:34:55 +02:00
Fredrik Fornwall b001313947 [wgsl-in] Only splat 'scalar op vec', not '_ op vec' (#2444)
Change binary_op_splat() from splatting:

        vec op scalar
        _ op vec

to only splat:

        vec op scalar
        scalar op vec
2023-08-18 15:16:44 +02:00
Fredrik Fornwall 3da9355125 [wgsl-in] Avoid splatting all binary operator expressions (#2440)
* [wgsl-in] Avoid splatting all binary operator expressions

Fixes #2439.

* [wgsl-in] Expand binary_op_splat function comment
2023-08-18 13:07:24 +02:00
Fredrik Fornwall f6e99a4603 [wgsl-in] Handle repeated or missing @workgroup_size (#2435) 2023-08-17 13:20:10 +02:00
Fredrik Fornwall 7a19f3af90 [wgsl-in] Fail on repeated attributes (#2428)
* [wgsl-in] Fail on repeated attributes

Fixes #2425.

* [wgsl-in] Use ParsedAttribute to keep track of parsed attributes
2023-08-13 17:52:10 +02:00
Fredrik Fornwall 30afa5bd1f [wgsl-in] Fix error message for invalid texture{Load,Store}() on 2d_array (#2432)
Fixes https://github.com/gfx-rs/naga/issues/2431
2023-08-11 16:35:41 +02:00
Jim Blandy e7cd4ffbaa [wgsl-in] Document ExpressionContextType, ExpressionContext. 2023-07-17 16:26:08 -07:00
Jim Blandy a3dff6b840 Document front::wgsl::lower::ExpressionContextType and friends. 2023-07-17 16:26:08 -07:00
teoxoy d348d843e1 implement const-expressions (phase 1) 2023-07-17 16:26:08 -07:00
Daniel McNab 907b7c7cda Workgroup uniform load (#2201)
Implement the WGSL `workgroupUniformLoad` function.
2023-05-26 13:32:22 -07:00
Shaye Garg 1c17fa82d4 [wgsl-in] Error on param redefinition (#2342)
* error on param redefinition

* also fix #2312
2023-05-25 13:13:27 +02:00
Teodor Tanasoaia 62b287e761 Change type of constant sized arrays to NonZeroU32 (#2337) 2023-05-12 14:38:50 +02:00
teoxoy d842d6688d Introduce GlobalCtx 2023-05-11 09:52:40 -07:00
Jim Blandy 412d5aa62e [wgsl-in] Generate Expression::Literal. 2023-05-11 07:09:53 -07:00
Teodor Tanasoaia 4d87401fac Use Expression::ZeroValue in SPIR-V and WGSL front ends. 2023-05-10 19:30:03 -07:00
Christopher Fleetwood 7c00548075 [wgsl] Use alias instead of type for type aliases (#2299) 2023-04-04 12:35:32 +02:00
Jim Blandy 53d62b9ede Clean up handling of RayDesc builtin type, somewhat. 2023-03-22 17:23:07 -07:00
Dzmitry Malyshau c34eed5e47 Address Jim's review notes, use typegen module for atomic struct 2023-03-22 17:23:07 -07:00
Dzmitry Malyshau 22e341b039 wgsl: handle RayDesc/RayIntersection at the type decl level instead of an AST constructor 2023-03-22 17:23:07 -07:00
Dzmitry Malyshau 13ee4369cc clippy fixes 2023-03-22 17:23:07 -07:00
Dzmitry Malyshau 67d31b8e8c spv-out: basic ray query support 2023-03-22 17:23:07 -07:00
Dzmitry Malyshau b856625821 Ray query expressions and special types 2023-03-22 17:23:07 -07:00
Dzmitry Malyshau 432b4990a7 Add ray query types to the IR 2023-03-22 17:23:07 -07:00
Evan Mark HopkinsandTeodor Tanasoaia 6db8da72ca Add partial derivative builtins (#2277)
* Add partial derivative builtins

* [dot] emit derivative control

* Fix fmt

---------

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
2023-03-17 00:15:44 +01:00
Evan Mark Hopkins 8a72b7a8ad Differentiate between i32 and u32 in switch (#2269)
* Differentiate between i32 and u32 in switch

* Use similar wording to other error messages

* Remove duplicate enum
2023-03-10 17:53:11 +01:00
Mauro GentileandTeodor Tanasoaia 810e9d26fc Add countTrailingZeros (#2243)
Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
2023-02-20 20:40:59 +01:00
Evan Mark Hopkins 7422ace934 [wgsl-in] Add predeclared vector and matrix type aliases (#2251) 2023-02-16 15:49:54 -08:00
Evan Mark Hopkins 1ad47f732d Fix texture built-ins where u32 was expected (#2245)
- The Typifier was updated to expect `uint`
- Both `glsl` and `spv` frontends where updated to cast the result to `sint`.
- Both `glsl` and `spv` backends where updated to cast the result to `uint`.
- Remove cast in `msl` backend.
2023-02-13 14:13:58 +01:00
SparkyPotato dcfd5c6f4a improve invalid assignment diagnostic 2023-02-01 12:28:31 +01:00
SparkyPotato 231af68386 expect semicolons wherever required 2023-02-01 12:28:31 +01:00
SparkyPotato e6bd2e9071 fix panic on invalid zero array size 2023-02-01 12:28:31 +01:00
SparkyPotato bb20ae8e79 check for leading { while parsing a block 2023-02-01 12:28:31 +01:00
Evan Mark Hopkinsandteoxoy 6be394dac3 Add countLeadingZeros (#2226)
* Add countLeadingZeros

* [glsl-out] Bake countLeadingZeros

* [hlsl-out] Bake countLeadingZeros

* [hlsl-out] Update Baked expressions

* Remove unnecessary bake for sints

* [glsl-out] CountLeadingZeros without findMSB

* Don't check negatives when uint

* Perform the type conv after mix

* use log2

* fix clippy lints

---------

Co-authored-by: teoxoy <28601907+teoxoy@users.noreply.github.com>
2023-01-31 21:31:05 +01:00
teoxoy a2b39e45bf [hlsl-out] clear named_expressions inserted by duplicated blocks
changed the type of `named_expressions` from `HashMap` to `IndexMap` so that insertion order is preserved
2023-01-31 10:43:02 -08:00
Shaye Garg 67ea8f0c06 [wgsl-in] Split into multiple files (#2207)
Make changes suggested in #2075, but put off to a separate PR because they would interfere with reviewing the change:

- Split the new WGSL front end into modules in a logical way.
- Rename `Parser` to `Frontend`.
2023-01-31 07:17:58 -08:00
Jim Blandy ca99d8bcbc Inline identifiers into format strings.
[Since Rust 1.58], Rust format strings have been able to "capture
arguments simply by writing {ident} in the string." Clippy 1.67 made
the corresponding warning, `uninlined_format_args`, warn-by-default.
Inlined arguments seem more readable, so Naga should adopt them.

[Since Rust 1.58]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1580-2022-01-13
2023-01-31 11:27:51 +01:00
Evan Mark Hopkins a638da9edb [wgsl] Removes isFinite and isNormal 2023-01-23 11:50:50 +01:00
Evan Mark Hopkins 74e5b4a07e [wgsl] Update inverse hyperbolic built-ins 2023-01-23 11:50:50 +01:00
Evan Mark Hopkins 9f182ade30 [wgsl] Add refract built-in 2023-01-23 11:50:50 +01:00