Mesa (gallium-double-opcodes): tgsi: implement double opcodes

Michał Król michal at kemper.freedesktop.org
Tue Jan 19 12:35:13 UTC 2010


Module: Mesa
Branch: gallium-double-opcodes
Commit: 9f245bebf29ce08948734620db3eade3085c6673
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9f245bebf29ce08948734620db3eade3085c6673

Author: Igor Olivera <igor.oliveira at openbossa.org>
Date:   Mon Jan 18 13:56:58 2010 -0400

tgsi: implement double opcodes

---

 src/gallium/auxiliary/tgsi/tgsi_exec.c |  127 ++++++++++++++++++++++++++++++++
 src/gallium/auxiliary/tgsi/tgsi_info.c |   11 +++-
 2 files changed, 137 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index b9ea761..2842089 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -180,6 +180,96 @@ micro_dmov(union tgsi_double_channel *dst,
 }
 
 static void
+micro_ddiv(union tgsi_double_channel *dst,
+           const union tgsi_double_channel *src)
+{
+   dst->d[0] = src[0].d[0] / src[1].d[0];
+   dst->d[1] = src[0].d[1] / src[1].d[1];
+   dst->d[2] = src[0].d[2] / src[1].d[2];
+   dst->d[3] = src[0].d[3] / src[1].d[3];
+}
+
+static void
+micro_dmul(union tgsi_double_channel *dst,
+           const union tgsi_double_channel *src)
+{
+   dst->d[0] = src[0].d[0] * src[1].d[0];
+   dst->d[1] = src[0].d[1] * src[1].d[1];
+   dst->d[2] = src[0].d[2] * src[1].d[2];
+   dst->d[3] = src[0].d[3] * src[1].d[3];
+}
+
+static void
+micro_dmax(union tgsi_double_channel *dst,
+           const union tgsi_double_channel *src)
+{
+   dst->d[0] = src[0].d[0] > src[1].d[0] ? src[0].d[0] : src[1].d[0];
+   dst->d[1] = src[0].d[1] > src[1].d[1] ? src[0].d[1] : src[1].d[1];
+   dst->d[2] = src[0].d[2] > src[1].d[2] ? src[0].d[2] : src[1].d[2];
+   dst->d[3] = src[0].d[3] > src[1].d[3] ? src[0].d[3] : src[1].d[3];
+}
+
+static void
+micro_dmin(union tgsi_double_channel *dst,
+           const union tgsi_double_channel *src)
+{
+   dst->d[0] = src[0].d[0] < src[1].d[0] ? src[0].d[0] : src[1].d[0];
+   dst->d[1] = src[0].d[1] < src[1].d[1] ? src[0].d[1] : src[1].d[1];
+   dst->d[2] = src[0].d[2] < src[1].d[2] ? src[0].d[2] : src[1].d[2];
+   dst->d[3] = src[0].d[3] < src[1].d[3] ? src[0].d[3] : src[1].d[3];
+}
+
+static void
+micro_dslt(union tgsi_double_channel *dst,
+           const union tgsi_double_channel *src)
+{
+   dst->d[0] = src[0].d[0] < src[1].d[0] ? 1.0 : 0.0;
+   dst->d[1] = src[0].d[1] < src[1].d[1] ? 1.0 : 0.0;
+   dst->d[2] = src[0].d[2] < src[1].d[2] ? 1.0 : 0.0;
+   dst->d[3] = src[0].d[3] < src[1].d[3] ? 1.0 : 0.0;
+}
+
+static void
+micro_dsge(union tgsi_double_channel *dst,
+           const union tgsi_double_channel *src)
+{
+   dst->d[0] = src[0].d[0] >= src[1].d[0] ? 1.0 : 0.0;
+   dst->d[1] = src[0].d[1] >= src[1].d[1] ? 1.0 : 0.0;
+   dst->d[2] = src[0].d[2] >= src[1].d[2] ? 1.0 : 0.0;
+   dst->d[3] = src[0].d[3] >= src[1].d[3] ? 1.0 : 0.0;
+}
+
+static void
+micro_dseq(union tgsi_double_channel *dst,
+           const union tgsi_double_channel *src)
+{
+   dst->d[0] = src[0].d[0] == src[1].d[0] ? 1.0 : 0.0;
+   dst->d[1] = src[0].d[1] == src[1].d[1] ? 1.0 : 0.0;
+   dst->d[2] = src[0].d[2] == src[1].d[2] ? 1.0 : 0.0;
+   dst->d[3] = src[0].d[3] == src[1].d[3] ? 1.0 : 0.0;
+}
+
+static void
+micro_drcp(union tgsi_double_channel *dst,
+           const union tgsi_double_channel *src)
+{
+   dst->d[0] = 1.0 / src->d[0];
+   dst->d[1] = 1.0 / src->d[1];
+   dst->d[2] = 1.0 / src->d[2];
+   dst->d[3] = 1.0 / src->d[3];
+}
+
+static void
+micro_dsqrt(union tgsi_double_channel *dst,
+            const union tgsi_double_channel *src)
+{
+   dst->d[0] = sqrt(src->d[0]);
+   dst->d[1] = sqrt(src->d[1]);
+   dst->d[2] = sqrt(src->d[2]);
+   dst->d[3] = sqrt(src->d[3]);
+}
+
+static void
 micro_exp2(union tgsi_exec_channel *dst,
            const union tgsi_exec_channel *src)
 {
@@ -3729,7 +3819,44 @@ exec_instruction(
       exec_double_binary(mach, inst, micro_dadd);
       break;
 
+   case TGSI_OPCODE_DDIV:
+      exec_double_binary(mach, inst, micro_ddiv);
+      break;
+
+   case TGSI_OPCODE_DMUL:
+      exec_double_binary(mach, inst, micro_dmul);
+      break;
+
+   case TGSI_OPCODE_DMAX:
+      exec_double_binary(mach, inst, micro_dmax);
+      break;
+
+   case TGSI_OPCODE_DMIN:
+      exec_double_binary(mach, inst, micro_dmin);
+      break;
+
+   case TGSI_OPCODE_DSLT:
+      exec_double_binary(mach, inst, micro_dslt);
+      break;
+
+   case TGSI_OPCODE_DSGE:
+      exec_double_binary(mach, inst, micro_dsge);
+      break;
+
+   case TGSI_OPCODE_DSEQ:
+      exec_double_binary(mach, inst, micro_dseq);
+      break;
+
+   case TGSI_OPCODE_DRCP:
+      exec_double_unary(mach, inst, micro_drcp);
+      break;
+
+   case TGSI_OPCODE_DSQRT:
+      exec_double_unary(mach, inst, micro_dsqrt);
+      break;
+
    default:
+      printf("%d", inst->Instruction.Opcode);
       assert( 0 );
    }
 }
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c
index c02b29c..6403e61 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
@@ -179,7 +179,16 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
    { 1, 1, 0, 0, 0, 0, "F2D", TGSI_OPCODE_F2D },
    { 1, 1, 0, 0, 0, 0, "D2F", TGSI_OPCODE_D2F },
    { 1, 1, 0, 0, 0, 0, "DMOV", TGSI_OPCODE_DMOV },
