[Mesa-dev] [PATCH 3/8] i965: Fix message and response length calculations for INT DIV.

Kenneth Graunke kenneth at whitecape.org
Wed Sep 28 17:37:52 PDT 2011


Both POW and INT DIV need a message length of 2; previously, we only
checked for POW.

Also, BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER has a response
length of 2; previously, we only checked for SINCOS.  We don't use this
message, but in case we ever decide to, we may as well fix it now.

While we're at it, just move these computations into
brw_set_math_message, since they're entirely based on the function.
This fixes it for both brw_math and the old backend's brw_math_16.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_eu_emit.c |   38 ++++++++++++++++++++++--------
 1 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 52ed21b..2d43c3c 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -374,8 +374,6 @@ void brw_set_src1(struct brw_compile *p,
 
 static void brw_set_math_message( struct brw_compile *p,
 				  struct brw_instruction *insn,
-				  GLuint msg_length,
-				  GLuint response_length,
 				  GLuint function,
 				  GLuint integer_type,
 				  GLboolean low_precision,
@@ -384,8 +382,34 @@ static void brw_set_math_message( struct brw_compile *p,
 {
    struct brw_context *brw = p->brw;
    struct intel_context *intel = &brw->intel;
-   brw_set_src1(p, insn, brw_imm_d(0));
+   unsigned msg_length;
+   unsigned response_length;
+
+   /* Infer message length from the function */
+   switch (function) {
+   case BRW_MATH_FUNCTION_POW:
+   case BRW_MATH_FUNCTION_INT_DIV_QUOTIENT:
+   case BRW_MATH_FUNCTION_INT_DIV_REMAINDER:
+   case BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER:
+      msg_length = 2;
+      break;
+   default:
+      msg_length = 1;
+      break;
+   }
+
+   /* Infer response length from the function */
+   switch (function) {
+   case BRW_MATH_FUNCTION_SINCOS:
+   case BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER:
+      response_length = 2;
+      break;
+   default:
+      response_length = 1;
+      break;
+   }
 
+   brw_set_src1(p, insn, brw_imm_d(0));
    if (intel->gen == 5) {
        insn->bits3.math_gen5.function = function;
        insn->bits3.math_gen5.int_type = integer_type;
@@ -1497,8 +1521,7 @@ void brw_math( struct brw_compile *p,
       brw_set_src1(p, insn, brw_null_reg());
    } else {
       struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
-      GLuint msg_length = (function == BRW_MATH_FUNCTION_POW) ? 2 : 1;
-      GLuint response_length = (function == BRW_MATH_FUNCTION_SINCOS) ? 2 : 1;
+
       /* Example code doesn't set predicate_control for send
        * instructions.
        */
@@ -1509,7 +1532,6 @@ void brw_math( struct brw_compile *p,
       brw_set_src0(p, insn, src);
       brw_set_math_message(p,
 			   insn,
-			   msg_length, response_length,
 			   function,
 			   BRW_MATH_INTEGER_UNSIGNED,
 			   precision,
@@ -1581,8 +1603,6 @@ void brw_math_16( struct brw_compile *p,
 {
    struct intel_context *intel = &p->brw->intel;
    struct brw_instruction *insn;
-   GLuint msg_length = (function == BRW_MATH_FUNCTION_POW) ? 2 : 1; 
-   GLuint response_length = (function == BRW_MATH_FUNCTION_SINCOS) ? 2 : 1; 
 
    if (intel->gen >= 6) {
       insn = next_insn(p, BRW_OPCODE_MATH);
@@ -1616,7 +1636,6 @@ void brw_math_16( struct brw_compile *p,
    brw_set_src0(p, insn, src);
    brw_set_math_message(p,
 			insn, 
-			msg_length, response_length, 
 			function,
 			BRW_MATH_INTEGER_UNSIGNED,
 			precision,
@@ -1633,7 +1652,6 @@ void brw_math_16( struct brw_compile *p,
    brw_set_src0(p, insn, src);
    brw_set_math_message(p, 
 			insn, 
-			msg_length, response_length, 
 			function,
 			BRW_MATH_INTEGER_UNSIGNED,
 			precision,
-- 
1.7.6.1



More information about the mesa-dev mailing list