diff options
author | Brian Paul <[email protected]> | 2010-12-08 18:25:38 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2010-12-08 18:25:38 -0700 |
commit | 7ce186358e881d1e30eda716a8dea73d2dab2ee9 (patch) | |
tree | 23d4f89f1ff2e5d69745f0423827f5c39b9218d5 /src/glsl/ir_variable.cpp | |
parent | 379332f629153220614e651225b0521cd64c98b9 (diff) |
glsl: add support for system values and GL_ARB_draw_instanced
Diffstat (limited to 'src/glsl/ir_variable.cpp')
-rw-r--r-- | src/glsl/ir_variable.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index 6b9b29458d0..4d105400dd9 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -30,6 +30,11 @@ static void generate_ARB_draw_buffers_variables(exec_list *, struct _mesa_glsl_parse_state *, bool, _mesa_glsl_parser_targets); +static void +generate_ARB_draw_instanced_variables(exec_list *, + struct _mesa_glsl_parse_state *, + bool, _mesa_glsl_parser_targets); + static ir_variable * add_variable(const char *name, enum ir_variable_mode mode, int slot, const glsl_type *type, exec_list *instructions, @@ -41,6 +46,7 @@ add_variable(const char *name, enum ir_variable_mode mode, int slot, case ir_var_auto: case ir_var_in: case ir_var_uniform: + case ir_var_system_value: var->read_only = true; break; case ir_var_inout: @@ -324,8 +330,13 @@ initialize_vs_variables(exec_list *instructions, generate_130_vs_variables(instructions, state); break; } + + if (state->ARB_draw_instanced_enable) + generate_ARB_draw_instanced_variables(instructions, state, false, + vertex_shader); } + /* This function should only be called for ES, not desktop GL. */ static void generate_100ES_fs_variables(exec_list *instructions, @@ -422,6 +433,27 @@ generate_ARB_draw_buffers_variables(exec_list *instructions, } } + +static void +generate_ARB_draw_instanced_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state, + bool warn, + _mesa_glsl_parser_targets target) +{ + /* gl_InstanceIDARB is only available in the vertex shader. + */ + if (target == vertex_shader) { + ir_variable *const inst = + add_variable("gl_InstanceIDARB", ir_var_system_value, + SYSTEM_VALUE_INSTANCE_ID, + glsl_type::int_type, instructions, state->symbols); + + if (warn) + inst->warn_extension = "GL_ARB_draw_instanced"; + } +} + + static void generate_ARB_shader_stencil_export_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state, |