st/vega: Fix image sampler views for alpha-only formats.
authorChia-I Wu <olv@lunarg.com>
Tue, 23 Nov 2010 14:39:31 +0000 (22:39 +0800)
committerChia-I Wu <olv@lunarg.com>
Wed, 1 Dec 2010 03:23:51 +0000 (11:23 +0800)
For alpha-only VG formats, R = G = B = 1.0.

src/gallium/state_trackers/vega/image.c

index 303e979012a8957236fd3af0b108855134a573ba..c5421f84cc60f47e0329a7d8086f09cb7af47935 100644 (file)
@@ -272,6 +272,13 @@ struct vg_image * image_create(VGImageFormat format,
    debug_assert(newtex);
 
    u_sampler_view_default_template(&view_templ, newtex, newtex->format);
+   /* R, G, and B are treated as 1.0 for alpha-only formats in OpenVG */
+   if (newtex->format == PIPE_FORMAT_A8_UNORM) {
+      view_templ.swizzle_r = PIPE_SWIZZLE_ONE;
+      view_templ.swizzle_g = PIPE_SWIZZLE_ONE;
+      view_templ.swizzle_b = PIPE_SWIZZLE_ONE;
+   }
+
    view = pipe->create_sampler_view(pipe, newtex, &view_templ);
    /* want the texture to go away if the view is freed */
    pipe_resource_reference(&newtex, NULL);