summaryrefslogtreecommitdiff
path: root/src/mesa/shader/prog_execute.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader/prog_execute.c')
-rw-r--r--src/mesa/shader/prog_execute.c116
1 files changed, 45 insertions, 71 deletions
diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c
index a93733c085..c8a762f8ff 100644
--- a/src/mesa/shader/prog_execute.c
+++ b/src/mesa/shader/prog_execute.c
@@ -186,30 +186,6 @@ get_dst_register_pointer(const struct prog_dst_register *dest,
-#if FEATURE_MESA_program_debug
-static struct gl_program_machine *CurrentMachine = NULL;
-
-/**
- * For GL_MESA_program_debug.
- * Return current value (4*GLfloat) of a program register.
- * Called via ctx->Driver.GetProgramRegister().
- */
-void
-_mesa_get_program_register(GLcontext *ctx, enum register_file file,
- GLuint index, GLfloat val[4])
-{
- if (CurrentMachine) {
- struct prog_src_register srcReg;
- const GLfloat *src;
- srcReg.File = file;
- srcReg.Index = index;
- src = get_src_register_pointer(&srcReg, CurrentMachine);
- COPY_4V(val, src);
- }
-}
-#endif /* FEATURE_MESA_program_debug */
-
-
/**
* Fetch a 4-element float vector from the given source register.
* Apply swizzling and negating as needed.
@@ -236,24 +212,26 @@ fetch_vector4(const struct prog_src_register *source,
result[3] = src[GET_SWZ(source->Swizzle, 3)];
}
- if (source->NegateBase) {
- result[0] = -result[0];
- result[1] = -result[1];
- result[2] = -result[2];
- result[3] = -result[3];
- }
if (source->Abs) {
result[0] = FABSF(result[0]);
result[1] = FABSF(result[1]);
result[2] = FABSF(result[2]);
result[3] = FABSF(result[3]);
}
- if (source->NegateAbs) {
+ if (source->Negate) {
+ ASSERT(source->Negate == NEGATE_XYZW);
result[0] = -result[0];
result[1] = -result[1];
result[2] = -result[2];
result[3] = -result[3];
}
+
+#ifdef NAN_CHECK
+ assert(!IS_INF_OR_NAN(result[0]));
+ assert(!IS_INF_OR_NAN(result[0]));
+ assert(!IS_INF_OR_NAN(result[0]));
+ assert(!IS_INF_OR_NAN(result[0]));
+#endif
}
@@ -283,7 +261,7 @@ fetch_vector4ui(const struct prog_src_register *source,
result[3] = src[GET_SWZ(source->Swizzle, 3)];
}
- /* Note: no NegateBase, Abs, NegateAbs here */
+ /* Note: no Negate or Abs here */
}
@@ -323,19 +301,14 @@ fetch_vector4_deriv(GLcontext * ctx,
result[2] = deriv[GET_SWZ(source->Swizzle, 2)];
result[3] = deriv[GET_SWZ(source->Swizzle, 3)];
- if (source->NegateBase) {
- result[0] = -result[0];
- result[1] = -result[1];
- result[2] = -result[2];
- result[3] = -result[3];
- }
if (source->Abs) {
result[0] = FABSF(result[0]);
result[1] = FABSF(result[1]);
result[2] = FABSF(result[2]);
result[3] = FABSF(result[3]);
}
- if (source->NegateAbs) {
+ if (source->Negate) {
+ ASSERT(source->Negate == NEGATE_XYZW);
result[0] = -result[0];
result[1] = -result[1];
result[2] = -result[2];
@@ -360,13 +333,10 @@ fetch_vector1(const struct prog_src_register *source,
result[0] = src[GET_SWZ(source->Swizzle, 0)];
- if (source->NegateBase) {
- result[0] = -result[0];
- }
if (source->Abs) {
result[0] = FABSF(result[0]);
}
- if (source->NegateAbs) {
+ if (source->Negate) {
result[0] = -result[0];
}
}
@@ -516,6 +486,13 @@ store_vector4(const struct prog_instruction *inst,
}
}
+#ifdef NAN_CHECK
+ assert(!IS_INF_OR_NAN(value[0]));
+ assert(!IS_INF_OR_NAN(value[0]));
+ assert(!IS_INF_OR_NAN(value[0]));
+ assert(!IS_INF_OR_NAN(value[0]));
+#endif
+
if (writeMask & WRITEMASK_X)
dst[0] = value[0];
if (writeMask & WRITEMASK_Y)
@@ -633,10 +610,6 @@ _mesa_execute_program(GLcontext * ctx,
printf("execute program %u --------------------\n", program->Id);
}
-#if FEATURE_MESA_program_debug
- CurrentMachine = machine;
-#endif
-
if (program->Target == GL_VERTEX_PROGRAM_ARB) {
machine->EnvParams = ctx->VertexProgram.Parameters;
}
@@ -647,15 +620,6 @@ _mesa_execute_program(GLcontext * ctx,
for (pc = 0; pc < numInst; pc++) {
const struct prog_instruction *inst = program->Instructions + pc;
-#if FEATURE_MESA_program_debug
- if (ctx->FragmentProgram.CallbackEnabled &&
- ctx->FragmentProgram.Callback) {
- ctx->FragmentProgram.CurrentPosition = inst->StringPos;
- ctx->FragmentProgram.Callback(program->Target,
- ctx->FragmentProgram.CallbackData);
- }
-#endif
-
if (DEBUG_PROG) {
_mesa_print_instruction(inst);
}
@@ -873,7 +837,7 @@ _mesa_execute_program(GLcontext * ctx,
* result.z = result.x * APPX(result.y)
* We do what the ARB extension says.
*/
- q[2] = (GLfloat) pow(2.0, t[0]);
+ q[2] = (GLfloat) _mesa_pow(2.0, t[0]);
}
q[1] = t[0] - floor_t0;
q[3] = 1.0F;
@@ -882,10 +846,14 @@ _mesa_execute_program(GLcontext * ctx,
break;
case OPCODE_EX2: /* Exponential base 2 */
{
- GLfloat a[4], result[4];
+ GLfloat a[4], result[4], val;
fetch_vector1(&inst->SrcReg[0], machine, a);
- result[0] = result[1] = result[2] = result[3] =
- (GLfloat) _mesa_pow(2.0, a[0]);
+ val = (GLfloat) _mesa_pow(2.0, a[0]);
+ /*
+ if (IS_INF_OR_NAN(val))
+ val = 1.0e10;
+ */
+ result[0] = result[1] = result[2] = result[3] = val;
store_vector4(inst, machine, result);
}
break;
@@ -954,6 +922,11 @@ _mesa_execute_program(GLcontext * ctx,
{
GLfloat a[4];
fetch_vector4(&inst->SrcReg[0], machine, a);
+ if (DEBUG_PROG) {
+ printf("KIL if (%g %g %g %g) <= 0.0\n",
+ a[0], a[1], a[2], a[3]);
+ }
+
if (a[0] < 0.0F || a[1] < 0.0F || a[2] < 0.0F || a[3] < 0.0F) {
return GL_FALSE;
}
@@ -961,12 +934,17 @@ _mesa_execute_program(GLcontext * ctx,
break;
case OPCODE_LG2: /* log base 2 */
{
- GLfloat a[4], result[4];
+ GLfloat a[4], result[4], val;
fetch_vector1(&inst->SrcReg[0], machine, a);
/* The fast LOG2 macro doesn't meet the precision requirements.
*/
- result[0] = result[1] = result[2] = result[3] =
- (log(a[0]) * 1.442695F);
+ if (a[0] == 0.0F) {
+ val = 0.0F;
+ }
+ else {
+ val = log(a[0]) * 1.442695F;
+ }
+ result[0] = result[1] = result[2] = result[3] = val;
store_vector4(inst, machine, result);
}
break;
@@ -986,7 +964,7 @@ _mesa_execute_program(GLcontext * ctx,
if (a[1] == 0.0 && a[3] == 0.0)
result[2] = 1.0;
else
- result[2] = EXPF(a[3] * LOGF(a[1]));
+ result[2] = (GLfloat) _mesa_pow(a[1], a[3]);
}
else {
result[2] = 0.0;
@@ -1551,7 +1529,7 @@ _mesa_execute_program(GLcontext * ctx,
ASSERT(swz <= 3);
result[i] = src[swz];
}
- if (source->NegateBase & (1 << i))
+ if (source->Negate & (1 << i))
result[i] = -result[i];
}
store_vector4(inst, machine, result);
@@ -1577,8 +1555,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_TXB: /* GL_ARB_fragment_program only */
/* Texel lookup with LOD bias */
{
- const struct gl_texture_unit *texUnit
- = &ctx->Texture.Unit[inst->TexSrcUnit];
+ const GLuint unit = machine->Samplers[inst->TexSrcUnit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
GLfloat texcoord[4], color[4], lodBias;
fetch_vector4(&inst->SrcReg[0], machine, texcoord);
@@ -1780,9 +1758,5 @@ _mesa_execute_program(GLcontext * ctx,
} /* for pc */
-#if FEATURE_MESA_program_debug
- CurrentMachine = NULL;
-#endif
-
return GL_TRUE;
}