On 15 September 2012 21:25, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In the past, we stored booleans as integer 0 or 1.  At some point, we<br>
changed to storing them as 0 or some non-zero value.</blockquote><div><br>Nit-pick: I'm assuming this means "0 is treated as false, and all nonzero values are treated as true".  But that can't be right, since resolve_bool_comparison() computes (x & 1).  Do we only use a subset of the possible nonzero values to represent true?  (If so it would be nice to document that in resolve_bool_comparison())  Or is resolve_bool_comparison() wrong?<br>
<br>In any case this change seems correct, so:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br><br>Note: I believe the case for ir_binop_logic_xor (in the same function) also needs fixing, since it treats "if (x ^ y)" as "if (x != y)".  That won't work if x and y use different representations of true.<br>
 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">  The Sandybridge<br>
specific code for emitting IF instructions with embedded conditional<br>
modifiers was not updated to account for this change.<br>
<br>
For code such as<br>
<br>
   if (bool_a == bool_b)<br>
<br>
we cannot simply emit an equality comparison: even if both operands are<br>
true, they may be represented by two different non-zero values.  We must<br>
first normalize them to 0 or 1 so that they can be compared properly.<br>
<br>
Fixes piglit test spec/glsl-1.10/execution/fs-bool-less-compare-true.<br>
Fixes at least 9 subcases of oglconform's shad-compiler test:<br>
- TestLessThanEquali<br>
- TestGreaterThan<br>
- TestGreaterThani<br>
- TestGreaterThanEqual<br>
- TestGreaterThanEquali<br>
- TestEqualb<br>
- TestNotEqual<br>
- TestNotEquali<br>
- TestNotEqualb<br>
<br>
NOTE: This is a candidate for the 9.0 branch (but not 8.0).<br>
<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=54709" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=54709</a><br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=48629
Signed-off-by" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=48629<br>
Signed-off-by</a>: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 3 +++<br>
 1 file changed, 3 insertions(+)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
index d3cbde3..320e2f0 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
@@ -1650,6 +1650,9 @@ fs_visitor::emit_if_gen6(ir_if *ir)<br>
       case ir_binop_all_equal:<br>
       case ir_binop_nequal:<br>
       case ir_binop_any_nequal:<br>
+        resolve_bool_comparison(expr->operands[0], &op[0]);<br>
+        resolve_bool_comparison(expr->operands[1], &op[1]);<br>
+<br>
         inst = emit(BRW_OPCODE_IF, reg_null_d, op[0], op[1]);<br>
         inst->conditional_mod =<br>
            brw_conditional_for_comparison(expr->operation);<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.11.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br>