[Mesa-dev] [PATCH 7/9] tgsi: implement micro_ilsb() and micro_ulsb()
Maxence Le Doré
maxence.ledore at gmail.com
Sat Jan 4 15:42:42 PST 2014
From: Maxence Le Doré <Maxence Le Doré>
---
src/gallium/auxiliary/tgsi/tgsi_exec.c | 42 ++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index ddff409..aa1b140 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -294,6 +294,40 @@ micro_lrp(union tgsi_exec_channel *dst,
}
static void
+micro_ilsb(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ int i = 0, j = 0;
+
+ for(i = 0; i < 4; i++) {
+ int x = src->i[i];
+ int mask;
+ int res = -1;
+ for(j = 0; j < 32; j++) {
+ mask = 1 << j;
+ if (x & mask) {
+ res = j;
+ break;
+ }
+ }
+ dst->i[i] = res;
+ }
+}
+
+static void
+micro_ulsb(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ int i = 0;
+ for(i = 0 ; i < 4 ; i++) {
+ if(src->u[i] == 0)
+ dst->i[i] = -1;
+ else
+ dst->i[i] = ffs(src->u[i]) - 1; /* see u_math.h */
+ }
+}
+
+static void
micro_mad(union tgsi_exec_channel *dst,
const union tgsi_exec_channel *src0,
const union tgsi_exec_channel *src1,
@@ -4276,6 +4310,10 @@ exec_instruction(
exec_vector_binary(mach, inst, micro_idiv, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
break;
+ case TGSI_OPCODE_ILSB:
+ exec_vector_unary(mach, inst, micro_ilsb, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
+ break;
+
case TGSI_OPCODE_IMAX:
exec_vector_binary(mach, inst, micro_imax, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
break;
@@ -4316,6 +4354,10 @@ exec_instruction(
exec_vector_binary(mach, inst, micro_udiv, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
break;
+ case TGSI_OPCODE_ULSB:
+ exec_vector_unary(mach, inst, micro_ulsb, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_UINT);
+ break;
+
case TGSI_OPCODE_UMAD:
exec_vector_trinary(mach, inst, micro_umad, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
break;
--
1.8.5.2
More information about the mesa-dev
mailing list