[Mesa-dev] GLSL builtins constant constructor

Paul Berry stereotype441 at gmail.com
Sun Sep 4 08:35:49 PDT 2011


On 4 September 2011 06:20, Christoph Bumiller <e0425955 at 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:

diff --git a/src/glsl/builtins/ir/cosh b/src/glsl/builtins/ir/cosh
index 45e0ae4..9457431 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 float (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))

That would be consistent with what we do in other builtin functions that
require constants (e.g. see "asin").
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110904/f4f4883c/attachment.htm>


More information about the mesa-dev mailing list