diff options
author | Brian Paul <brianp@vmware.com> | 2008-12-31 16:49:58 -0700 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2009-01-05 15:46:24 +0800 |
commit | 815f6664389fc51245cc1451225e1714d8daa7bf (patch) | |
tree | 4b083491c17a28855ccffa11a8ae8591f94ce598 | |
parent | 33459bcacea47ff6c32de9b29a99514cfc820c72 (diff) |
i965: implement OPCODE_NRM3/NRM4
-rw-r--r-- | 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 4a9541378f..b594e479de 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) |