glsl: shader outputs cannot have initializers
authorIago Toral Quiroga <itoral@igalia.com>
Wed, 7 Oct 2015 07:21:36 +0000 (09:21 +0200)
committerIago Toral Quiroga <itoral@igalia.com>
Mon, 12 Oct 2015 06:31:08 +0000 (08:31 +0200)
GLSL Spec 4.20.8, 4.3 Storage Qualifiers:

"Initializers in global declarations may only be used in declarations of
 global variables with no storage qualifier, with a const qualifier or
 with a uniform qualifier."

We do this for input variables, but not for output variables. AMD and NVIDIA
proprietary drivers don't allow this either.

Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/ast_to_hir.cpp

index 9511440ba3a20bea9090a82848a99614830c1690..2aea5aef9c0de16fbca6505c7c06bd80f525ff98 100644 (file)
@@ -3201,6 +3201,12 @@ process_initializer(ir_variable *var, ast_declaration *decl,
                       ? "attribute" : "varying");
    }
 
+   if (var->data.mode == ir_var_shader_out && state->current_function == NULL) {
+      _mesa_glsl_error(&initializer_loc, state,
+                       "cannot initialize %s shader output",
+                       _mesa_shader_stage_to_string(state->stage));
+   }
+
    /* If the initializer is an ast_aggregate_initializer, recursively store
     * type information from the LHS into it, so that its hir() function can do
     * type checking.