summaryrefslogtreecommitdiffstats
path: root/src/glsl/ast_to_hir.cpp
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2013-05-23 11:48:40 -0700
committerMatt Turner <[email protected]>2013-07-08 12:46:56 -0700
commitba7b60d3e4a89558dc1b514e7611f17d238a2abc (patch)
tree3066d4a48995a567ff952afd4ae1335d93cbdcfa /src/glsl/ast_to_hir.cpp
parent1faa37557373aa29169aa4e3b95c6dcf5aced025 (diff)
glsl: Allow non-constant expression initializers of const-qualified vars.
Required by ARB_shading_language_420pack. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/glsl/ast_to_hir.cpp')
-rw-r--r--src/glsl/ast_to_hir.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index efbd72c1834..cbd9ea35716 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2355,17 +2355,25 @@ process_initializer(ir_variable *var, ast_declaration *decl,
ir_constant *constant_value = rhs->constant_expression_value();
if (!constant_value) {
- _mesa_glsl_error(& initializer_loc, state,
- "initializer of %s variable `%s' must be a "
- "constant expression",
- (type->qualifier.flags.q.constant)
- ? "const" : "uniform",
- decl->identifier);
- if (var->type->is_numeric()) {
- /* Reduce cascading errors. */
- var->constant_value = ir_constant::zero(state, var->type);
- }
- } else {
+ /* If ARB_shading_language_420pack is enabled, initializers of
+ * const-qualified local variables do not have to be constant
+ * expressions. Const-qualified global variables must still be
+ * initialized with constant expressions.
+ */
+ if (!state->ARB_shading_language_420pack_enable
+ || state->current_function == NULL) {
+ _mesa_glsl_error(& initializer_loc, state,
+ "initializer of %s variable `%s' must be a "
+ "constant expression",
+ (type->qualifier.flags.q.constant)
+ ? "const" : "uniform",
+ decl->identifier);
+ if (var->type->is_numeric()) {
+ /* Reduce cascading errors. */
+ var->constant_value = ir_constant::zero(state, var->type);
+ }
+ }
+ } else {
rhs = constant_value;
var->constant_value = constant_value;
}