SPIRV-Cross/shaders-msl-no-opt/vert
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
..
functions_nested.vert MSL test shader refactoring to avoid optimization crashes. 2017-12-26 18:40:46 -05:00
layer.msl11.invalid.vert Move .invalid. test shaders to the more appropriate subfolders. 2019-11-06 10:40:37 +01:00
pass-array-by-value.force-native-array.vert MSL: Reintroduce workaround for constant arrays being passed by value. 2020-02-24 13:22:52 +01:00
pass-array-by-value.vert MSL: Fix case where we pass arrays to functions by value. 2019-01-14 11:00:14 +01:00
unused-subgroup-builtin.msl22.vert spirv_msl: Don't add fixup hooks for builtin variables if they're unused. 2020-11-25 13:41:12 -05:00
viewport-index.msl2.invalid.vert Move .invalid. test shaders to the more appropriate subfolders. 2019-11-06 10:40:37 +01:00