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.
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.
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.
* [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.
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.