On 4 September 2011 14:49, Ian Romanick <span dir="ltr">&lt;<a href="mailto:idr@freedesktop.org">idr@freedesktop.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;">
-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA1<br>
<div class="im"><br>
On 09/04/2011 08:35 AM, Paul Berry wrote:<br>
&gt; On 4 September 2011 06:20, Christoph Bumiller<br>
</div>&gt; &lt;<a href="mailto:e0425955@student.tuwien.ac.at">e0425955@student.tuwien.ac.at</a> &lt;mailto:<a href="mailto:e0425955@student.tuwien.ac.at">e0425955@student.tuwien.ac.at</a>&gt;&gt;<br>
<div><div></div><div class="h5">&gt; wrote:<br>
&gt;<br>
&gt;     I encountered some failures in piglit&#39;s tests of builtins because a<br>
&gt;     vector constructor that is given only 1 single argument does not<br>
&gt;     replicate the argument into the yzw components, for example:<br>
&gt;<br>
&gt;     diff --git a/src/glsl/builtins/ir/cosh b/src/glsl/builtins/ir/cosh<br>
&gt;     index 45e0ae4..8bf3ad2 100644<br>
&gt;     --- a/src/glsl/builtins/ir/cosh<br>
&gt;     +++ b/src/glsl/builtins/ir/cosh<br>
&gt;     @@ -9,21 +9,21 @@<br>
&gt;        (signature vec2<br>
&gt;          (parameters<br>
&gt;            (declare (in) vec2 x))<br>
&gt;     -     ((return (expression vec2 * (constant vec2 (0.5))<br>
&gt;     +     ((return (expression vec2 * (constant vec2 (0.5, 0.5))<br>
&gt;                     (expression vec2 +<br>
&gt;                      (expression vec2 exp (var_ref x))<br>
&gt;                      (expression vec2 exp (expression vec2 neg (var_ref<br>
&gt;     x))))))))<br>
&gt;        (signature vec3<br>
&gt;          (parameters<br>
&gt;            (declare (in) vec3 x))<br>
&gt;<br>
&gt;     Should the constructors or should all the builtin files be fixed ?<br>
&gt;<br>
&gt;<br>
&gt; Thanks for noticing this, Christoph.  I wrote the tests for hyperbolic<br>
&gt; trig functions a few weeks ago, and I&#39;ve been waiting for some i965<br>
&gt; churn to settle down before looping back to fix the bugs.<br>
&gt;<br>
&gt; Personally, I&#39;d prefer to fix this bug by making the constant a scalar,<br>
&gt; like this:<br>
<br>
</div></div>I don&#39;t recall for sure, but, while that is valid GLSL, I don&#39;t think<br>
that&#39;s valid in the IR.  Did you try it?  I think you may have to wrap<br>
it in a swizzle, at which point it&#39;s probably better to use the correct<br>
vec# constructor.<br></blockquote><div><br>Yes, I did try it, and it worked just fine.  Furthermore, the code in ir_validate.cpp seems to indicate that multiplying a scalar by a vector is allowed in GLSL IR:<br><br>   case ir_binop_add:<br>
   case ir_binop_sub:<br>   case ir_binop_mul:<br>   case ir_binop_div:<br>   case ir_binop_mod:<br>   case ir_binop_min:<br>   case ir_binop_max:<br>   case ir_binop_pow:<br>      if (ir-&gt;operands[0]-&gt;type-&gt;is_scalar())<br>
     assert(ir-&gt;operands[1]-&gt;type == ir-&gt;type);<br>      else if (ir-&gt;operands[1]-&gt;type-&gt;is_scalar())<br>     assert(ir-&gt;operands[0]-&gt;type == ir-&gt;type);<br>      else if (ir-&gt;operands[0]-&gt;type-&gt;is_vector() &amp;&amp;<br>
           ir-&gt;operands[1]-&gt;type-&gt;is_vector()) {<br>     assert(ir-&gt;operands[0]-&gt;type == ir-&gt;operands[1]-&gt;type);<br>     assert(ir-&gt;operands[0]-&gt;type == ir-&gt;type);<br>      }<br>      break;<br>
<br>Also, as I noted in my previous email, this is what we do in several other built-in functions, such as asin:<br><br>   (signature vec2<br>     (parameters<br>       (declare (in) vec2 x))<br>     ((return (expression vec2 *<br>
           (expression vec2 sign (var_ref x))<br>           (expression vec2 -<br>        (constant float (1.5707964))<br>        (expression vec2 *<br>         (expression vec2 sqrt<br>          (expression vec2 -<br>           (constant float (1.0))<br>
           (expression vec2 abs (var_ref x))))<br>         (expression vec2 +<br>          (constant float (1.5707964))<br>          (expression vec2 *<br>           (expression vec2 abs (var_ref x))<br>           (expression vec2 +<br>
            (constant float (-0.21460183))<br>            (expression vec2 *<br>             (expression vec2 abs (var_ref x))<br>                     (expression vec2 +<br>                      (constant float (0.086566724))<br>
                      (expression vec2 *<br>                       (expression vec2 abs (var_ref x))<br>                       (constant float (-0.03102955))<br>             ))))))))))))<br><br></div></div>