On 4 September 2011 14:49, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org">idr@freedesktop.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;">
-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA1<br>
<div class="im"><br>
On 09/04/2011 08:35 AM, Paul Berry wrote:<br>
> On 4 September 2011 06:20, Christoph Bumiller<br>
</div>> <<a href="mailto:e0425955@student.tuwien.ac.at">e0425955@student.tuwien.ac.at</a> <mailto:<a href="mailto:e0425955@student.tuwien.ac.at">e0425955@student.tuwien.ac.at</a>>><br>
<div><div></div><div class="h5">> wrote:<br>
><br>
> I encountered some failures in piglit's tests of builtins because a<br>
> vector constructor that is given only 1 single argument does not<br>
> replicate the argument into the yzw components, for example:<br>
><br>
> diff --git a/src/glsl/builtins/ir/cosh b/src/glsl/builtins/ir/cosh<br>
> index 45e0ae4..8bf3ad2 100644<br>
> --- a/src/glsl/builtins/ir/cosh<br>
> +++ b/src/glsl/builtins/ir/cosh<br>
> @@ -9,21 +9,21 @@<br>
> (signature vec2<br>
> (parameters<br>
> (declare (in) vec2 x))<br>
> - ((return (expression vec2 * (constant vec2 (0.5))<br>
> + ((return (expression vec2 * (constant vec2 (0.5, 0.5))<br>
> (expression vec2 +<br>
> (expression vec2 exp (var_ref x))<br>
> (expression vec2 exp (expression vec2 neg (var_ref<br>
> x))))))))<br>
> (signature vec3<br>
> (parameters<br>
> (declare (in) vec3 x))<br>
><br>
> Should the constructors or should all the builtin files be fixed ?<br>
><br>
><br>
> Thanks for noticing this, Christoph. I wrote the tests for hyperbolic<br>
> trig functions a few weeks ago, and I've been waiting for some i965<br>
> churn to settle down before looping back to fix the bugs.<br>
><br>
> Personally, I'd prefer to fix this bug by making the constant a scalar,<br>
> like this:<br>
<br>
</div></div>I don't recall for sure, but, while that is valid GLSL, I don't think<br>
that'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'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->operands[0]->type->is_scalar())<br>
assert(ir->operands[1]->type == ir->type);<br> else if (ir->operands[1]->type->is_scalar())<br> assert(ir->operands[0]->type == ir->type);<br> else if (ir->operands[0]->type->is_vector() &&<br>
ir->operands[1]->type->is_vector()) {<br> assert(ir->operands[0]->type == ir->operands[1]->type);<br> assert(ir->operands[0]->type == ir->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>