Commit Graph
1268 Commits
Author SHA1 Message Date
Jim Blandy 165bcfea73 [spv-out] Use bit flags in LocalImageType, instead of bools. 2021-09-01 17:13:18 -04:00
Jim Blandy 7d8fbb810e [spv-out] Add test for duplicate OpTypeImage instructions. 2021-09-01 17:11:06 -04:00
Jim Blandy 70d43bdad6 [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:08:39 -04:00
Jim Blandy 8034054584 [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:07:57 -04:00
Jim Blandy 4ddd4dd2a0 [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:07:38 -04:00
Jim Blandy 075d4a5c85 [spv-out] Avoid duplicate lookup in write_type_declaration_local. 2021-09-01 17:07:26 -04:00
Jim Blandy d9f095fccc [spv-out] Request proper capabilities for storage image formats. 2021-09-01 17:06:22 -04:00
Jim Blandy 2e29967a66 [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:02:11 -04:00
Jim Blandy 301fb9486a [spv-out] Handle break and continue in switch statements.
Fixes #1030.
Fixes #1017.
2021-09-01 16:48:36 -04:00
Igor Shaposhnik 481c645894 [hlsl-out] Fix output struct member names 2021-09-01 16:47:33 -04:00
Dzmitry Malyshau c6fd9e71da [msl-out] don't pack location fields 2021-09-01 16:46:48 -04:00
fsh d08055151a [glsl-in] Avoid infinite loop when parsing invalid statements (#1280) 2021-09-01 16:46:46 -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
Dzmitry Malyshau 5415d8c7c4 Fix atomics in workgroup storage 2021-08-13 23:01:25 -04:00
Dzmitry Malyshau 69b70f8cc3 [hlsl-out] reorder fields when composing structs 2021-08-13 01:45:43 -04:00
Dzmitry Malyshau 27e4ba59e4 Validate that SampleLevel::Exact isn't used for comparisons 2021-08-13 01:45:43 -04:00
Dzmitry Malyshau e59582469c [hlsl-out] basic support for pointer arguments 2021-08-13 01:45:43 -04:00
Dzmitry Malyshau 1907a92928 Fix deserialization of arenas 2021-08-12 22:51:29 -04:00
Dzmitry Malyshau 0feea58a34 [hlsl-out] re-order interface struct fields (#1189) 2021-08-12 13:08:29 -04:00