diff options
author | Brian Paul <[email protected]> | 2008-12-11 19:34:43 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-01-06 09:08:16 -0700 |
commit | 0d293f66877486a37682bd0537ea1d3c5fc126db (patch) | |
tree | 6b6668cf5994c921335d8d6bc52d36423af5f955 /src | |
parent | 6bc2fa0f827989be248fe29a195c2110293e42db (diff) |
mesa: consolidate variable declaration initializer code for globals too
(cherry picked from commit 1737f2dbdd8d9d6b1da140340323cbf83f7bd592)
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/shader/slang/slang_codegen.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 1c7282c26c8..f88bf320c6f 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -2573,6 +2573,7 @@ _slang_gen_var_decl(slang_assemble_ctx *A, slang_variable *var, #endif } + /* constant-folding, etc here */ _slang_simplify(initializer, &A->space, A->atoms); init = _slang_gen_operation(A, initializer); @@ -3938,26 +3939,9 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var, slang_ir_node *n; /* IR node to declare the variable */ - n = _slang_gen_var_decl(A, var, NULL); - - /* IR code for the var's initializer, if present */ - if (var->initializer) { - slang_ir_node *lhs, *rhs, *init; - - /* Generate IR_COPY instruction to initialize the variable */ - lhs = new_node0(IR_VAR); - lhs->Var = var; - lhs->Store = n->Store; - - /* constant folding, etc */ - _slang_simplify(var->initializer, &A->space, A->atoms); - - rhs = _slang_gen_operation(A, var->initializer); - assert(rhs); - init = new_node2(IR_COPY, lhs, rhs); - n = new_seq(n, init); - } + n = _slang_gen_var_decl(A, var, var->initializer); + /* emit GPU instructions */ success = _slang_emit_code(n, A->vartable, A->program, GL_FALSE, A->log); _slang_free_ir_tree(n); |