This is the (simplest) instancing shader I can come up with, which basically just transforms a bunch of 2D primitives:
#version 400
#extension GL_ARB_draw_instanced : enable
#extension GL_ARB_shading_language_420pack : enable
layout(std140, binding = 0) uniform VConstants {
vec4 vfuniforms[48];
};
in vec4 pos;
void main() {
gl_Position = vec4(0.0,0,0.0,1);
gl_Position.x = dot(pos, vfuniforms[int(float(gl_InstanceID) * 2.0)]);
gl_Position.y = dot(pos, vfuniforms[int(float(gl_InstanceID) * 2.0 + 1.0)]);
}
If I try to compile this to SPIR-V with the glslangValidator that comes with the Vulkan SDK, I get:
WARNING: 0:2: '#extension' : extension not supported: GL_ARB_draw_instanced
ERROR: 0:14: 'gl_InstanceID' : undeclared identifier
ERROR: 1 compilation errors. No code generated.
If I remove the #extension GL_ARB_draw_instanced
line, I still get the gl_InstanceID
error. Is it possible to write instancing GLSL and compile them to SPIR-V? If so, what I am doing incorrectly?