summaryrefslogtreecommitdiff
path: root/src/glsl/ast_to_hir.cpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-07-07 12:13:34 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-07-07 12:41:26 -0700
commite78e0fa42b49b50ed1150f7fdb74bf942ebd6bcf (patch)
treec30083909ec2a5bd96b02d313e22f5a6bacf485d /src/glsl/ast_to_hir.cpp
parentc44556317abf77ca6e344c79d119c91bebe25c8c (diff)
glsl2: Put the initializer in the instruction stream after the declaration
Diffstat (limited to 'src/glsl/ast_to_hir.cpp')
-rw-r--r--src/glsl/ast_to_hir.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index f5e93b0254..b21131f60f 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1772,6 +1772,13 @@ ast_declarator_list::hir(exec_list *instructions,
}
}
+ /* Process the initializer and add its instructions to a temporary
+ * list. This list will be added to the instruction stream (below) after
+ * the declaration is added. This is done because in some cases (such as
+ * redeclarations) the declaration may not actually be added to the
+ * instruction stream.
+ */
+ exec_list intializer_instructions;
if (decl->initializer != NULL) {
YYLTYPE initializer_loc = decl->initializer->get_location();
@@ -1801,7 +1808,8 @@ ast_declarator_list::hir(exec_list *instructions,
}
ir_dereference *const lhs = new(ctx) ir_dereference_variable(var);
- ir_rvalue *rhs = decl->initializer->hir(instructions, state);
+ ir_rvalue *rhs = decl->initializer->hir(&intializer_instructions,
+ state);
/* Calculate the constant value if this is a const or uniform
* declaration.
@@ -1829,7 +1837,7 @@ ast_declarator_list::hir(exec_list *instructions,
/* Never emit code to initialize a uniform.
*/
if (!this->type->qualifier.uniform)
- result = do_assignment(instructions, state, lhs, rhs,
+ result = do_assignment(&intializer_instructions, state, lhs, rhs,
this->get_location());
var->read_only = temp;
}
@@ -1919,6 +1927,7 @@ ast_declarator_list::hir(exec_list *instructions,
}
instructions->push_tail(var);
+ instructions->append_list(&intializer_instructions);
/* Add the variable to the symbol table after processing the initializer.
* This differs from most C-like languages, but it follows the GLSL