Replace gl_VertexID/gl_InstanceID with gl_VertexIndex/gl_InstanceIndex
Summary
The Vulkan dialect of GLSL uses gl_VertexIndex and gl_InstanceIndex instead of gl_VertexID and gl_InstanceID. But FIR only accepts the latter.
Details
The document defining the version of GLSL Vulkan uses states that gl_VertexID and gl_InstanceID are among the removed features, while gl_VertexIndex and gl_InstanceIndex have been added.
FIR allows the former in a vertex shader, but does not allow the latter.
Using gl_VertexID does work on my setup, but also produces a validation layer error:
UNASSIGNED-CoreValidation-Shader-InconsistentSpirv(ERROR / SPEC): msgNum: 7060244 - Validation Error:
[ UNASSIGNED-CoreValidation-Shader-InconsistentSpirv ] Object 0: handle = 0x4346de8, type = VK_OBJECT_TYPE_DEVICE;
| MessageID = 0x6bbb14 | SPIR-V module not valid: Vulkan spec doesn't allow BuiltIn VertexId to be used.
%gl_VertexID = OpVariable %_ptr_Input_uint Input
Proposed changes
gl_VertexIndex and gl_InstanceIndex are already defined as SPIR-V builtins, but not available for use in a vertex shader. I imagine they would just have to be added here, possibly replacing the existing gl_VertexID/gl_InstanceID in this list.
Edited by Jakob Brünker