diff --git a/src/mesa/drivers/dri/i915tex/i915_fragprog.c b/src/mesa/drivers/dri/i915tex/i915_fragprog.c index a4b22a0..feed41e 100644 --- a/src/mesa/drivers/dri/i915tex/i915_fragprog.c +++ b/src/mesa/drivers/dri/i915tex/i915_fragprog.c @@ -316,11 +316,29 @@ upload_program(struct i915_fragment_program *p) case OPCODE_COS: src0 = src_vector(p, &inst->SrcReg[0], program); tmp = i915_get_utemp(p); + + // perform range reduction + i915_emit_arith(p, + A0_MAD, + tmp, A0_DEST_CHANNEL_X, 0, + src0, i915_emit_const1f(p, 0.159154943), + i915_emit_const1f(p, 0.5)); + + i915_emit_arith(p, + A0_FRC, + tmp, A0_DEST_CHANNEL_X, 0, + tmp, 0, 0); + + i915_emit_arith(p, + A0_MAD, + tmp, A0_DEST_CHANNEL_X, 0, + tmp, i915_emit_const1f(p, 6.283185307), + i915_emit_const1f(p, -3.141592654)); i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - src0, i915_emit_const1f(p, 1.0 / (M_PI * 2)), 0); + tmp, i915_emit_const1f(p, 1.0 / (M_PI * 2)), 0); i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0); @@ -639,10 +657,28 @@ upload_program(struct i915_fragment_program *p) src0 = src_vector(p, &inst->SrcReg[0], program); tmp = i915_get_utemp(p); + // perform range reduction + i915_emit_arith(p, + A0_MAD, + tmp, A0_DEST_CHANNEL_X, 0, + src0, i915_emit_const1f(p, 0.159154943), + i915_emit_const1f(p, 0.5)); + + i915_emit_arith(p, + A0_FRC, + tmp, A0_DEST_CHANNEL_X, 0, + tmp, 0, 0); + + i915_emit_arith(p, + A0_MAD, + tmp, A0_DEST_CHANNEL_X, 0, + tmp, i915_emit_const1f(p, 6.283185307), + i915_emit_const1f(p, -3.141592654)); + i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - src0, i915_emit_const1f(p, 1.0 / (M_PI * 2)), 0); + tmp, i915_emit_const1f(p, 1.0 / (M_PI * 2)), 0); i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0);