Mesa (master): lima/ppir: don't lower vector {b,f}csel to scalar if condition is scalar

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Sep 6 02:10:45 UTC 2019


Module: Mesa
Branch: master
Commit: 517b60dc13f1d3fcffee2564b7ad7aed34b83068
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=517b60dc13f1d3fcffee2564b7ad7aed34b83068

Author: Vasily Khoruzhick <anarsoul at gmail.com>
Date:   Thu Aug 29 21:28:36 2019 -0700

lima/ppir: don't lower vector {b,f}csel to scalar if condition is scalar

Utgard PP has vector fcsel operation, but its condition is scalar. Add
filtering callback that checks whether {b,f}csel condition is not scalar
to lower {b,f}csel to scalar only in this case.

Reviewed-by: Qiang Yu <yuq825 at gmail.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
Signed-off-by: Vasily Khoruzhick <anarsoul at gmail.com>

---

 src/gallium/drivers/lima/lima_program.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/lima/lima_program.c b/src/gallium/drivers/lima/lima_program.c
index c0683b88600..4bfcd7e87dc 100644
--- a/src/gallium/drivers/lima/lima_program.c
+++ b/src/gallium/drivers/lima/lima_program.c
@@ -160,16 +160,32 @@ lima_alu_to_scalar_filter_cb(const nir_instr *instr, const void *data)
    case nir_op_fsqrt:
    case nir_op_fsin:
    case nir_op_fcos:
-   /* nir vec4 fcsel assumes that each component of the condition will be
-    * used to select the same component from the two options, but lima
-    * can't implement that since we only have 1 component condition */
-   case nir_op_fcsel:
-   case nir_op_bcsel:
       return true;
    default:
       break;
    }
 
+   /* nir vec4 fcsel assumes that each component of the condition will be
+    * used to select the same component from the two options, but Utgard PP
+    * has only 1 component condition. If all condition components are not the
+    * same we need to lower it to scalar.
+    */
+   switch (alu->op) {
+   case nir_op_bcsel:
+   case nir_op_fcsel:
+      break;
+   default:
+      return false;
+   }
+
+   int num_components = nir_dest_num_components(alu->dest.dest);
+
+   uint8_t swizzle = alu->src[0].swizzle[0];
+
+   for (int i = 1; i < num_components; i++)
+      if (alu->src[0].swizzle[i] != swizzle)
+         return true;
+
    return false;
 }
 




More information about the mesa-commit mailing list