The GLSL empty-global-name.frag test doesn't suffice because the GLSL front end
doesn't produce the same IR as the SPIR-V included in the bug report. As far as
I know, only a genuine SPIR-V input test can produce a global whose name is
`Some("")`.
Include the SPIR-V assembly source.
* 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
* Proof-of-concept for adding spans to validation errors.
Still missing: actually printing the damn stuff.
* Emit errors from analyzer in the CLI.
TODO: tests, I guess!
* Simplification refactoring: avoid avoiding allocations so vehemently.
* Mask helper traits with `as _`.
* Fix block iterator throwing up when span feature is disabled.
* Nest use statements.
* Add basic docs.
* Axe AddSpanResult.
Some compilers like shaderc introduce a full gl_PerVertex struct, this
includes gl_ClipDistance. Normally this isn't a problem since most
drivers optimize it away, but naga zero inits globals if they weren't
previously initialized. This causes gl_ClipDistance to be initialized to
zero which can be really bad for performance.
Minimize allocation in the namer. Heap-allocate string only when needed to
provide an owned key for a hash table, or to hold synthesized text. Try to reuse
allocations.
Many unnecessary trailing `_` characters are removed from test output. These
were all superfluous; separators are still inserted where necessary.
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.
The original pointer access test used SPIR-V for its input because WGSL didn't
have a working pointer indirection operator at the time. Now that it does, we
can just write this test in WGSL directly.
Fixes#1432.
WGSL says:
> - The last member of the structure type defining the store type for a variable
> ... may be a runtime-sized array.
>
> - A runtime-sized array must not be used as the store type or contained within
> a store type in any other cases.
Thus, a struct whose final member is a struct whose final member is a
runtime-sized array is verboten.
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.
Eliminate `Namer::namespace_index` and remove namespace indices from
`Namer::unique` keys. Instead, implement `Namer::namespace` by just swapping in
a fresh table for the duration of the call.
Create the fresh hash table with the right initial capacity. The prior
implementation did manage to avoid allocations by sharing a hash table, and we'd
like to not lose that advantage entirely.
This has no effect on generated code.
* 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.
Automatically spills to a local variable function call arguments to
parameters expecting a pointer where the argument storage class isn't
function since the storage classes wouldn't match.
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.