[Mesa-dev] [PATCH 6/9] tgsi: implement micro_popcnt() in tgsi exec machine

Maxence Le Doré maxence.ledore at gmail.com
Sat Jan 4 15:42:41 PST 2014


From: Maxence Le Doré <Maxence Le Doré>

---
 src/gallium/auxiliary/tgsi/tgsi_exec.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index 25d3373..ddff409 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -316,6 +316,16 @@ micro_mov(union tgsi_exec_channel *dst,
 }
 
 static void
+micro_popcnt(union tgsi_exec_channel *dst,
+             const union tgsi_exec_channel *src)
+{
+  dst->i[0] = util_bitcount(src->u[0]); /* util_bitcount from umath.h */
+  dst->i[1] = util_bitcount(src->u[1]);
+  dst->i[2] = util_bitcount(src->u[2]);
+  dst->i[3] = util_bitcount(src->u[3]);
+}
+
+static void
 micro_rcp(union tgsi_exec_channel *dst,
           const union tgsi_exec_channel *src)
 {
@@ -3671,6 +3681,10 @@ exec_instruction(
       exec_vector_binary(mach, inst, micro_max, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
 
+   case TGSI_OPCODE_POPCNT:
+      exec_vector_unary(mach, inst, micro_popcnt, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_UINT);
+      break;
+
    case TGSI_OPCODE_SLT:
       exec_vector_binary(mach, inst, micro_slt, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
       break;
-- 
1.8.5.2



More information about the mesa-dev mailing list