[Mesa-dev] [PATCH] nir: add missing x swizzle in nir_print()

Timothy Arceri timothy.arceri at collabora.com
Wed Aug 3 00:28:10 UTC 2016


Currently we only print the swizzle if the components are not
used in order. This means x is not printed when it is the only
component used. By checking if the last component is used we
can print the swizzle for this case.
---
 src/compiler/nir/nir_print.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index 8987526..8bc99bc 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -185,9 +185,17 @@ print_alu_src(nir_alu_instr *instr, unsigned src, print_state *state)
 
    bool print_swizzle = false;
    for (unsigned i = 0; i < 4; i++) {
-      if (!nir_alu_instr_channel_used(instr, src, i))
+      if (!nir_alu_instr_channel_used(instr, src, i)) {
+         /* If the last component is not use print the swizzle */
+         if (instr->src[src].src.ssa &&
+             instr->src[src].src.ssa->num_components == i + 1) {
+            print_swizzle = true;
+            break;
+         }
          continue;
+      }
 
+      /* If components are not used in order then print swizzle */
       if (instr->src[src].swizzle[i] != i) {
          print_swizzle = true;
          break;
-- 
2.7.4



More information about the mesa-dev mailing list