-   { 1, 2, 0, 0, 0, 0, "DADD", TGSI_OPCODE_DADD }
+   { 1, 2, 0, 0, 0, 0, "DADD", TGSI_OPCODE_DADD },
+   { 1, 2, 0, 0, 0, 0, "DDIV", TGSI_OPCODE_DDIV },
+   { 1, 2, 0, 0, 0, 0, "DMUL", TGSI_OPCODE_DMUL },
+   { 1, 2, 0, 0, 0, 0, "DMAX", TGSI_OPCODE_DMAX },
+   { 1, 2, 0, 0, 0, 0, "DMIN", TGSI_OPCODE_DMIN },
+   { 1, 2, 0, 0, 0, 0, "DSLT", TGSI_OPCODE_DSLT },
+   { 1, 2, 0, 0, 0, 0, "DSGE", TGSI_OPCODE_DSGE },
+   { 1, 2, 0, 0, 0, 0, "DSEQ", TGSI_OPCODE_DSEQ },
+   { 1, 1, 0, 0, 0, 0, "DRCP", TGSI_OPCODE_DRCP },
+   { 1, 1, 0, 0 ,0, 0, "DSQRT", TGSI_OPCODE_DSQRT }
 };
 
 const struct tgsi_opcode_info *




More information about the mesa-commit mailing list