diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index f357717..9ff7a7e 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_draw_instanced_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_draw_instanced_variables(instructions, state, false, + vertex_shader); } @@ -749,6 +755,25 @@ generate_ARB_draw_instanced_variables(exec_list *instructions, } } +static void +generate_EXT_draw_instanced_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) { + ir_variable *const inst = + add_variable(instructions, state->symbols, + "gl_InstanceID", glsl_type::int_type, + ir_var_system_value, SYSTEM_VALUE_INSTANCE_ID); + + if (warn) + inst->warn_extension = "GL_EXT_draw_instanced"; + } +} + static void generate_ARB_shader_stencil_export_variables(exec_list *instructions, @@ -835,3 +860,5 @@ _mesa_glsl_initialize_variables(exec_list *instructions, break; } } + +