[Mesa-dev] glsl: vectorize pass probably needs to change types of scalar constants as well?

Matt Turner mattst88 at gmail.com
Tue Jan 28 12:11:17 PST 2014


On Mon, Jan 27, 2014 at 10:28 PM, Aras Pranckevicius <aras at unity3d.com> wrote:
> The new vectorization pass (added in 4bd6e0d7c69) properly changes types of
> scalar dereferences. Doesn't it need to change types of scalar constants as
> well?
>
> Consider this shader:
>
> uniform sampler2D maintex;
> uniform float factor;
> varying vec2 uv;
> void main() {
>     vec4 c = texture2D(maintex, uv);
>     vec4 r;
>     r.x = max(0.123, c.x);
>     r.y = max(0.123, c.y);
>     r.z = min(c.z, factor);
>     r.w = min(c.w, factor);
>     gl_FragColor = r;
> }
>
> Scalar dereference gets properly vectorized into:
> r.zw = min (c.zw, vec2(factor));
> However scalar constant is vectorized into:
> r.xy = max (0.123, c.xy); // type mismatch
>
>
> It seems that handling ir_constant same way as ir_dereference inside
> opt_vectorize.cpp rewrite_swizzle() should fix the issue.
>
>
> --
> Aras Pranckevičius
> work: http://unity3d.com
> home: http://aras-p.info

Thanks Aras. I think you're right. I'll try to look into this today
unless you beat me to it.

Thanks,
Matt


More information about the mesa-dev mailing list