diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index f357717..cff364e 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -38,6 +38,10 @@ static void generate_ARB_draw_instanced_variables(exec_list *, struct _mesa_glsl_parse_state *, bool, _mesa_glsl_parser_targets); + +static void generate_EXT_gpu_shader4_variables(exec_list *, + struct _mesa_glsl_parse_state *, + bool, _mesa_glsl_parser_targets); static struct gl_builtin_uniform_element gl_DepthRange_elements[] = { {"near", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_XXXX}, @@ -629,6 +633,8 @@ initialize_vs_variables(exec_list *instructions, if (state->ARB_draw_instanced_enable) generate_ARB_draw_instanced_variables(instructions, state, false, vertex_shader); + generate_EXT_gpu_shader4_variables(instructions, state, false, + vertex_shader); } @@ -749,6 +755,26 @@ generate_ARB_draw_instanced_variables(exec_list *instructions, } } +static void +generate_EXT_gpu_shader4_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state, + bool warn, + _mesa_glsl_parser_targets target) +{ + /* gl_InstanceID is only available in the vertex shader. + */ + if (target == vertex_shader) { + if (state->ARB_draw_instanced_enable) { + add_variable(instructions, state->symbols, + "gl_InstanceID", glsl_type::int_type, + ir_var_system_value, SYSTEM_VALUE_INSTANCE_ID); + } else { + add_builtin_constant(instructions, state->symbols, + "gl_InstanceID", 0); + } + } +} + static void generate_ARB_shader_stencil_export_variables(exec_list *instructions,