gallium/vl: Fix mirror with rotation for compute shaders

The mirror needs to be reversed because the rotation is applied
before the mirroring.

VAAPI docs:
  Mirroring of an image can be performed either along the
  horizontal or vertical axis. It is assumed that the rotation
  operation is always performed before the mirroring operation.

Cc: mesa-stable
Acked-by: Ruijing Dong <ruijing.dong@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34140>
This commit is contained in:
David Rosca 2025-03-18 12:23:27 +01:00 committed by Marge Bot
parent c8a2f0b248
commit 962c33cbca

View file

@ -669,7 +669,7 @@ calc_proj(struct vl_compositor_layer *layer,
struct pipe_resource *texture,
float m[2][4])
{
enum vl_compositor_mirror mirror = layer->mirror;
unsigned mirror = layer->mirror;
float ratio_x = (float)texture->width0 / layer->sampler_views[0]->texture->width0;
float ratio_y = (float)texture->height0 / layer->sampler_views[0]->texture->height0;
float width = layer->sampler_views[0]->texture->width0;
@ -689,14 +689,16 @@ calc_proj(struct vl_compositor_layer *layer,
m[1][2] = texture->height0;
width = layer->sampler_views[0]->texture->height0;
height = layer->sampler_views[0]->texture->width0;
if (mirror != VL_COMPOSITOR_MIRROR_NONE)
mirror = ~mirror;
break;
case VL_COMPOSITOR_ROTATE_180:
m[0][0] = 1.0;
m[1][1] = 1.0;
if (mirror != VL_COMPOSITOR_MIRROR_VERTICAL)
mirror = VL_COMPOSITOR_MIRROR_VERTICAL;
if (mirror == VL_COMPOSITOR_MIRROR_NONE)
mirror = VL_COMPOSITOR_MIRROR_HORIZONTAL | VL_COMPOSITOR_MIRROR_VERTICAL;
else
mirror = VL_COMPOSITOR_MIRROR_HORIZONTAL;
mirror = ~mirror;
break;
case VL_COMPOSITOR_ROTATE_270:
m[0][1] = -1.0;
@ -704,23 +706,21 @@ calc_proj(struct vl_compositor_layer *layer,
m[0][2] = texture->width0;
width = layer->sampler_views[0]->texture->height0;
height = layer->sampler_views[0]->texture->width0;
if (mirror != VL_COMPOSITOR_MIRROR_NONE)
mirror = ~mirror;
break;
}
switch (mirror) {
default:
case VL_COMPOSITOR_MIRROR_NONE:
break;
case VL_COMPOSITOR_MIRROR_HORIZONTAL:
if (mirror & VL_COMPOSITOR_MIRROR_HORIZONTAL) {
m[0][0] *= -1;
m[0][1] *= -1;
m[0][2] = texture->width0 - m[0][2];
break;
case VL_COMPOSITOR_MIRROR_VERTICAL:
}
if (mirror & VL_COMPOSITOR_MIRROR_VERTICAL) {
m[1][0] *= -1;
m[1][1] *= -1;
m[1][2] = texture->height0 - m[1][2];
break;
}
float scale_x = (width * (layer->src.br.x - layer->src.tl.x)) / layer->viewport.scale[0];