From 537acf092b8d188d691a86fd44a24f706eb88473 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 2 Jun 2008 17:40:44 -0400 Subject: [PATCH] Implemented DP2ADD in the arb1 profile. --HG-- branch : trunk --- mojoshader.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/mojoshader.c b/mojoshader.c index bfb880d8..f5b6ac94 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -4325,7 +4325,25 @@ static void emit_ARB1_CMP(Context *ctx) } // emit_ARB1_CMP EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(BEM) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(DP2ADD) + + +static void emit_ARB1_DP2ADD(Context *ctx) +{ + const char *dst = make_ARB1_destarg_string(ctx); + const char *src0 = make_ARB1_srcarg_string(ctx, 0); + const char *src1 = make_ARB1_srcarg_string(ctx, 1); + const char *src2 = make_ARB1_srcarg_string(ctx, 2); + const char *scratch = allocate_ARB1_scratch_reg_name(ctx); + + // DP2ADD is: + // dest = src0.r * src1.r + src0.g * src1.g + src2.replicate_swizzle + output_line(ctx, "MUL %s, %s, %s;", scratch, src0, src1); + output_line(ctx, "ADD %s, %s.x, %s.y;", scratch, scratch, scratch); + output_line(ctx, "ADD%s, %s.x, %s;", dst, scratch, src2); + emit_ARB1_dest_modifiers(ctx); +} // emit_ARB1_DP2ADD + + EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(DSX) EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(DSY) EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXLDD)