On Friday, July 31, 2015 04:37:16 PM Chris Forbes wrote: > If the indexing expression involves anything modified during the call, > the fixup code to copy back after the call would use the new values. > > This fixes the cases where the first expression node encountered is > ir_binop_vector_extract, fixing the piglits: > > * shaders@out-parameter-indexing@vs-inout-index-inout-mat2-row > * shaders@out-parameter-indexing@vs-inout-index-inout-vec4 > * shaders@out-parameter-indexing@vs-inout-index-inout-vec4-array-element > > Further changes are needed for other expression types. > > Signed-off-by: Chris Forbes <chr...@ijw.co.nz> > Cc: Ben Widawsky <b...@bwidawsk.net> > --- > src/glsl/ast_function.cpp | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp > index 803edf5..e7147dd 100644 > --- a/src/glsl/ast_function.cpp > +++ b/src/glsl/ast_function.cpp > @@ -299,6 +299,21 @@ fix_parameter(void *mem_ctx, ir_rvalue *actual, const > glsl_type *formal_type, > > before_instructions->push_tail(tmp); > > + if (expr != NULL && expr->operation == ir_binop_vector_extract) { > + /* We're going to have to emit a matching insert after the call. > + * evaluate the indexing expression before the call, because it > + * may reference things that change during the call. > + */ > + ir_variable *index_tmp = new(mem_ctx) > ir_variable(expr->operands[1]->type, > + "inout_index_tmp", ir_var_temporary); > + before_instructions->push_tail(index_tmp); > + before_instructions->push_tail( > + new(mem_ctx) ir_assignment( > + new(mem_ctx) ir_dereference_variable(index_tmp), > + expr->operands[1]->clone(mem_ctx, NULL))); > + expr->operands[1] = new(mem_ctx) ir_dereference_variable(index_tmp); > + } > + > /* If the parameter is an inout parameter, copy the value of the actual > * parameter to the new temporary. Note that no type conversion is > allowed > * here because inout parameters must match types exactly. >
Yikes. You can get into trouble with array dereferences too. Would be nice to fix those as well...not sure on the best way to handle it offhand. Still, this fixes bugs, so in the mean time, Reviewed-by: Kenneth Graunke <kenn...@whitecape.org>
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev