diff options
author | Brian Paul <[email protected]> | 2008-07-29 17:05:54 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-07-29 17:05:54 -0600 |
commit | 153407f72d3492f9d35e2424bb877def8b1a1dcd (patch) | |
tree | f9afee20c821990f07b4ecec487c0a5c013d4c26 /src/mesa/shader/slang/slang_codegen.c | |
parent | 527e1357b59a476348b5fd2600fb99e85cc4e897 (diff) |
mesa: fix some function inlining bugs
Need to add local vars of original function to the new scope's variable
list (though the DECLs were already present).
In slang_operation_copy() call slang_replace_scope() for SLANG_OPER_BLOCK_NEW_SCOPE opers.
Diffstat (limited to 'src/mesa/shader/slang/slang_codegen.c')
-rw-r--r-- | src/mesa/shader/slang/slang_codegen.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 14fa38c3cda..3766a246974 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -651,6 +651,8 @@ new_var(slang_assemble_ctx *A, slang_operation *oper, slang_atom name) if (!var) return NULL; + assert(var->declared); + assert(!oper->var || oper->var == var); n = new_node0(IR_VAR); @@ -924,7 +926,6 @@ slang_substitute(slang_assemble_ctx *A, slang_operation *oper, } - /** * Produce inline code for a call to an assembly instruction. * This is typically used to compile a call to a built-in function like this: @@ -1196,6 +1197,16 @@ slang_inline_function_call(slang_assemble_ctx * A, slang_function *fun, } } + /* Now add copies of the function's local vars to the new variable scope */ + for (i = totalArgs; i < fun->parameters->num_variables; i++) { + slang_variable *p = fun->parameters->variables[i]; + slang_variable *pCopy = slang_variable_scope_grow(inlined->locals); + pCopy->type = p->type; + pCopy->a_name = p->a_name; + pCopy->array_len = p->array_len; + } + + /* New epilog statements: * 1. Create end of function label to jump to from return statements. * 2. Copy the 'out' parameter vars @@ -2059,6 +2070,8 @@ static slang_ir_node * _slang_gen_var_decl(slang_assemble_ctx *A, slang_variable *var) { slang_ir_node *n; + /*assert(!var->declared);*/ + var->declared = GL_TRUE; assert(!is_sampler_type(&var->type)); n = new_node0(IR_VAR_DECL); if (n) { @@ -3140,6 +3153,8 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var, if (store) var->aux = store; /* save var's storage info */ + var->declared = GL_TRUE; + return success; } |