st/xa: Fix format conversion copy alpha channel
authorThomas Hellstrom <thellstrom@vmware.com>
Wed, 14 Dec 2011 15:02:54 +0000 (16:02 +0100)
committerThomas Hellstrom <thellstrom@vmware.com>
Thu, 15 Dec 2011 07:28:09 +0000 (08:28 +0100)
When doing format conversion copies between a format without an
alpha channel and a format with an alpha channel, make sure the
destination alpha is set to 1.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
src/gallium/state_trackers/xa/xa_context.c
src/gallium/state_trackers/xa/xa_priv.h
src/gallium/state_trackers/xa/xa_renderer.c

index 8290e0fa8b32c0111389cf8d1d90edbe063955c8..8da7c31cf483d65d2f1dd41eb63314fe55786382 100644 (file)
@@ -220,7 +220,9 @@ xa_copy_prepare(struct xa_context *ctx,
        int ret = xa_ctx_srf_create(ctx, dst);
        if (ret != XA_ERR_NONE)
            return ret;
-       renderer_copy_prepare(ctx, ctx->srf, src->tex);
+       renderer_copy_prepare(ctx, ctx->srf, src->tex,
+                             src->fdesc.xa_format,
+                             dst->fdesc.xa_format);
        ctx->simple_copy = 0;
     } else
        ctx->simple_copy = 1;
index d00114f99b5341aa62f248518188c10dd868df1e..de4639a41a88e227a986b76ff3a96e2c2de8a40b 100644 (file)
@@ -237,7 +237,10 @@ void renderer_bind_destination(struct xa_context *r,
 void renderer_init_state(struct xa_context *r);
 void renderer_copy_prepare(struct xa_context *r,
                           struct pipe_surface *dst_surface,
-                          struct pipe_resource *src_texture);
+                          struct pipe_resource *src_texture,
+                          const enum xa_formats src_xa_format,
+                          const enum xa_formats dst_xa_format);
+
 void renderer_copy(struct xa_context *r, int dx,
                   int dy,
                   int sx,
index ef762f0ab49c00b2f13393f3400047b6dd9c5ddd..5496fc04bfedb3605b2c47333a1284f6b0f60038 100644 (file)
@@ -413,7 +413,9 @@ renderer_set_constants(struct xa_context *r,
 void
 renderer_copy_prepare(struct xa_context *r,
                      struct pipe_surface *dst_surface,
-                     struct pipe_resource *src_texture)
+                     struct pipe_resource *src_texture,
+                     const enum xa_formats src_xa_format,
+                     const enum xa_formats dst_xa_format)
 {
     struct pipe_context *pipe = r->pipe;
     struct pipe_screen *screen = pipe->screen;
@@ -474,6 +476,9 @@ renderer_copy_prepare(struct xa_context *r,
        fs_traits |= FS_SRC_LUMINANCE;
     if (dst_surface->format == PIPE_FORMAT_L8_UNORM)
        fs_traits |= FS_DST_LUMINANCE;
+    if (xa_format_a(dst_xa_format) != 0 &&
+       xa_format_a(src_xa_format) == 0)
+       fs_traits |= FS_SRC_SET_ALPHA;
 
     shader = xa_shaders_get(r->shaders, VS_COMPOSITE, fs_traits);
     cso_set_vertex_shader_handle(r->cso, shader.vs);