SPIRV-Cross/reference/shaders-msl-no-opt
comex c80cbde7aa spirv_msl: Don't add fixup hooks for builtin variables if they're unused.
This is necessary to avoid invalid output because of how implicit
dependencies on builtins work.

For example, the fixup for `BuiltInSubgroupEqMask` initializes the
variable based on `builtin_subgroup_invocation_id_id`, a field storing
the ID for a variable with decoration `BuiltInSubgroupLocalInvocationId`.
This could be either a variable that already exists in the input
(spirv_msl.cpp:300) or, if necessary, a newly created one
(spirv_msl.cpp:621).  In both cases, though,
`builtin_subgroup_invocation_id_id` is only set under the condition
`need_subgroup_mask || needs_subgroup_invocation_id`.
`need_subgroup_mask` is true if any of the `BuiltInSubgroupXXMask` are
set in `active_input_builtins`.

Normally, if the program contains `BuiltInSubgroupEqMask`,
`Compiler::ActiveBuiltinHandler` will set it in `active_input_builtins`.
But this only happens if the variable is actually used, whereas
`fix_up_shader_inputs_outputs` loops over all variables in the program
regardless of whether they're used.

If `BuiltInSubgroupEqMask` is not used,
`builtin_subgroup_invocation_id_id` is never set, but before this patch
the fixup hook would try to use it anyway, producing MSL that references
a nonexistent variable named `_0`.

Avoid this by changing `fix_up_shader_inputs_outputs` to skip builtins
which are not set in `active_input_builtins` or
`active_output_builtins`.  And add a test case.
2020-11-25 13:41:12 -05:00
..
asm MSL: Fix regression in image gather handling. 2020-11-06 16:21:30 +01:00
comp MSL: Don't mask off inactive bits in ballot masks. 2020-11-25 09:29:51 -06:00
components MSL: Deal with padded fragment output + Component decoration. 2020-01-07 17:02:12 +01:00
frag MSL: Expand subgroup support. 2020-11-20 15:55:49 -06:00
packing MSL: Do not emit swizzled writes in packing fixups. 2020-07-06 10:03:46 +02:00
vert spirv_msl: Don't add fixup hooks for builtin variables if they're unused. 2020-11-25 13:41:12 -05:00
vulkan/frag Update for pull request #1162 rev. 1 2019-09-24 18:13:04 -04:00