On Tue, 2015-10-06 at 19:09 -0700, Ian Romanick wrote: > From: Ian Romanick <ian.d.roman...@intel.com> > > It may be possible to consolodate this check with the existing check for consolidate > uniform and const initializers, but a way that didn't require a huge > amount of restructing was not obvious to me. > > Fixes: > > ES2-CTS.shaders.negative.initialize > ES3-CTS.shaders.negative.initialize > > spec/glsl-es-1.00/compiler/global-initializer/from-attribute.vert > spec/glsl-es-1.00/compiler/global-initializer/from-uniform.vert > spec/glsl-es-1.00/compiler/global-initializer/from-uniform.frag > spec/glsl-es-1.00/compiler/global-initializer/from-global.vert > spec/glsl-es-1.00/compiler/global-initializer/from-global.frag > spec/glsl-es-1.00/compiler/global-initializer/from-varying.frag > spec/glsl-es-3.00/compiler/global-initializer/from-uniform.vert > spec/glsl-es-3.00/compiler/global-initializer/from-uniform.frag > spec/glsl-es-3.00/compiler/global-initializer/from-in.vert > spec/glsl-es-3.00/compiler/global-initializer/from-in.frag > spec/glsl-es-3.00/compiler/global-initializer/from-global.vert > spec/glsl-es-3.00/compiler/global-initializer/from-global.frag > > Note: spec/glsl-es-3.00/compiler/global-initializer/from-sequence.* > still fail because the result of a sequence operator is still considered > to be a constant expression. > > Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92304 > Cc: "10.6 11.0" <mesa-sta...@lists.freedesktop.org> > --- > src/glsl/ast_to_hir.cpp | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp > index 9511440..92f288f 100644 > --- a/src/glsl/ast_to_hir.cpp > +++ b/src/glsl/ast_to_hir.cpp > @@ -3300,6 +3300,27 @@ process_initializer(ir_variable *var, ast_declaration > *decl, > var->data.read_only = temp; > } > > + /* Section 4.3 (Storage Qualifiers) of the GLSL ES 1.00.17 spec says: > + * > + * "Declarations of globals without a storage qualifier, or with > + * just the const qualifier, may include initializers, in which case > + * they will be initialized before the first line of main() is > + * executed. Such initializers must be a constant expression." > + * > + * The same section of the GLSL ES 3.00.4 spec has similar language. > + * > + * Initializers for const-decorated declarations are handled above. > + */ > + const bool is_global_declaration = state->current_function == NULL; > + if (state->es_shader && > + is_global_declaration && > + var->data.has_initializer && > + var->constant_initializer == NULL) > + _mesa_glsl_error(&initializer_loc, state, > + "initializer of global variable `%s' must be a " > + "constant expression", > + decl->identifier); > + > return result; > } >
Reviewed-by: Iago Toral Quiroga <ito...@igalia.com> BTW, while reading that spec quote I noticed that we should fail declarations of out variables with initializers as well. Mesa currently allows this (it kinda makes sense to me), but I have checked that neither AMD nor nVidia proprietary driver don't, so I guess this is not a behavior that people are relying on... I'll send a patch for this. Iago _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev