glsl/ast: Allow redeclaration of gl_LastFragData with different precision qualifier.
authorFrancisco Jerez <currojerez@riseup.net>
Thu, 14 Jul 2016 19:52:51 +0000 (12:52 -0700)
committerFrancisco Jerez <currojerez@riseup.net>
Wed, 24 Aug 2016 20:28:31 +0000 (13:28 -0700)
v2: No need to check the GLSL version. (Ken)

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/compiler/glsl/ast_to_hir.cpp

index c91ed53962315a8ac44f762cffab3ad05d682eac..581367ba1cfafbdb4facd4908efc64ec2cae0ed1 100644 (file)
@@ -3979,6 +3979,18 @@ get_variable_being_redeclared(ir_variable *var, YYLTYPE loc,
 
       earlier->data.depth_layout = var->data.depth_layout;
 
+   } else if (state->has_framebuffer_fetch() &&
+              strcmp(var->name, "gl_LastFragData") == 0 &&
+              var->type == earlier->type &&
+              var->data.mode == ir_var_auto) {
+      /* According to the EXT_shader_framebuffer_fetch spec:
+       *
+       *   "By default, gl_LastFragData is declared with the mediump precision
+       *    qualifier. This can be changed by redeclaring the corresponding
+       *    variables with the desired precision qualifier."
+       */
+      earlier->data.precision = var->data.precision;
+
    } else if (allow_all_redeclarations) {
       if (earlier->data.mode != var->data.mode) {
          _mesa_glsl_error(&loc, state,