Skip to content

vrend/shader: Fix texture buffer swizzling and emulate more alpha textures

Gert Wollny requested to merge gerddie/virglrenderer:fix-alpha-textures into master

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.

Fixes: 29c6b9177541f189ebed5158a432b21d0d82211
    vrend: apply format swizzling during GLSL generation

In addition, emulate a few more alpha texture types up-front.

Merge request reports