On 31 October 2011 23:24, 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><div></div><div class="h5">On 10/31/2011 08:34 PM, Paul Berry wrote:<br>
&gt; When converting an expression like &quot;++x&quot; to GLSL IR we were failing to<br>
&gt; account for the possibility that x might be an unsigned integral type.<br>
&gt; As a result the user would receive a bogus error message &quot;Could not<br>
&gt; implicitly convert operands to arithmetic operator&quot;.<br>
&gt;<br>
&gt; Fixes piglit tests {vs,fs}-{increment,decrement}-uint.<br>
&gt; ---<br>
&gt;  src/glsl/ast_to_hir.cpp |   31 +++++++++++++++++++++++--------<br>
&gt;  1 files changed, 23 insertions(+), 8 deletions(-)<br>
&gt;<br>
&gt; diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp<br>
&gt; index 7584fdf..a4eec50 100644<br>
&gt; --- a/src/glsl/ast_to_hir.cpp<br>
&gt; +++ b/src/glsl/ast_to_hir.cpp<br>
&gt; @@ -935,6 +935,27 @@ check_builtin_array_max_size(const char *name, unsigned size,<br>
&gt;     return false;<br>
&gt;  }<br>
&gt;<br>
&gt; +/**<br>
&gt; + * Create the constant 1, with the given GLSL type, for use in increment and<br>
&gt; + * decrement operators.<br>
&gt; + *<br>
&gt; + * If the given type is invalid for increment and decrement operators, return<br>
&gt; + * a floating point 1--the error will be detected later.<br>
&gt; + */<br>
&gt; +static ir_rvalue *<br>
&gt; +constant_one_for_inc_dec(void *ctx, const glsl_type *type)<br>
&gt; +{<br>
&gt; +   switch (type-&gt;base_type) {<br>
&gt; +   case GLSL_TYPE_UINT:<br>
&gt; +      return new(ctx) ir_constant((unsigned) 1);<br>
&gt; +   case GLSL_TYPE_INT:<br>
&gt; +      return new(ctx) ir_constant(1);<br>
&gt; +   default:<br>
&gt; +   case GLSL_TYPE_FLOAT:<br>
&gt; +      return new(ctx) ir_constant(1.0f);<br>
&gt; +   }<br>
&gt; +}<br>
<br>
</div></div>Perhaps it would be cleaner to add a new ir_constant::one static method<br>
similar to ir_constant::zero?  There&#39;s nothing really inc/dec specific<br>
about this, and it might be more useful in general...<br></blockquote><div><br>The difficulty is that this function doesn&#39;t actually return a constant 1 of the given type--it returns a constant 1 of a type which is suitable for incrementing and decrementing values of the given type.  For example, if type is vec4, this function creates a constant value of 1.0 having type float.  (My comments in the code seem to contradict this--I&#39;ll fix that).  IMHO, that makes this function specific enough to increment/decrement that it belongs here.<br>
</div></div>