[Mesa-dev] [PATCH v2] glsl_to_tgsi, mesa: fixes for native integers and integer booleans

Bryan Cain bryancain3 at gmail.com
Sat Sep 3 21:40:32 PDT 2011


On 09/02/2011 06:13 PM, Eric Anholt wrote:
> On Wed, 31 Aug 2011 01:33:59 -0500, Bryan Cain <bryancain3 at gmail.com> wrote:
>> With this patch, there are no piglit regressions on softpipe with native
>> integers enabled.  Unlike my previous patch, this uses integer values of
>> ~0 and 0 for true and false, respectively, instead of the float values 1.0
>> and 0.0.
> This will break b2* conversions on our driver, since we expect true to
> be 1, not ~0.  The minimal change would require emit(AND(temp, uniform,
> 1)) when deferencing boolean components of uniform variables.

Your driver already emits an AND instruction on every compare, according
to this code from brw_fs_visitor.cpp:

   case ir_binop_less:
   case ir_binop_greater:
   case ir_binop_lequal:
   case ir_binop_gequal:
   case ir_binop_equal:
   case ir_binop_all_equal:
   case ir_binop_nequal:
   case ir_binop_any_nequal:
      temp = this->result;
      /* original gen4 does implicit conversion before comparison. */
      if (intel->gen < 5)
     temp.type = op[0].type;

      inst = emit(BRW_OPCODE_CMP, temp, op[0], op[1]);
      inst->conditional_mod = brw_conditional_for_comparison(ir->operation);
      emit(BRW_OPCODE_AND, this->result, this->result, fs_reg(0x1));
      break;

If the hardware sets ~0 on compares anyway, why not use that in your driver?


More information about the mesa-dev mailing list