mesa: added DP2, DP2A instructions
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 7 Nov 2008 16:41:00 +0000 (09:41 -0700)
committerBrian Paul <brian.paul@tungstengraphics.com>
Fri, 7 Nov 2008 16:51:25 +0000 (09:51 -0700)
src/mesa/shader/prog_execute.c
src/mesa/shader/prog_instruction.c
src/mesa/shader/prog_instruction.h

index b47421d5a11329702d4332cf3a70878cfc2ccae1..ef17ed128a79fc6d6a41de3ff27728cd079bda5b 100644 (file)
@@ -776,6 +776,33 @@ _mesa_execute_program(GLcontext * ctx,
             store_vector4(inst, machine, result);
          }
          break;
+      case OPCODE_DP2:
+         {
+            GLfloat a[4], b[4], result[4];
+            fetch_vector4(&inst->SrcReg[0], machine, a);
+            fetch_vector4(&inst->SrcReg[1], machine, b);
+            result[0] = result[1] = result[2] = result[3] = DOT2(a, b);
+            store_vector4(inst, machine, result);
+            if (DEBUG_PROG) {
+               printf("DP2 %g = (%g %g) . (%g %g)\n",
+                      result[0], a[0], a[1], b[0], b[1]);
+            }
+         }
+         break;
+      case OPCODE_DP2A:
+         {
+            GLfloat a[4], b[4], c, result[4];
+            fetch_vector4(&inst->SrcReg[0], machine, a);
+            fetch_vector4(&inst->SrcReg[1], machine, b);
+            fetch_vector1(&inst->SrcReg[1], machine, &c);
+            result[0] = result[1] = result[2] = result[3] = DOT2(a, b) + c;
+            store_vector4(inst, machine, result);
+            if (DEBUG_PROG) {
+               printf("DP2A %g = (%g %g) . (%g %g) + %g\n",
+                      result[0], a[0], a[1], b[0], b[1], c);
+            }
+         }
+         break;
       case OPCODE_DP3:
          {
             GLfloat a[4], b[4], result[4];
@@ -808,8 +835,7 @@ _mesa_execute_program(GLcontext * ctx,
             GLfloat a[4], b[4], result[4];
             fetch_vector4(&inst->SrcReg[0], machine, a);
             fetch_vector4(&inst->SrcReg[1], machine, b);
-            result[0] = result[1] = result[2] = result[3] =
-               a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + b[3];
+            result[0] = result[1] = result[2] = result[3] = DOT3(a, b) + b[3];
             store_vector4(inst, machine, result);
          }
          break;
index ac9d9e1bb7f2fcdcbb5e704b490e9e78b38922c5..54df3fb2e1547037c7238f4a9781b25d8c8fa2ad 100644 (file)
@@ -169,6 +169,8 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = {
    { OPCODE_COS,    "COS",     1, 1 },
    { OPCODE_DDX,    "DDX",     1, 1 },
    { OPCODE_DDY,    "DDY",     1, 1 },
+   { OPCODE_DP2,    "DP2",     2, 1 },
+   { OPCODE_DP2A,   "DP2A",    3, 1 },
    { OPCODE_DP3,    "DP3",     2, 1 },
    { OPCODE_DP4,    "DP4",     2, 1 },
    { OPCODE_DPH,    "DPH",     2, 1 },
index 2cb2014cd4852ea167f69b6710176245e17d138e..855a80e24245d4b8220a0cb9f8f2b3c2bb4ccf4a 100644 (file)
@@ -160,6 +160,8 @@ typedef enum prog_opcode {
    OPCODE_COS,       /*            X       2       X         X   */
    OPCODE_DDX,       /*                            X         X   */
    OPCODE_DDY,       /*                            X         X   */
+   OPCODE_DP2,       /*                            2             */
+   OPCODE_DP2A,      /*                            2             */
    OPCODE_DP3,       /*   X        X       X       X         X   */
    OPCODE_DP4,       /*   X        X       X       X         X   */
    OPCODE_DPH,       /*   X        X       1.1                   */