Commit Graph
1274 Commits
Author SHA1 Message Date
Igor Shaposhnik c4f3f5ca72 [hlsl-out] Rewrite indent logic. Reduce heap allocation 2021-09-08 17:05:34 -04:00
Igor Shaposhnik 1c2fb3a8a8 [glsl-out] Rewrite indent logic. Reduce heap allocation 2021-09-08 17:05:34 -04:00
Igor Shaposhnik 21fccd71a7 Move Level from msl to backend module 2021-09-08 17:05:08 -04:00
Dzmitry Malyshau f92b56a5b9 Version bump to 0.6.2 2021-09-01 17:52:28 -04:00
Hans Christian Schmitz 270dbeba6e Fix GLSL output for non-fallthrough switch cases (#1310)
* Fix GLSL output for non-fallthrough switch cases

Partially reverts 02c74b5002 and
fixes #1309.

* Fix indentation of control-flow WGSL code

* Clean up glsl-out switch case fallthrough handling

Only insert a break if needed
and if a case is fallthrough, insert a comment indicating this.
2021-09-01 17:52:28 -04:00
Jim Blandy 914cfda696 [spv-out] Replace map_dim with a From implementation. 2021-09-01 17:52:28 -04:00
Jim Blandy 6c47f81054 [spv-out] Use bit flags in LocalImageType, instead of bools. 2021-09-01 17:52:28 -04:00
Jim Blandy 8bc8327ab2 [spv-out] Add test for duplicate OpTypeImage instructions. 2021-09-01 17:52:28 -04:00
Jim Blandy 10175ccd14 [spv-out] Avoid generating duplicate OpTypeImage instructions.
Fixes #1305.

Ensure that two `back::spv::LocalType::Image` values are sure to be equal (and
hash equal) whenever they would generate the same `OpTypeImage` instruction, so
that the usual duplicate removal via `Writer::lookup_type` works. Accomplish
this by changing the contents of `LocalType::Image` to more closely match the
operands of `OpTypeImage` instructions.

Previously, `LocalType::Image` included a `ImageClass::Storage::access` value,
which did not affect the `OpTypeImage` instruction generated. If two
`LocalType::Image` values differered only in their `access`, then they would get
separate entries in `Writer::lookup_type`, two identical `OpTypeImage`
instructions would be generated, and SPIR-V validation would fail.
2021-09-01 17:52:28 -04:00
Jim Blandy ecb53a82d0 [spv-out] Write debug names for all types, not just structs.
This affects a lot of snapshots, so it's in its own commit, for easier review.
2021-09-01 17:52:28 -04:00
Jim Blandy 2fa0c6b99e [spv-out] Let write_type_declaration_local handle all LocalTypes.
Change `write_type_declaration_local` to handle any type that can be represented
as a `LocalType`. This means that Image and Sampler types are handled there now.

Change `write_type_declaration_arena` to defer to `write_type_declaration_local`
to handle any type that can be represented as a `LocalType`. This makes the code
for those types in `write_type_declaration_arena` redundant, so remove it.

However, continue to request SPIR-V capabilities for image types from
`write_type_declaration_arena`, since that function is fallible, while
`write_type_declaration_local` is not.
2021-09-01 17:52:28 -04:00
Jim Blandy edc48aa354 [spv-out] Avoid duplicate lookup in write_type_declaration_local. 2021-09-01 17:52:28 -04:00
Jim Blandy f88117e3fd [spv-out] Request proper capabilities for storage image formats. 2021-09-01 17:52:28 -04:00
Jim Blandy a0158b32c2 [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-09-01 17:52:28 -04:00
Jim Blandy 0eb3a1848b [spv-out] Handle break and continue in switch statements.
Fixes #1030.
Fixes #1017.
2021-09-01 17:52:28 -04:00
Igor Shaposhnik 81016c7f67 [hlsl-out] Fix output struct member names 2021-09-01 17:52:28 -04:00
Dzmitry Malyshau 2d09fd0e35 [msl-out] don't pack location fields 2021-09-01 17:52:28 -04:00
fsh 20ce0407c0 [glsl-in] Avoid infinite loop when parsing invalid statements (#1280) 2021-09-01 17:52:28 -04:00
Dzmitry Malyshau c722da8ac3 Bump version to 0.6.1 2021-08-24 18:17:02 -04:00
aentity 135f23fe1c Update deps petgraph and rose-tree 2021-08-24 18:17:02 -04:00
Dzmitry Malyshau 2419553892 [spv-in] track function parameter sampling flags across handle permutation 2021-08-24 18:17:02 -04:00
Connor Fitzgerald b80e253f17 Allow newer bitflags 2021-08-24 18:17:02 -04:00
Mikko Lehtonen fbb3aa2b1b [msl-out] Fix gradient sampling typo 2021-08-24 18:17:02 -04:00
Dzmitry Malyshau f6a63b65da 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-24 18:17:02 -04:00
Jim Blandy 7637f4d83a [wgsl-in] Print errors nicely in convert_wgsl snapshot tests. (#1274) 2021-08-24 18:17:02 -04:00
João Capucho bc1c3d9bb5 [glsl-out] Modulo operator on float must be converted to mod function (#1271)
Fixes #1266
2021-08-24 18:17:02 -04:00
Dzmitry Malyshau c8f220f57c [spv-in] fix expression emit in image store 2021-08-24 18:17:02 -04:00
Igor Shaposhnik 02c74b5002 [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-24 18:17:02 -04:00
Connor Fitzgerald 7d88637bbf [hlsl-out] Fix pointer-to-array arguments (#1240) 2021-08-24 18:17:02 -04:00
Dzmitry Malyshau 83ec5f6f14 [hlsl-out] fix array arguments in functions 2021-08-24 18:17:02 -04:00
Dzmitry Malyshau 7a45d73465 Release v0.6 version, changelog, and spirv update naga-v0.6.0 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
Dzmitry Malyshau 939e8f0a7b [msl-out] insert padding struct initialization 2021-08-17 00:23:07 -04:00
Dzmitry Malyshau ab1e932e16 [glsl-out] use common bake prefix 2021-08-17 00:22:51 -04:00
Dzmitry Malyshau c398102332 [msl-out]: avoid inner structure for run-time array sizes 2021-08-16 13:10:56 -04:00
Dzmitry Malyshau ec64eaae6b [spv-in] work around storage image access 2021-08-16 12:20:40 -04:00
Dzmitry Malyshau 220081c4b2 [msl-out] pass-through workgroup storage 2021-08-16 12:20:07 -04:00
Dzmitry Malyshau 8e0295178c [spv-in] allow float16 and float64 2021-08-16 12:14:10 -04:00
Jim Blandy 4b1363e122 [spv-out] Creating SPIR-V types is not, in fact, fallible.
There's no need for functions that construct SPIR-V types to be fallible, or for
their callers to check for errors.

As a consequence of this change, there may be other functions that no longer
need to be fallible, but Rust doesn't warn and Clippy doesn't lint, so we'll
have to address them as they come up.
2021-08-16 12:02:15 -04:00
João Capucho c6a6afdf37 [spv-in] Parse OpNoLine 2021-08-16 10:26:21 -04:00
Dzmitry Malyshau 7613798aed [wgsl-in] parse identifiers before builtin function calls 2021-08-15 23:20:04 -04:00
Kneelawk d7af2a84b7 Move case-closing-brace writer inside cases loop 2021-08-15 22:39:23 -04:00
Dzmitry Malyshau 2dfcb7fcf0 [spv-in] treat Grad on depth textures as level 0 2021-08-15 22:25:20 -04:00
Dzmitry Malyshau 0d829d6bb0 hlsl-out: relational expressions 2021-08-15 22:22:22 -04:00