[Mesa-dev] [PATCH 06/10] glsl: copy function out to temp if we don't directly ref a variable
Timothy Arceri
tarceri at itsqueeze.com
Tue Apr 10 04:34:31 UTC 2018
Otherwise we can end up with IR that looks like this:
(
(declare (temporary ) vec4 f at 8)
(assign (xyzw) (var_ref f at 8) (var_ref f) )
(call f16 ((swiz y (var_ref f at 8) )))
(assign (xyzw) (var_ref f) (var_ref f at 8) )
))
When we really need:
(declare (temporary ) float inout_tmp)
(assign (x) (var_ref inout_tmp) (swiz y (var_ref f) ))
(call f16 ((var_ref inout_tmp) ))
(assign (y) (var_ref f) (swiz y (swiz xxxx (var_ref inout_tmp) )))
(declare (temporary ) void void_var)
The GLSL IR function inlining code seemed to produce correct code
even without this but we need the correct IR for GLSL IR -> NIR to
be able to understand whats going on.
---
src/compiler/glsl/ast_function.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp
index eab18446ef8..fff911e76d0 100644
--- a/src/compiler/glsl/ast_function.cpp
+++ b/src/compiler/glsl/ast_function.cpp
@@ -446,7 +446,8 @@ fix_parameter(void *mem_ctx, ir_rvalue *actual, const glsl_type *formal_type,
* nothing needs to be done to fix the parameter.
*/
if (formal_type == actual->type
- && (expr == NULL || expr->operation != ir_binop_vector_extract))
+ && (expr == NULL || expr->operation != ir_binop_vector_extract) &&
+ actual->as_dereference_variable())
return;
/* An array index could also be an out variable so we need to make a copy
@@ -496,7 +497,7 @@ fix_parameter(void *mem_ctx, ir_rvalue *actual, const glsl_type *formal_type,
ir_dereference_variable *const deref_tmp_1 =
new(mem_ctx) ir_dereference_variable(tmp);
ir_assignment *const assignment =
- new(mem_ctx) ir_assignment(deref_tmp_1, actual);
+ new(mem_ctx) ir_assignment(deref_tmp_1, actual->clone(mem_ctx, NULL));
before_instructions->push_tail(assignment);
}
--
2.17.0
More information about the mesa-dev
mailing list