The swizzling didn't take into account that the destination might
actually only read a few components or just one, so that the
applied swizzling could even become invalid because code like
dest.z = vec4(dest.z.x, dest.z.y.dest.z.z. dest.z.w)
could be created. The check for when to apply the swizzling was also
not correct because the two values compared came from different
name-spaces.
To fix this, just check whether the TEXTURE_NEEDS_SWIZZLE is set,
and when loweing in the shader, take only the components into account
that are actually written.
This also needs a fix for the alpha-format override to add the
TEXTURE_NEEDS_SWIZZLE flag.
Finally take the shader type into account when checking the number
of sampler views.
v2: Correct the shader code to apply the swizzling (Maksym)
v3: Fix formatting (Maksym)
Fixes: 29c6b9177541f189ebed5158a432b21d0d82211
vrend: apply format swizzling during GLSL generation
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: maksym.wezdecki@collabora.com