glsl: Don't use MOD_TO_FRACT lowering on GLSL 1.30's % operator.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 15 Jun 2011 06:13:27 +0000 (23:13 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 29 Jun 2011 23:07:13 +0000 (16:07 -0700)
MOD_TO_FRACT was designed to lower the GLSL 1.20 mod() function, which
operates on floating point values.  However, we also use ir_binop_mod
for GLSL 1.30's % operator, which operates on integers.

For now, make MOD_TO_FRACT only apply to floating-point mod operations.
In the future, we may want to add a lowering pass for integer-based mod.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/glsl/lower_instructions.cpp

index 94b8c4a6836d292b2c718b42a33d4f26e25f6102..806f86399599669364377e4635cc221fb352ca1c 100644 (file)
@@ -276,7 +276,7 @@ lower_instructions_visitor::visit_leave(ir_expression *ir)
       break;
 
    case ir_binop_mod:
-      if (lowering(MOD_TO_FRACT))
+      if (lowering(MOD_TO_FRACT) && ir->type->is_float())
         mod_to_fract(ir);
       break;