Closed AmesingFlank closed 1 month ago
This is illegal SPIR-V I believe. In Vulkan, InstanceId cannot be used, need to use InstanceIndex. The module is not valid OpenGL SPIR-V either, so I doubt that was the intent.
Also, I think duplicate decoration declarations like that are illegal. For user-defined variables for example, declaring two variables with same location is banned:
Any two inputs listed as operands on the same OpEntryPoint must not be assigned the same Location slot and Component word, either explicitly or implicitly. Any two outputs listed as operands on the same OpEntryPoint must not be assigned the same Location slot and Component word, either explicitly or implicitly.
spirv-val does not seem to validate this at the moment. I've suggested a spec clarification to add similar rules for builtins. I don't believe that was intended to work.
This was clarified in 1.3.285 spec update to be banned.
Consider this SPIRV file, this contains multiple SPIRV variables marked with the
InstanceId
built-in decoration:When this shader is passed to spirv cross, an invalid MSL shader is generated:
notice the redefinition of the
gl_InstanceID
variable