Mesa (glsl2): glsl2: Conditionally allow optional extensions to be enabled

Ian Romanick idr at kemper.freedesktop.org
Fri Jul 2 03:54:34 UTC 2010


Module: Mesa
Branch: glsl2
Commit: 667f4e1940c4c4660e35dc9906672a476369660f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=667f4e1940c4c4660e35dc9906672a476369660f

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Wed Jun 30 16:42:07 2010 -0700

glsl2: Conditionally allow optional extensions to be enabled

The only optional extension currently supported by the compiler is
GL_EXT_texture_array.

---

 src/glsl/glsl_parser_extras.cpp |    6 ++++++
 src/glsl/glsl_parser_extras.h   |    3 +++
 src/glsl/main.cpp               |    1 +
 src/mesa/shader/ir_to_mesa.cpp  |    1 +
 4 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 2e17c4c..fc3f9e9 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -27,6 +27,7 @@
 
 extern "C" {
 #include <talloc.h>
+#include "main/mtypes.h"
 }
 
 #include "ast.h"
@@ -135,6 +136,11 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
    } else if (strcmp(name, "GL_ARB_texture_rectangle") == 0) {
       state->ARB_texture_rectangle_enable = (ext_mode != extension_disable);
       state->ARB_texture_rectangle_warn = (ext_mode == extension_warn);
+   } else if (strcmp(name, "GL_EXT_texture_array") == 0) {
+      state->EXT_texture_array_enable = (ext_mode != extension_disable);
+      state->EXT_texture_array_warn = (ext_mode == extension_warn);
+
+      unsupported = !state->extensions->EXT_texture_array;
    } else {
       unsupported = true;
    }
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index dc3d23a..16f7268 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -90,6 +90,9 @@ struct _mesa_glsl_parse_state {
    unsigned EXT_texture_array_enable:1;
    unsigned EXT_texture_array_warn:1;
    /*@}*/
+
+   /** Extensions supported by the OpenGL implementation. */
+   const struct gl_extensions *extensions;
 };
 
 typedef struct YYLTYPE {
diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp
index deaab7e..16bbc8c 100644
--- a/src/glsl/main.cpp
+++ b/src/glsl/main.cpp
@@ -129,6 +129,7 @@ compile_shader(struct gl_shader *shader)
    state->ARB_texture_rectangle_enable = true;
 
    memset(&ext, 0, sizeof(ext));
+   state->extensions = &ext;
    state->Const.MaxDrawBuffers = 2;
    state->Const.MaxTextureCoords = 4;
 
diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp
index 918004c..7c7e368 100644
--- a/src/mesa/shader/ir_to_mesa.cpp
+++ b/src/mesa/shader/ir_to_mesa.cpp
@@ -1709,6 +1709,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader)
    state->loop_or_switch_nesting = NULL;
    state->ARB_texture_rectangle_enable = true;
 
+   state->extensions = &ctx->Extensions;
    state->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers;
    state->Const.MaxTextureCoords = ctx->Const.MaxTextureCoordUnits;
 




More information about the mesa-commit mailing list