Mesa (master): ir_to_mesa: Don't assertion fail on integer modulus.

Kenneth Graunke kwg at kemper.freedesktop.org
Mon Oct 3 00:02:36 UTC 2011


Module: Mesa
Branch: master
Commit: e66fc1cb035caa5375c4ef3578420476ea94d371
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e66fc1cb035caa5375c4ef3578420476ea94d371

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Wed Sep 28 17:37:50 2011 -0700

ir_to_mesa: Don't assertion fail on integer modulus.

Drivers implementing GLSL 1.30 want to do integer modulus, and until we
can stop generating code via ir_to_mesa, it's easier to make it silently
generate rubbish code.  Multiply will do.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Tested-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/mesa/program/ir_to_mesa.cpp |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 5992e20..033ef38 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1261,8 +1261,11 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
       break;
    case ir_binop_div:
       assert(!"not reached: should be handled by ir_div_to_mul_rcp");
+      break;
    case ir_binop_mod:
-      assert(!"ir_binop_mod should have been converted to b * fract(a/b)");
+      /* Floating point should be lowered by MOD_TO_FRACT in the compiler. */
+      assert(ir->type->is_integer());
+      emit(ir, OPCODE_MUL, result_dst, op[0], op[1]);
       break;
 
    case ir_binop_less:




More information about the mesa-commit mailing list