Mesa (gallium-0.2): mesa: add GLSL support for DP2, NRM3, NRM4 instructions (not actually emitted yet though)

Brian Paul brianp at kemper.freedesktop.org
Fri Nov 7 17:20:36 UTC 2008


Module: Mesa
Branch: gallium-0.2
Commit: a98a25c25ff1ec3be74cf9c5f027b85a297c3e78
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a98a25c25ff1ec3be74cf9c5f027b85a297c3e78

Author: Brian Paul <brian.paul at tungstengraphics.com>
Date:   Fri Nov  7 09:49:26 2008 -0700

mesa: add GLSL support for DP2, NRM3, NRM4 instructions (not actually emitted yet though)

---

 src/mesa/shader/slang/slang_codegen.c |    3 +++
 src/mesa/shader/slang/slang_emit.c    |    8 +++++++-
 src/mesa/shader/slang/slang_ir.c      |    7 +++++--
 src/mesa/shader/slang/slang_ir.h      |    3 +++
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index d83e3b0..ea35d67 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -413,6 +413,9 @@ static slang_asm_info AsmInfo[] = {
    { "vec4_multiply", IR_MUL, 1, 2 },
    { "vec4_dot", IR_DOT4, 1, 2 },
    { "vec3_dot", IR_DOT3, 1, 2 },
+   { "vec2_dot", IR_DOT2, 1, 2 },
+   { "vec3_nrm", IR_NRM3, 1, 1 },
+   { "vec4_nrm", IR_NRM4, 1, 1 },
    { "vec3_cross", IR_CROSS, 1, 2 },
    { "vec4_lrp", IR_LRP, 1, 3 },
    { "vec4_min", IR_MIN, 1, 2 },
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index 672ec4b..827760c 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -488,6 +488,9 @@ instruction_annotation(gl_inst_opcode opcode, char *dstAnnot,
    case OPCODE_MUL:
       operator = "*";
       break;
+   case OPCODE_DP2:
+      operator = "DP2";
+      break;
    case OPCODE_DP3:
       operator = "DP3";
       break;
@@ -708,7 +711,7 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
       }
       else {
          assert(size == 2);
-         dotOp = OPCODE_DP3;
+         dotOp = OPCODE_DP3; /* XXX use OPCODE_DP2 eventually */
          swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y);
       }
 
@@ -1893,12 +1896,15 @@ emit(slang_emit_info *emitInfo, slang_ir_node *n)
    case IR_NOISE2:
    case IR_NOISE3:
    case IR_NOISE4:
+   case IR_NRM4:
+   case IR_NRM3:
    /* binary */
    case IR_ADD:
    case IR_SUB:
    case IR_MUL:
    case IR_DOT4:
    case IR_DOT3:
+   case IR_DOT2:
    case IR_CROSS:
    case IR_MIN:
    case IR_MAX:
diff --git a/src/mesa/shader/slang/slang_ir.c b/src/mesa/shader/slang/slang_ir.c
index 711ee51..9d055bf 100644
--- a/src/mesa/shader/slang/slang_ir.c
+++ b/src/mesa/shader/slang/slang_ir.c
@@ -37,8 +37,11 @@ static const slang_ir_info IrInfo[] = {
    { IR_SUB, "IR_SUB", OPCODE_SUB, 4, 2 },
    { IR_MUL, "IR_MUL", OPCODE_MUL, 4, 2 },
    { IR_DIV, "IR_DIV", OPCODE_NOP, 0, 2 }, /* XXX broke */
-   { IR_DOT4, "IR_DOT_4", OPCODE_DP4, 1, 2 },
-   { IR_DOT3, "IR_DOT_3", OPCODE_DP3, 1, 2 },
+   { IR_DOT4, "IR_DOT4", OPCODE_DP4, 1, 2 },
+   { IR_DOT3, "IR_DOT3", OPCODE_DP3, 1, 2 },
+   { IR_DOT2, "IR_DOT2", OPCODE_DP2, 1, 2 },
+   { IR_NRM4, "IR_NRM4", OPCODE_NRM4, 1, 1 },
+   { IR_NRM3, "IR_NRM3", OPCODE_NRM3, 1, 1 },
    { IR_CROSS, "IR_CROSS", OPCODE_XPD, 3, 2 },
    { IR_LRP, "IR_LRP", OPCODE_LRP, 4, 3 },
    { IR_MIN, "IR_MIN", OPCODE_MIN, 4, 2 },
diff --git a/src/mesa/shader/slang/slang_ir.h b/src/mesa/shader/slang/slang_ir.h
index f64f9a9..ab0353c 100644
--- a/src/mesa/shader/slang/slang_ir.h
+++ b/src/mesa/shader/slang/slang_ir.h
@@ -83,6 +83,9 @@ typedef enum
    IR_DIV,
    IR_DOT4,
    IR_DOT3,
+   IR_DOT2,
+   IR_NRM4,
+   IR_NRM3,
    IR_CROSS,   /* vec3 cross product */
    IR_LRP,
    IR_CLAMP,




More information about the mesa-commit mailing list