diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2010-06-17 20:09:34 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-06-17 20:09:34 -0700 |
commit | ce030884064046925a655413097dd8257e9392dd (patch) | |
tree | 35bd14c81c003e9eaf9fd75945452d26dca0fcaa /ast_to_hir.cpp | |
parent | c648a124b20c5e37cf4041062333fc177a65f997 (diff) |
Allow initializers for uniforms
Diffstat (limited to 'ast_to_hir.cpp')
-rw-r--r-- | ast_to_hir.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 1c0b98b10c..3414da00eb 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1758,15 +1758,17 @@ ast_declarator_list::hir(exec_list *instructions, ir_dereference *const lhs = new ir_dereference_variable(var); ir_rvalue *rhs = decl->initializer->hir(instructions, state); - /* Calculate the constant value if this is a const + /* Calculate the constant value if this is a const or uniform * declaration. */ - if (this->type->qualifier.constant) { + if (this->type->qualifier.constant || this->type->qualifier.uniform) { ir_constant *constant_value = rhs->constant_expression_value(); if (!constant_value) { _mesa_glsl_error(& initializer_loc, state, - "initializer of const variable `%s' must be a " + "initializer of %s variable `%s' must be a " "constant expression", + (this->type->qualifier.constant) + ? "const" : "uniform", decl->identifier); } else { rhs = constant_value; @@ -1778,8 +1780,12 @@ ast_declarator_list::hir(exec_list *instructions, bool temp = var->read_only; if (this->type->qualifier.constant) var->read_only = false; - result = do_assignment(instructions, state, lhs, rhs, - this->get_location()); + + /* Never emit code to initialize a uniform. + */ + if (!this->type->qualifier.uniform) + result = do_assignment(instructions, state, lhs, rhs, + this->get_location()); var->read_only = temp; } } |