On 4 October 2011 23:55, Kenneth Graunke <span dir="ltr">&lt;<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>&gt;</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;">
<div class="im">On 10/03/2011 03:41 PM, Eric Anholt wrote:<br>
</div><div class="im">&gt; The condmod instruction ends up generating garbage condition codes,<br>
&gt; because apparently the comparison happens on the accumulator value (33<br>
&gt; bits for UD), not the truncated value that would be written.<br>
&gt;<br>
&gt; Fixes fs-op-neg-*<br>
<br>
</div>I am uneasy about these two patches for a number of reasons.<br>
<br>
1. fs-op-neg-* and vs-op-neg-* fail on AMD (Catalyst 11.7),<br>
   which makes me wonder if the tests are correct.<br>
<br>
AMD does the expected behavior if you change the line:<br>
  uint result = (- arg0);<br>
to this:<br>
  uint result = uint(-int(arg0));<br>
or this:<br>
  uint result = 0 - arg0;<br>
<br>
While the GLSL spec isn&#39;t terribly clear about how unary negate works on<br>
unsigned, the fact -arg0 != 0 - arg0 seems horrendously broken.  So<br>
maybe AMD&#39;s driver is just buggy.<br>
<br></blockquote><div><br>I personally fall mostly on the &quot;AMD&#39;s driver is just buggy&quot; side of this argument.  My reasoning is based on this text from the GLSL 1.30 spec (section 4.1.3 &quot;Integers&quot;): &quot;Operations resulting in overflow or underflow will not cause any exception, nor will they saturate, rather they will “wrap” to yield the low-order 32 bits of the result.&quot;  So even though -1 is not representable in a uint, it seems reasonable to me that it should &quot;wrap&quot; to binary 11111111..., and so on.  But I admit we are in fairly dodgy territory here, trying to negate unsigned values :)<br>
</div></div>