-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 09/04/2011 03:03 PM, Paul Berry wrote: > On 4 September 2011 14:49, Ian Romanick <i...@freedesktop.org > <mailto:i...@freedesktop.org>> wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On 09/04/2011 08:35 AM, Paul Berry wrote: > > On 4 September 2011 06:20, Christoph Bumiller > > <e0425...@student.tuwien.ac.at > <mailto:e0425...@student.tuwien.ac.at> > <mailto:e0425...@student.tuwien.ac.at > <mailto:e0425...@student.tuwien.ac.at>>> > > wrote: > > > > I encountered some failures in piglit's tests of builtins > because a > > vector constructor that is given only 1 single argument does not > > replicate the argument into the yzw components, for example: > > > > diff --git a/src/glsl/builtins/ir/cosh b/src/glsl/builtins/ir/cosh > > index 45e0ae4..8bf3ad2 100644 > > --- a/src/glsl/builtins/ir/cosh > > +++ b/src/glsl/builtins/ir/cosh > > @@ -9,21 +9,21 @@ > > (signature vec2 > > (parameters > > (declare (in) vec2 x)) > > - ((return (expression vec2 * (constant vec2 (0.5)) > > + ((return (expression vec2 * (constant vec2 (0.5, 0.5)) > > (expression vec2 + > > (expression vec2 exp (var_ref x)) > > (expression vec2 exp (expression vec2 neg > (var_ref > > x)))))))) > > (signature vec3 > > (parameters > > (declare (in) vec3 x)) > > > > Should the constructors or should all the builtin files be fixed ? > > > > > > Thanks for noticing this, Christoph. I wrote the tests for hyperbolic > > trig functions a few weeks ago, and I've been waiting for some i965 > > churn to settle down before looping back to fix the bugs. > > > > Personally, I'd prefer to fix this bug by making the constant a > scalar, > > like this: > > I don't recall for sure, but, while that is valid GLSL, I don't think > that's valid in the IR. Did you try it? I think you may have to wrap > it in a swizzle, at which point it's probably better to use the correct > vec# constructor. > > > 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:
Call me convinced. Using float constants is preferable to vector constants with replicated components. > case ir_binop_add: > case ir_binop_sub: > case ir_binop_mul: > case ir_binop_div: > case ir_binop_mod: > case ir_binop_min: > case ir_binop_max: > case ir_binop_pow: > if (ir->operands[0]->type->is_scalar()) > assert(ir->operands[1]->type == ir->type); > else if (ir->operands[1]->type->is_scalar()) > assert(ir->operands[0]->type == ir->type); > else if (ir->operands[0]->type->is_vector() && > ir->operands[1]->type->is_vector()) { > assert(ir->operands[0]->type == ir->operands[1]->type); > assert(ir->operands[0]->type == ir->type); > } > break; > > Also, as I noted in my previous email, this is what we do in several > other built-in functions, such as asin: > > (signature vec2 > (parameters > (declare (in) vec2 x)) > ((return (expression vec2 * > (expression vec2 sign (var_ref x)) > (expression vec2 - > (constant float (1.5707964)) > (expression vec2 * > (expression vec2 sqrt > (expression vec2 - > (constant float (1.0)) > (expression vec2 abs (var_ref x)))) > (expression vec2 + > (constant float (1.5707964)) > (expression vec2 * > (expression vec2 abs (var_ref x)) > (expression vec2 + > (constant float (-0.21460183)) > (expression vec2 * > (expression vec2 abs (var_ref x)) > (expression vec2 + > (constant float (0.086566724)) > (expression vec2 * > (expression vec2 abs (var_ref x)) > (constant float (-0.03102955)) > )))))))))))) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAk5lQpMACgkQX1gOwKyEAw+aTwCfcYdLH6ASpmq2raZcZe+ysBZr 1dAAniYEsG+CSKK89cQdq5o0z9PZw2Lt =L6gM -----END PGP SIGNATURE----- _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev