glsl: Create and use a has_explicit_attrib_location() helper.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 24 Sep 2013 01:13:52 +0000 (18:13 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 26 Sep 2013 23:55:18 +0000 (16:55 -0700)
Explicit attribute locations are supported with GLSL 3.30, GLSL ES 3.00,
or "#extension GL_ARB_explicit_attrib_location: enable".  Using a helper
function makes it easy to check for this.

This enables support in GLSL 3.30, which was previously missing.

Previously, we overrode the extension enable flag for ES 3.00.  This is
not robust against a shader such as:

   #version 330
   #extension GL_ARB_explicit_attrib_location : disable

Disabling extensions should not remove core language functionality.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/ast_to_hir.cpp
src/glsl/glsl_parser.yy
src/glsl/glsl_parser_extras.cpp
src/glsl/glsl_parser_extras.h

index 2316cf8e5e45e147883baa2b8a9b6992be898b60..0859d9e00a30212f357cadbd2611ad27361c8c50 100644 (file)
@@ -2842,7 +2842,7 @@ ast_declarator_list::hir(exec_list *instructions,
        * any extension that adds the 'layout' keyword.
        */
       if (!state->is_version(130, 300)
-         && !state->ARB_explicit_attrib_location_enable
+         && !state->has_explicit_attrib_location()
          && !state->ARB_fragment_coord_conventions_enable) {
         if (this->type->qualifier.flags.q.out) {
            _mesa_glsl_error(& loc, state,
index fa6e2053adf2fa56faffb22827ac86aabed6834b..56ca4ad8b07dcc1bfd751813ecb1c3ab315ad667 100644 (file)
@@ -1262,7 +1262,7 @@ layout_qualifier_id:
    {
       memset(& $$, 0, sizeof($$));
 
-      if (state->ARB_explicit_attrib_location_enable) {
+      if (state->has_explicit_attrib_location()) {
          if (strcmp("location", $1) == 0) {
             $$.flags.q.explicit_location = 1;
 
index cac5a18e474f0befc19104d9761f4e6dcd738e0f..a2b52ef004ff2e20e8e697f4cbbda2e1aec9bb92 100644 (file)
@@ -303,10 +303,6 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
    if (this->language_version >= 140) {
       this->ARB_uniform_buffer_object_enable = true;
    }
-
-   if (this->language_version == 300 && this->es_shader) {
-      this->ARB_explicit_attrib_location_enable = true;
-   }
 }
 
 extern "C" {
index 364a983458a99a49c0282103b41089ab065fefc3..27ebbcff88ee9abc136f0d448d6991ff3b94b53f 100644 (file)
@@ -121,6 +121,11 @@ struct _mesa_glsl_parse_state {
       return check_version(130, 300, locp, "bit-wise operations are forbidden");
    }
 
+   bool has_explicit_attrib_location() const
+   {
+      return ARB_explicit_attrib_location_enable || is_version(330, 300);
+   }
+
    void process_version_directive(YYLTYPE *locp, int version,
                                   const char *ident);