i965: Always hand the absolute value to RSQ.
authorEric Anholt <eric@anholt.net>
Tue, 7 Dec 2010 20:34:30 +0000 (12:34 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 7 Dec 2010 21:13:27 +0000 (13:13 -0800)
gen6 builtin RSQ apparently clamps negative values to 0 instead of
returning the RSQ of the absolute value like ARB_fragment_program
desires and pre-gen6 apparently does.

Fixes:
glean/fp1-RSQ test 2 (reciprocal square root of negative value)
glean/vp1-RSQ test 2 (reciprocal square root of negative value)

src/mesa/drivers/dri/i965/brw_vs_emit.c
src/mesa/drivers/dri/i965/brw_wm_fp.c

index 407358f498f44e0df8297fe879fdf878ad585c1c..184452666a5b78784cda80c18470254c9a1e01b4 100644 (file)
@@ -1958,7 +1958,7 @@ void brw_vs_emit(struct brw_vs_compile *c )
         emit_math1(c, BRW_MATH_FUNCTION_INV, dst, args[0], BRW_MATH_PRECISION_FULL);
         break;
       case OPCODE_RSQ:
-        emit_math1(c, BRW_MATH_FUNCTION_RSQ, dst, args[0], BRW_MATH_PRECISION_FULL);
+        emit_math1(c, BRW_MATH_FUNCTION_RSQ, dst, brw_abs(args[0]), BRW_MATH_PRECISION_FULL);
         break;
 
       case OPCODE_SEQ:
index 36330c134e66bc024ee37c6eff34de778c6c9092..4759b289a0c87496cadda4b41da83fc0328c6edd 100644 (file)
@@ -1131,6 +1131,11 @@ void brw_wm_pass_fp( struct brw_wm_compile *c )
         precalc_lit(c, inst);
         break;
 
+      case OPCODE_RSQ:
+        out = emit_scalar_insn(c, inst);
+        out->SrcReg[0].Abs = GL_TRUE;
+        break;
+
       case OPCODE_TEX:
         precalc_tex(c, inst);
         break;