Mesa (intel-2008-q4): i965: implement OPCODE_NRM3/NRM4
Haihao Xiang
haihao at kemper.freedesktop.org
Mon Jan 5 08:06:24 UTC 2009
Module: Mesa
Branch: intel-2008-q4
Commit: 815f6664389fc51245cc1451225e1714d8daa7bf
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=815f6664389fc51245cc1451225e1714d8daa7bf
Author: Brian Paul <brianp at vmware.com>
Date: Wed Dec 31 16:49:58 2008 -0700
i965: implement OPCODE_NRM3/NRM4
---
src/mesa/drivers/dri/i965/brw_vs_emit.c | 33 ++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c
index 4a95413..b594e47 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c
@@ -596,7 +596,29 @@ static void emit_lit_noalias( struct brw_vs_compile *c,
}
+/** 3 or 4-component vector normalization */
+static void emit_nrm( struct brw_vs_compile *c,
+ struct brw_reg dst,
+ struct brw_reg arg0,
+ int num_comps)
+{
+ struct brw_compile *p = &c->func;
+ struct brw_reg tmp = get_tmp(c);
+
+ /* tmp = dot(arg0, arg0) */
+ if (num_comps == 3)
+ brw_DP3(p, tmp, arg0, arg0);
+ else
+ brw_DP4(p, tmp, arg0, arg0);
+ /* tmp = 1 / tmp */
+ emit_math1(c, BRW_MATH_FUNCTION_RSQ, tmp, tmp, BRW_MATH_PRECISION_FULL);
+
+ /* dst = arg0 * tmp */
+ brw_MUL(p, dst, arg0, tmp);
+
+ release_tmp(c, tmp);
+}
/* TODO: relative addressing!
@@ -1035,6 +1057,12 @@ void brw_vs_emit(struct brw_vs_compile *c )
case OPCODE_DPH:
brw_DPH(p, dst, args[0], args[1]);
break;
+ case OPCODE_NRM3:
+ emit_nrm(c, dst, args[0], 3);
+ break;
+ case OPCODE_NRM4:
+ emit_nrm(c, dst, args[0], 4);
+ break;
case OPCODE_DST:
unalias2(c, dst, args[0], args[1], emit_dst_noalias);
break;
@@ -1160,11 +1188,10 @@ void brw_vs_emit(struct brw_vs_compile *c )
case OPCODE_ENDSUB:
break;
default:
- _mesa_printf("Unsupported opcode %i (%s) in vertex shader\n",
- inst->Opcode, inst->Opcode < MAX_OPCODE ?
+ _mesa_problem(NULL, "Unsupported opcode %i (%s) in vertex shader",
+ inst->Opcode, inst->Opcode < MAX_OPCODE ?
_mesa_opcode_string(inst->Opcode) :
"unknown");
- break;
}
if ((inst->DstReg.File == PROGRAM_OUTPUT)
More information about the mesa-commit
mailing list