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

2014-01-28 Thread Matt Turner
On Mon, Jan 27, 2014 at 10:28 PM, Aras Pranckevicius  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
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


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

2014-01-27 Thread Aras Pranckevicius
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
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev