implement DDX, DDY instructions
authorBrian <brian.paul@tungstengraphics.com>
Wed, 25 Jul 2007 20:28:24 +0000 (14:28 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Wed, 25 Jul 2007 20:28:24 +0000 (14:28 -0600)
src/mesa/pipe/tgsi/core/tgsi_exec.c
src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c

index db965ccbecde73017c82af7d07fd8b5c6a62efba..6aaaef98a832277cfccc610ba371248fac13fe38 100644 (file)
@@ -228,6 +228,28 @@ micro_cos(
    dst->f[3] = (GLfloat) cos( (GLdouble) src->f[3] );
 }
 
+static void
+micro_ddx(
+   union tgsi_exec_channel *dst,
+   const union tgsi_exec_channel *src )
+{
+   dst->f[0] =
+   dst->f[1] =
+   dst->f[2] =
+   dst->f[3] = src->f[TILE_BOTTOM_RIGHT] - src->f[TILE_BOTTOM_LEFT];
+}
+
+static void
+micro_ddy(
+   union tgsi_exec_channel *dst,
+   const union tgsi_exec_channel *src )
+{
+   dst->f[0] =
+   dst->f[1] =
+   dst->f[2] =
+   dst->f[3] = src->f[TILE_TOP_LEFT] - src->f[TILE_BOTTOM_LEFT];
+}
+
 static void
 micro_div(
    union tgsi_exec_channel *dst,
@@ -1715,11 +1737,19 @@ exec_instruction(
       break;
 
    case TGSI_OPCODE_DDX:
-      assert (0);
+      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
+         FETCH( &r[0], 0, chan_index );
+         micro_ddx( &r[0], &r[0] );
+         STORE( &r[0], 0, chan_index );
+      }
       break;
 
    case TGSI_OPCODE_DDY:
-      assert (0);
+      FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
+         FETCH( &r[0], 0, chan_index );
+         micro_ddy( &r[0], &r[0] );
+         STORE( &r[0], 0, chan_index );
+      }
       break;
 
    case TGSI_OPCODE_KIL:
index 21b488c98f1bc8c7125ebfc264d74d6f18685f69..a9415ac15bc7dbcbf1c5450414f638b3a1d6ea3e 100644 (file)
@@ -261,6 +261,12 @@ compile_instruction(
    case OPCODE_DP3:\r
       fullinst->Instruction.Opcode = TGSI_OPCODE_DP3;\r
       break;\r
+   case OPCODE_DDX:\r
+      fullinst->Instruction.Opcode = TGSI_OPCODE_DDX;\r
+      break;\r
+   case OPCODE_DDY:\r
+      fullinst->Instruction.Opcode = TGSI_OPCODE_DDY;\r
+      break;\r
    case OPCODE_DP4:\r
       fullinst->Instruction.Opcode = TGSI_OPCODE_DP4;\r
       break;\r