glsl: Fix copying function's out to temp if dereferenced by array
Function's out variable could be an array dereferenced by an array:
func(v[w[i]]);
or something more complicated.
Copy index in any case.
Fixes: 76c27e47b9
("glsl: Copy function out to temp if we don't directly ref a variable")
Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
04c2f12ab2
commit
0862929bf6
|
@ -363,13 +363,12 @@ copy_index_derefs_to_temps(ir_instruction *ir, void *data)
|
||||||
ir = a->array->as_dereference();
|
ir = a->array->as_dereference();
|
||||||
|
|
||||||
ir_rvalue *idx = a->array_index;
|
ir_rvalue *idx = a->array_index;
|
||||||
if (idx->as_dereference_variable()) {
|
|
||||||
ir_variable *var = idx->variable_referenced();
|
ir_variable *var = idx->variable_referenced();
|
||||||
|
|
||||||
/* If the index is read only it cannot change so there is no need
|
/* If the index is read only it cannot change so there is no need
|
||||||
* to copy it.
|
* to copy it.
|
||||||
*/
|
*/
|
||||||
if (var->data.read_only || var->data.memory_read_only)
|
if (!var || var->data.read_only || var->data.memory_read_only)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ir_variable *tmp = new(d->mem_ctx) ir_variable(idx->type, "idx_tmp",
|
ir_variable *tmp = new(d->mem_ctx) ir_variable(idx->type, "idx_tmp",
|
||||||
|
@ -389,7 +388,6 @@ copy_index_derefs_to_temps(ir_instruction *ir, void *data)
|
||||||
a->array_index = deref_tmp_2;
|
a->array_index = deref_tmp_2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fix_parameter(void *mem_ctx, ir_rvalue *actual, const glsl_type *formal_type,
|
fix_parameter(void *mem_ctx, ir_rvalue *actual, const glsl_type *formal_type,
|
||||||
|
|
Loading…
Reference in New Issue