Commit Graph
21 Commits
Author SHA1 Message Date
Teodor Tanasoaia 9742f1616c fix zero initialization of workgroup memory (#2259)
Use the local (not global) invocation id to decide which invocation should do the initialization, so that every workgroup gets initialized, not just the first.
2023-02-20 19:56:24 -08:00
teoxoy c7d02151f0 add support for zero-initializing workgroup memory 2023-01-25 18:07:48 +01:00
6035b07b78 [wgsl-in] Implement module-level scoping.
Fixes #1745: Support out-of-order module scope declarations in WGSL
Fixes #1044: Forbid local variable shadowing in WGSL
Fixes #2076: [wgsl-in] no error for duplicated type definition
Fixes #2071: Global item does not support 'const'
Fixes #2105: [wgsl-in] Type aliases for a vecN<T> doesn't work when constructing vec from a single argument
Fixes #1775: Referencing a function without a return type yields an unknown identifier error.
Fixes #2089: Error span reported on the declaration of a variable instead of its use
Fixes #1996: [wgsl-in] Confusing error: "expected unsigned/signed integer literal, found '1'"

Separate parsing from lowering by generating an AST, which desugars as
much as possible down to something like Naga IR. The AST is then used
to resolve identifiers while lowering to Naga IR.

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
Co-authored-by: Jim Blandy <jimb@red-bean.com>
2023-01-12 09:37:08 -08:00
teoxoy 1869c6831e [hlsl-out] zero init struct constructor 2022-05-03 19:51:51 +02:00
Igor Shaposhnik f76af4e53a [wgsl] Remove buffer, texture, in, out, input, output from reserved keywords 2022-04-29 20:06:09 +02:00
Teodor Tanasoaia dc075e66e3 [wgsl-in] Update reserved keywords (#1847) 2022-04-17 15:56:54 +02:00
teoxoy 6e6daad4d4 [hlsl-out] fix bool splat 2022-04-15 11:21:51 +02:00
teoxoy d3957c1186 implement invariant attribute 2022-04-10 21:49:23 -07:00
Noel Tautges a3d968e795 [hlsl-out] Don't output interpolation modifier if it's the default (#1809)
* hlsl-out: don't output interpolation modifier if it's the default (linear/`Interpolation::Perspective`)

* Remove linear interpolation modifiers from HLSL output tests
2022-04-09 22:36:36 -07:00
Jim Blandy c84aa77579 [msl-out] Properly rename entry point arguments for struct members. (#1766) 2022-03-08 10:07:30 -05:00
Dzmitry Malyshau 8bc3aa824b Refactor namer scheme, fix trailing digits (#1510) 2021-11-09 09:24:41 -05: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
Jim Blandy d44e2ad207 Simplify interpolation defaulting.
Replace `Module::apply_common_default_interpolation` with a simpler function
that handles a single `Binding` at a time. In exchange for the simplicity, the
function must be called at each point function arguments, function results, and
struct members are prepared. (Any missed spots will be caught by the verifier.)

This approach no longer requires mutating types in the arena, a prerequisite for
properly handling type identity.

Applying defaults to struct members when the struct declaration is parsed does
have a disadvantage, compared to the old whole-module pass: at struct parse
time, we don't yet know which pipeline stages the struct will be used in. The
best we can do is apply defaults to anything with a `Location` binding. This
causes needless qualifiers to appear in some output. However, it seems that our
back end languages all tolerate such qualifiers.
2021-09-27 15:17:41 -04:00
Dzmitry Malyshau a4f19833b5 hlsl: implement struct constructors 2021-09-03 12:43:54 -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
Dzmitry Malyshau 79d899fe4c Support num_workgroups builtin 2021-08-17 22:22:22 -04:00
Dzmitry Malyshau 0feea58a34 [hlsl-out] re-order interface struct fields (#1189) 2021-08-12 13:08:29 -04:00
Dzmitry Malyshau bbfa9a0f9e hlsl: remove the boolean casts for unary operators 2021-07-23 10:41:36 -04:00
Dzmitry Malyshau 8eef784416 WGSL: Flip true/false arguments of select() 2021-07-16 11:42:12 -04:00
Gordon-F 9e61390626 [hlsl-out] Zero initialize variables. Write interpolation and sampling qualifier 2021-07-07 10:57:28 -04:00
Gordon-F d5776879de [hlsl-out] Enable interface snapshot testing 2021-07-05 18:54:42 -04:00