glsl: Accept precision qualifiers on sampler types, but only in ES.
authorKenneth Graunke <kenneth@whitecape.org>
Sun, 27 Mar 2011 06:37:09 +0000 (23:37 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sun, 27 Mar 2011 06:56:18 +0000 (23:56 -0700)
GLSL 1.30 states clearly that only float and int are allowed, while the
GLSL ES specification's issues section states that sampler types may
take precision qualifiers.

Fixes compilation failures in 3DMarkMobileES 2.0 and GLBenchmark 2.0.

NOTE: This is a candidate for stable release branches.

src/glsl/ast_to_hir.cpp

index a1c76e834affada1b85244f6d89d7fabfcc498d6..9538aa62b3757a1c1d81da0c92f6c81257d5b1ac 100644 (file)
@@ -2676,17 +2676,24 @@ ast_declarator_list::hir(exec_list *instructions,
        *    preceded by one of these precision qualifiers [...] Literal
        *    constants do not have precision qualifiers. Neither do Boolean
        *    variables.
+       *
+       * In GLSL ES, sampler types are also allowed.
+       *
+       * From page 87 of the GLSL ES spec:
+       *    "RESOLUTION: Allow sampler types to take a precision qualifier."
        */
       if (this->type->specifier->precision != ast_precision_none
           && !var->type->is_float()
           && !var->type->is_integer()
+          && !(var->type->is_sampler() && state->es_shader)
           && !(var->type->is_array()
                && (var->type->fields.array->is_float()
                    || var->type->fields.array->is_integer()))) {
 
          _mesa_glsl_error(&loc, state,
-                          "precision qualifiers apply only to floating point "
-                          "and integer types");
+                          "precision qualifiers apply only to floating point"
+                          "%s types", state->es_shader ? ", integer, and sampler"
+                                                      : "and integer");
       }
 
       /* Process the initializer and add its instructions to a temporary