i965: implement OPCODE_NRM3/NRM4

This commit is contained in:
Brian Paul 2008-12-31 16:49:58 -07:00
parent 23b0ad4d7e
commit 131ac5b465

View file

@ -591,6 +591,31 @@ 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!
*/
static struct brw_reg get_reg( struct brw_vs_compile *c,
@ -1019,6 +1044,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;
@ -1145,11 +1176,10 @@ void brw_vs_emit(struct brw_vs_compile *c )
/* no-op instructions */
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)