[Mesa-dev] [PATCH 25/25] st/vdpau: fix default swizzle for Output/Bitmap samplers

Christian König deathsimple at vodafone.de
Mon Feb 27 08:25:53 PST 2012


Signed-off-by: Christian König <deathsimple at vodafone.de>
---
 src/gallium/state_trackers/vdpau/bitmap.c        |    3 +--
 src/gallium/state_trackers/vdpau/device.c        |   22 ++++++++++++++++++++--
 src/gallium/state_trackers/vdpau/output.c        |    3 +--
 src/gallium/state_trackers/vdpau/vdpau_private.h |    2 ++
 4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/bitmap.c b/src/gallium/state_trackers/vdpau/bitmap.c
index bfabd05..a02bb94 100644
--- a/src/gallium/state_trackers/vdpau/bitmap.c
+++ b/src/gallium/state_trackers/vdpau/bitmap.c
@@ -84,8 +84,7 @@ vlVdpBitmapSurfaceCreate(VdpDevice device,
       return VDP_STATUS_RESOURCES;
    }
 
-   memset(&sv_templ, 0, sizeof(sv_templ));
-   u_sampler_view_default_template(&sv_templ, res, res->format);
+   vlVdpDefaultSamplerViewTemplate(&sv_templ, res);
    vlsurface->sampler_view = pipe->create_sampler_view(pipe, res, &sv_templ);
    if (!vlsurface->sampler_view) {
       pipe_resource_reference(&res, NULL);
diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c
index 482b71e..98106a1 100644
--- a/src/gallium/state_trackers/vdpau/device.c
+++ b/src/gallium/state_trackers/vdpau/device.c
@@ -240,6 +240,25 @@ vlVdpGetErrorString (VdpStatus status)
 }
 
 void
+vlVdpDefaultSamplerViewTemplate(struct pipe_sampler_view *templ, struct pipe_resource *res)
+{
+   const struct util_format_description *desc;
+
+   memset(templ, 0, sizeof(*templ));
+   u_sampler_view_default_template(templ, res, res->format);
+
+   desc = util_format_description(res->format);
+   if (desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_0)
+      templ->swizzle_r = PIPE_SWIZZLE_ONE;
+   if (desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_0)
+      templ->swizzle_g = PIPE_SWIZZLE_ONE;
+   if (desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_0)
+      templ->swizzle_b = PIPE_SWIZZLE_ONE;
+   if (desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_0)
+      templ->swizzle_a = PIPE_SWIZZLE_ONE;
+}
+
+void
 vlVdpResolveDelayedRendering(vlVdpDevice *dev, struct pipe_surface *surface, struct u_rect *dirty_area)
 {
    struct vl_compositor_state *cstate;
@@ -270,8 +289,7 @@ vlVdpResolveDelayedRendering(vlVdpDevice *dev, struct pipe_surface *surface, str
       struct pipe_resource *res = surface->texture;
       struct pipe_sampler_view sv_templ;
 
-      memset(&sv_templ, 0, sizeof(sv_templ));
-      u_sampler_view_default_template(&sv_templ, res, res->format);
+      vlVdpDefaultSamplerViewTemplate(&sv_templ, res);
       pipe_sampler_view_reference(&vlsurface->sampler_view,
          dev->context->create_sampler_view(dev->context, res, &sv_templ));
    }
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
index cf94fe7..924ec54 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -87,8 +87,7 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
       return VDP_STATUS_ERROR;
    }
 
-   memset(&sv_templ, 0, sizeof(sv_templ));
-   u_sampler_view_default_template(&sv_templ, res, res->format);
+   vlVdpDefaultSamplerViewTemplate(&sv_templ, res);
    vlsurface->sampler_view = pipe->create_sampler_view(pipe, res, &sv_templ);
    if (!vlsurface->sampler_view) {
       pipe_resource_reference(&res, NULL);
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
index 2f9f37b..9dcedbd 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -399,6 +399,8 @@ boolean vlGetFuncFTAB(VdpFuncId function_id, void **func);
 VdpDeviceCreateX11 vdp_imp_device_create_x11;
 VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11;
 
+void vlVdpDefaultSamplerViewTemplate(struct pipe_sampler_view *templ, struct pipe_resource *res);
+
 /* Delayed rendering funtionality */
 void vlVdpResolveDelayedRendering(vlVdpDevice *dev, struct pipe_surface *surface, struct u_rect *dirty_area);
 void vlVdpSave4DelayedRendering(vlVdpDevice *dev, VdpOutputSurface surface, struct vl_compositor_state *cstate);
-- 
1.7.5.4



More information about the mesa-dev mailing list