[Mesa-dev] [PATCH] nir: avoid emitting copies for 0 length arrays.

Dave Airlie airlied at gmail.com
Fri May 20 06:20:50 UTC 2016


From: Dave Airlie <airlied at redhat.com>

This replaces the patch to remove the assert I sent previously.

When we lower to temporaries unused arrays were getting copied
unnessecarily.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/compiler/nir/nir_lower_io_to_temporaries.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/compiler/nir/nir_lower_io_to_temporaries.c b/src/compiler/nir/nir_lower_io_to_temporaries.c
index 3153a49..05fca6e 100644
--- a/src/compiler/nir/nir_lower_io_to_temporaries.c
+++ b/src/compiler/nir/nir_lower_io_to_temporaries.c
@@ -49,6 +49,8 @@ emit_copies(nir_cursor cursor, nir_shader *shader, struct exec_list *new_vars,
       nir_variable *newv = exec_node_data(nir_variable, new_node, node);
       nir_variable *temp = exec_node_data(nir_variable, old_node, node);
 
+      if (glsl_type_is_array(temp->type) && glsl_get_length(temp->type) == 0)
+         continue;
       nir_intrinsic_instr *copy =
          nir_intrinsic_instr_create(shader, nir_intrinsic_copy_var);
       copy->variables[0] = nir_deref_var_create(copy, newv);
-- 
2.5.5



More information about the mesa-dev mailing list