Treat texture rectangles as an extension that is enabled be default
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 8 Apr 2010 00:13:44 +0000 (17:13 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 8 Apr 2010 00:13:44 +0000 (17:13 -0700)
builtin_types.sh
glsl_parser_extras.cpp
glsl_parser_extras.h
glsl_types.cpp

index 609073c9e4d73161fc644f8a52d1b7216307af44..4e6f0878ce5c61ece699f1efa9e7fd311b22a8a7 100755 (executable)
@@ -167,8 +167,6 @@ done
 
 gen_sampler_type "3D"     "GLSL_SAMPLER_DIM_3D"   0 0 "GLSL_TYPE_FLOAT"
 gen_sampler_type "Cube"   "GLSL_SAMPLER_DIM_CUBE" 0 0 "GLSL_TYPE_FLOAT"
-gen_sampler_type "2DRect" "GLSL_SAMPLER_DIM_RECT" 0 0 "GLSL_TYPE_FLOAT"
-gen_sampler_type "2DRect" "GLSL_SAMPLER_DIM_RECT" 1 0 "GLSL_TYPE_FLOAT"
 
 gen_footer
 
@@ -328,6 +326,16 @@ echo ''
 echo 'const glsl_type *const glsl_type::uint_type = & builtin_130_types['$uint_index'];'
 echo '/*@}*/'
 
+echo
+echo '/** \name Sampler types added by GL_ARB_texture_rectangle'
+echo ' */'
+echo '/*@{*/'
+gen_header "ARB_texture_rectangle"
+gen_sampler_type "2DRect" "GLSL_SAMPLER_DIM_RECT" 0 0 "GLSL_TYPE_FLOAT"
+gen_sampler_type "2DRect" "GLSL_SAMPLER_DIM_RECT" 1 0 "GLSL_TYPE_FLOAT"
+gen_footer
+echo '/*@}*/'
+
 echo
 echo '/** \name Sampler types added by GL_EXT_texture_buffer_object'
 echo ' */'
index 553cd675a7a1a714f8487bb03e394ae07f5dd218..fd44e96602422a83da5ff39bcd0b102ad32123f5 100644 (file)
@@ -135,6 +135,9 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
         state->ARB_draw_buffers_enable = (ext_mode != extension_disable);
         state->ARB_draw_buffers_warn = (ext_mode == extension_warn);
       }
+   } 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 {
       unsupported = true;
    }
@@ -736,6 +739,7 @@ main(int argc, char **argv)
    state.error = false;
    state.temp_index = 0;
    state.loop_or_switch_nesting = NULL;
+   state.ARB_texture_rectangle_enable = true;
 
    _mesa_glsl_lexer_ctor(& state, shader, shader_len);
    _mesa_glsl_parse(& state);
index 51e4eb89ccf596f0f5acc1f81ab80d138b9e4a65..a79dc75d4823fc4415de03d7df216824386ecc73 100644 (file)
@@ -66,6 +66,8 @@ struct _mesa_glsl_parse_state {
    /*@{*/
    unsigned ARB_draw_buffers_enable:1;
    unsigned ARB_draw_buffers_warn:1;
+   unsigned ARB_texture_rectangle_enable:1;
+   unsigned ARB_texture_rectangle_warn:1;
    /*@}*/
 };
 
index ba4f0297d81d8258966264ab8062db4c9c32a14d..24b3e3f59f9a67d885023a8e9a4198992195a05e 100644 (file)
@@ -35,11 +35,11 @@ hash_table *glsl_type::array_types = NULL;
 static void
 add_types_to_symbol_table(glsl_symbol_table *symtab,
                          const struct glsl_type *types,
-                         unsigned num_types)
+                         unsigned num_types, bool warn)
 {
-   unsigned i;
+   (void) warn;
 
-   for (i = 0; i < num_types; i++) {
+   for (unsigned i = 0; i < num_types; i++) {
       symtab->add_type(types[i].name, & types[i]);
    }
 }
@@ -49,12 +49,15 @@ static void
 generate_110_types(glsl_symbol_table *symtab)
 {
    add_types_to_symbol_table(symtab, builtin_core_types,
-                            Elements(builtin_core_types));
+                            Elements(builtin_core_types),
+                            false);
    add_types_to_symbol_table(symtab, builtin_structure_types,
-                            Elements(builtin_structure_types));
+                            Elements(builtin_structure_types),
+                            false);
    add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types,
-                            Elements(builtin_110_deprecated_structure_types));
-   add_types_to_symbol_table(symtab, & void_type, 1);
+                            Elements(builtin_110_deprecated_structure_types),
+                            false);
+   add_types_to_symbol_table(symtab, & void_type, 1, false);
 }
 
 
@@ -64,7 +67,7 @@ generate_120_types(glsl_symbol_table *symtab)
    generate_110_types(symtab);
 
    add_types_to_symbol_table(symtab, builtin_120_types,
-                            Elements(builtin_120_types));
+                            Elements(builtin_120_types), false);
 }
 
 
@@ -74,7 +77,16 @@ generate_130_types(glsl_symbol_table *symtab)
    generate_120_types(symtab);
 
    add_types_to_symbol_table(symtab, builtin_130_types,
-                            Elements(builtin_130_types));
+                            Elements(builtin_130_types), false);
+}
+
+
+static void
+generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab, bool warn)
+{
+   add_types_to_symbol_table(symtab, builtin_ARB_texture_rectangle_types,
+                            Elements(builtin_ARB_texture_rectangle_types),
+                            warn);
 }
 
 
@@ -95,6 +107,11 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
       /* error */
       break;
    }
+
+   if (state->ARB_texture_rectangle_enable) {
+      generate_ARB_texture_rectangle_types(state->symbols,
+                                          state->ARB_texture_rectangle_warn);
+   }
 }