Skip to content

Commit

Permalink
Implemented fragment program version of NRM in nv2 profile.
Browse files Browse the repository at this point in the history
--HG--
branch : trunk
  • Loading branch information
icculus committed Jun 20, 2008
1 parent 09016a5 commit bf6294f
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions mojoshader.c
Expand Up @@ -4219,15 +4219,22 @@ EMIT_ARB1_OPCODE_DS_FUNC(ABS)

static void emit_ARB1_NRM(Context *ctx)
{
const char *dst = make_ARB1_destarg_string(ctx);
const char *src0 = make_ARB1_srcarg_string(ctx, 0);
const char *scratch = allocate_ARB1_scratch_reg_name(ctx);
output_line(ctx, "DP3 %s.w, %s, %s;", scratch, src0, src0);
output_line(ctx, "RSQ %s.w, %s.w;", scratch, scratch);
output_line(ctx, "MUL%s, %s.w, %s;", dst, scratch, src0);
emit_ARB1_dest_modifiers(ctx);
// nv2 fragment programs have a real NRM.
if ( (ctx->support_nv2) && (shader_is_pixel(ctx)) )
emit_ARB1_opcode_ds(ctx, "NRM");
else
{
const char *dst = make_ARB1_destarg_string(ctx);
const char *src0 = make_ARB1_srcarg_string(ctx, 0);
const char *scratch = allocate_ARB1_scratch_reg_name(ctx);
output_line(ctx, "DP3 %s.w, %s, %s;", scratch, src0, src0);
output_line(ctx, "RSQ %s.w, %s.w;", scratch, scratch);
output_line(ctx, "MUL%s, %s.w, %s;", dst, scratch, src0);
emit_ARB1_dest_modifiers(ctx);
} // else
} // emit_ARB1_NRM


static void emit_ARB1_SINCOS(Context *ctx)
{
// we don't care about the temp registers that <= sm2 demands; ignore them.
Expand Down Expand Up @@ -4319,6 +4326,7 @@ static void emit_ARB1_SINCOS(Context *ctx)
emit_ARB1_dest_modifiers(ctx);
} // emit_ARB1_SINCOS


static void emit_ARB1_REP(Context *ctx)
{
const char *src0 = make_ARB1_srcarg_string(ctx, 0);
Expand Down

0 comments on commit bf6294f

Please sign in to comment.