From f8ac7e034803a1c873bf156c012fede6d2640097 Mon Sep 17 00:00:00 2001 From: Christian König Date: Sat, 25 Feb 2012 23:34:31 +0100 Subject: st/vdpau: avoid an unnessasary copy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Delay the actual mixer rendering until we really know which surface is the real destination. Signed-off-by: Christian König --- src/gallium/state_trackers/vdpau/device.c | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/gallium/state_trackers/vdpau/device.c') diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c index f4a3dc04bfb..482b71e9a0d 100644 --- a/src/gallium/state_trackers/vdpau/device.c +++ b/src/gallium/state_trackers/vdpau/device.c @@ -29,6 +29,7 @@ #include "util/u_memory.h" #include "util/u_debug.h" +#include "util/u_sampler.h" #include "vl_winsys.h" @@ -237,3 +238,54 @@ vlVdpGetErrorString (VdpStatus status) default: return "Unknown Error"; } } + +void +vlVdpResolveDelayedRendering(vlVdpDevice *dev, struct pipe_surface *surface, struct u_rect *dirty_area) +{ + struct vl_compositor_state *cstate; + vlVdpOutputSurface *vlsurface; + + assert(dev); + + cstate = dev->delayed_rendering.cstate; + if (!cstate) + return; + + vlsurface = vlGetDataHTAB(dev->delayed_rendering.surface); + if (!vlsurface) + return; + + if (!surface) { + surface = vlsurface->surface; + dirty_area = &vlsurface->dirty_area; + } + + vl_compositor_render(cstate, &dev->compositor, surface, dirty_area); + + dev->delayed_rendering.surface = VDP_INVALID_HANDLE; + dev->delayed_rendering.cstate = NULL; + + /* test if we need to create a new sampler for the just filled texture */ + if (surface->texture != vlsurface->sampler_view->texture) { + 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); + pipe_sampler_view_reference(&vlsurface->sampler_view, + dev->context->create_sampler_view(dev->context, res, &sv_templ)); + } + + return; +} + +void +vlVdpSave4DelayedRendering(vlVdpDevice *dev, VdpOutputSurface surface, struct vl_compositor_state *cstate) +{ + assert(dev); + + vlVdpResolveDelayedRendering(dev, NULL, NULL); + + dev->delayed_rendering.surface = surface; + dev->delayed_rendering.cstate = cstate; +} -- cgit v1.2.3