[Mesa-dev] [PATCH] glsl: skip comparison opt when adding vars of different size

Ian Romanick idr at freedesktop.org
Thu Jun 28 00:38:42 UTC 2018


The funny thing is that I just encountered a somewhat similar bug in the
i965 vec4 backend. :)  The ability to mix sizes like that in the IR was
a mistake.  We should have added swizzles to code like this so that the
types would match.  Alas.

This patch is

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

On 06/27/2018 04:23 PM, Timothy Arceri wrote:
> The spec allows adding scalars a vector or matrix. In this case
> the opt was losing any swizzle or size information.
> 
> This fixes a bug with Doom (2016) shaders.
> ---
>  src/compiler/glsl/opt_algebraic.cpp | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/compiler/glsl/opt_algebraic.cpp b/src/compiler/glsl/opt_algebraic.cpp
> index 1a8ee361652..ff4be269578 100644
> --- a/src/compiler/glsl/opt_algebraic.cpp
> +++ b/src/compiler/glsl/opt_algebraic.cpp
> @@ -709,6 +709,12 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
>           if (!is_vec_zero(zero))
>              continue;
>  
> +         /* We are allowed to add scalars with a vector or matrix. In that
> +          * case lets just exit early.
> +          */
> +         if (add->operands[0]->type != add->operands[1]->type)
> +            continue;
> +
>           /* Depending of the zero position we want to optimize
>            * (0 cmp x+y) into (-x cmp y) or (x+y cmp 0) into (x cmp -y)
>            */
> 



More information about the mesa-dev mailing list