glsl2: Conditionally allow optional extensions to be enabled
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 30 Jun 2010 23:42:07 +0000 (16:42 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 2 Jul 2010 03:40:08 +0000 (20:40 -0700)
The only optional extension currently supported by the compiler is
GL_EXT_texture_array.

src/glsl/glsl_parser_extras.cpp
src/glsl/glsl_parser_extras.h
src/glsl/main.cpp
src/mesa/shader/ir_to_mesa.cpp

index 2e17c4c33723b8cd6b020d58b8d4a2c2a61de36a..fc3f9e90b6be810c1b55406ebf37bcac3fad57e3 100644 (file)
@@ -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;
    }
index dc3d23ac545b1852f9190b6f926f9d9850ae44a2..16f72681816b145eecbaa2b86755019b70a1487f 100644 (file)
@@ -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 {
index deaab7e0335d672f86bb6730fdffb15a10c35957..16bbc8cd3f1a4c564f931bfc308200bbc9dcf94f 100644 (file)
@@ -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;
 
index 918004c79f101b31880400078a149667d21d77b5..7c7e368d0d5120decdae1437fd3b34427edcecf0 100644 (file)
@@ -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;