No subject


Wed Jan 25 13:12:15 PST 2012


if (ARB_draw_instanced) use gl_InstanceID;
if (EXT_texture_array || GL3) use sampler2DArrayShadow;

There are no GLSL preprocessor directives in any shader in Unigine whatsoever.

Comments welcome.

Marek

---
 src/glsl/builtin_variables.cpp  |   22 +++++++++++++++-------
 src/glsl/glsl_parser_extras.cpp |    4 ++++
 src/glsl/glsl_parser_extras.h   |    1 +
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index ed6b922..a1ecf56 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -761,7 +761,7 @@ initialize_vs_variables(exec_list *instructions,
       break;
    }
 
-   if (state->ARB_draw_instanced_enable)
+   if (state->ARB_draw_instanced_supported)
       generate_ARB_draw_instanced_variables(instructions, state, false,
                                             vertex_shader);
 }
@@ -870,13 +870,21 @@ generate_ARB_draw_instanced_variables(exec_list *instructions,
    /* gl_InstanceIDARB is only available in the vertex shader.
     */
    if (target == vertex_shader) {
-      ir_variable *const inst =
-         add_variable(instructions, state->symbols,
-		      "gl_InstanceIDARB", glsl_type::int_type,
-		      ir_var_system_value, SYSTEM_VALUE_INSTANCE_ID);
+      if (state->ARB_draw_instanced_enable) {
+         ir_variable *const inst =
+            add_variable(instructions, state->symbols,
+                         "gl_InstanceIDARB", glsl_type::int_type,
+                         ir_var_system_value, SYSTEM_VALUE_INSTANCE_ID);
+
+         if (warn)
+            inst->warn_extension = "GL_ARB_draw_instanced";
+      }
 
-      if (warn)
-         inst->warn_extension = "GL_ARB_draw_instanced";
+      /* Fixup for Unigine: declare gl_InstanceID if ARB_draw_instanced is
+       * supported. */
+      add_variable(instructions, state->symbols,
+                   "gl_InstanceID", glsl_type::int_type,
+                   ir_var_system_value, SYSTEM_VALUE_INSTANCE_ID);
    }
 }
 
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 0b53232..65dd928 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -60,6 +60,10 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *ctx,
    this->es_shader = false;
    this->ARB_texture_rectangle_enable = true;
 
+   /* Out-of-spec fixups for Unigine. */
+   this->EXT_texture_array_enable = ctx->Extensions.EXT_texture_array;
+   this->ARB_draw_instanced_supported = ctx->Extensions.ARB_draw_instanced;
+
    /* OpenGL ES 2.0 has different defaults from desktop GL. */
    if (ctx->API == API_OPENGLES2) {
       this->language_version = 100;
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index dd93295..97c3107 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -172,6 +172,7 @@ struct _mesa_glsl_parse_state {
    bool ARB_draw_buffers_warn;
    bool ARB_draw_instanced_enable;
    bool ARB_draw_instanced_warn;
+   bool ARB_draw_instanced_supported;
    bool ARB_explicit_attrib_location_enable;
    bool ARB_explicit_attrib_location_warn;
    bool ARB_fragment_coord_conventions_enable;
-- 
1.7.5.4



More information about the mesa-dev mailing list