diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2006-10-22 23:21:45 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2006-10-22 23:21:45 +0000 |
commit | b9786cfaae3bd58d8e487846cfa9c251e1246abd (patch) | |
tree | 4fcbee36a5ec618094e71b7ba9dca3ffe7a7f074 /src/mesa | |
parent | 49a5a09adaac457860a8abb9d7b86f317353a23c (diff) |
assorted clean-ups
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/swrast/s_nvfragprog.c | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c index 01fa221fc6..e55fe5c851 100644 --- a/src/mesa/swrast/s_nvfragprog.c +++ b/src/mesa/swrast/s_nvfragprog.c @@ -699,7 +699,8 @@ execute_program( GLcontext *ctx, { GLfloat a[4], result[4]; fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a ); - result[0] = result[1] = result[2] = result[3] = (GLfloat)_mesa_cos(a[0]); + result[0] = result[1] = result[2] = result[3] + = (GLfloat) _mesa_cos(a[0]); store_vector4( inst, machine, result ); } break; @@ -753,8 +754,7 @@ execute_program( GLcontext *ctx, GLfloat a[4], b[4], result[4]; fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a ); fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b ); - result[0] = result[1] = result[2] = result[3] = - a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; + result[0] = result[1] = result[2] = result[3] = DOT3(a, b); store_vector4( inst, machine, result ); #if DEBUG_FRAG printf("DP3 %g = (%g %g %g) . (%g %g %g)\n", @@ -767,8 +767,7 @@ execute_program( GLcontext *ctx, GLfloat a[4], b[4], result[4]; fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a ); fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b ); - result[0] = result[1] = result[2] = result[3] = - a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; + result[0] = result[1] = result[2] = result[3] = DOT4(a,b); store_vector4( inst, machine, result ); #if DEBUG_FRAG printf("DP4 %g = (%g, %g %g %g) . (%g, %g %g %g)\n", @@ -854,8 +853,7 @@ execute_program( GLcontext *ctx, { GLfloat a[4], result[4]; fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a ); - result[0] = result[1] = result[2] = result[3] - = LOG2(a[0]); + result[0] = result[1] = result[2] = result[3] = LOG2(a[0]); store_vector4( inst, machine, result ); } break; @@ -1054,25 +1052,20 @@ execute_program( GLcontext *ctx, else if (IS_INF_OR_NAN(a[0])) printf("RCP(inf)\n"); #endif - result[0] = result[1] = result[2] = result[3] - = 1.0F / a[0]; + result[0] = result[1] = result[2] = result[3] = 1.0F / a[0]; store_vector4( inst, machine, result ); } break; - case OPCODE_RFL: + case OPCODE_RFL: /* reflection vector */ { - GLfloat axis[4], dir[4], result[4], tmp[4]; + GLfloat axis[4], dir[4], result[4], tmpX, tmpW; fetch_vector4( ctx, &inst->SrcReg[0], machine, program, axis ); fetch_vector4( ctx, &inst->SrcReg[1], machine, program, dir ); - tmp[3] = axis[0] * axis[0] - + axis[1] * axis[1] - + axis[2] * axis[2]; - tmp[0] = (2.0F * (axis[0] * dir[0] + - axis[1] * dir[1] + - axis[2] * dir[2])) / tmp[3]; - result[0] = tmp[0] * axis[0] - dir[0]; - result[1] = tmp[0] * axis[1] - dir[1]; - result[2] = tmp[0] * axis[2] - dir[2]; + tmpW = DOT3(axis, axis); + tmpX = (2.0F * DOT3(axis, dir)) / tmpW; + result[0] = tmpX * axis[0] - dir[0]; + result[1] = tmpX * axis[1] - dir[1]; + result[2] = tmpX * axis[2] - dir[2]; /* result[3] is never written! XXX enforce in parser! */ store_vector4( inst, machine, result ); } @@ -1146,8 +1139,8 @@ execute_program( GLcontext *ctx, { GLfloat a[4], result[4]; fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a ); - result[0] = result[1] = result[2] = - result[3] = (GLfloat)_mesa_sin(a[0]); + result[0] = result[1] = result[2] = result[3] + = (GLfloat) _mesa_sin(a[0]); store_vector4( inst, machine, result ); } break; @@ -1205,23 +1198,24 @@ execute_program( GLcontext *ctx, store_vector4( inst, machine, result ); } break; - case OPCODE_SWZ: + case OPCODE_SWZ: /* extended swizzle */ { const struct prog_src_register *source = &inst->SrcReg[0]; const GLfloat *src = get_register_pointer(ctx, source, machine, program); GLfloat result[4]; GLuint i; - - /* do extended swizzling here */ for (i = 0; i < 4; i++) { - if (GET_SWZ(source->Swizzle, i) == SWIZZLE_ZERO) + const GLuint swz = GET_SWZ(source->Swizzle, i); + if (swz == SWIZZLE_ZERO) result[i] = 0.0; - else if (GET_SWZ(source->Swizzle, i) == SWIZZLE_ONE) + else if (swz == SWIZZLE_ONE) result[i] = 1.0; - else - result[i] = src[GET_SWZ(source->Swizzle, i)]; - + else { + ASSERT(swz >= 0); + ASSERT(swz <= 3); + result[i] = src[swz]; + } if (source->NegateBase & (1 << i)) result[i] = -result[i]; } |