[Mesa-dev] [PATCH 3/3] st/vdpau: remove the delayed rendering hack

Nayan Deshmukh nayan26deshmukh at gmail.com
Mon Oct 24 13:55:17 UTC 2016


the hack was introduced to avoid an extra copying
but now with dri3 we don't need it anymore

Signed-off-by: Nayan Deshmukh <nayan26deshmukh at gmail.com>
---
 src/gallium/state_trackers/vdpau/bitmap.c        |  2 -
 src/gallium/state_trackers/vdpau/device.c        | 50 -------------
 src/gallium/state_trackers/vdpau/mixer.c         | 89 +++++++++++-------------
 src/gallium/state_trackers/vdpau/output.c        |  9 ---
 src/gallium/state_trackers/vdpau/presentation.c  | 30 +++-----
 src/gallium/state_trackers/vdpau/vdpau_private.h |  9 ---
 6 files changed, 50 insertions(+), 139 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/bitmap.c b/src/gallium/state_trackers/vdpau/bitmap.c
index fd67a98..d9ec60d 100644
--- a/src/gallium/state_trackers/vdpau/bitmap.c
+++ b/src/gallium/state_trackers/vdpau/bitmap.c
@@ -198,8 +198,6 @@ vlVdpBitmapSurfacePutBitsNative(VdpBitmapSurface surface,
 
    pipe_mutex_lock(vlsurface->device->mutex);
 
-   vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
-
    dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture);
    pipe->texture_subdata(pipe, vlsurface->sampler_view->texture, 0,
                          PIPE_TRANSFER_WRITE, &dst_box, *source_data,
diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c
index 81b7582..79e99ba 100644
--- a/src/gallium/state_trackers/vdpau/device.c
+++ b/src/gallium/state_trackers/vdpau/device.c
@@ -321,53 +321,3 @@ vlVdpDefaultSamplerViewTemplate(struct pipe_sampler_view *templ, struct pipe_res
    if (desc->swizzle[3] == PIPE_SWIZZLE_0)
       templ->swizzle_a = PIPE_SWIZZLE_1;
 }
-
-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, true);
-
-   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;
-
-      vlVdpDefaultSamplerViewTemplate(&sv_templ, res);
-      pipe_sampler_view_reference(&vlsurface->sampler_view, NULL);
-      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;
-}
diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c
index c205427..1206292 100644
--- a/src/gallium/state_trackers/vdpau/mixer.c
+++ b/src/gallium/state_trackers/vdpau/mixer.c
@@ -184,8 +184,6 @@ vlVdpVideoMixerDestroy(VdpVideoMixer mixer)
 
    pipe_mutex_lock(vmixer->device->mutex);
 
-   vlVdpResolveDelayedRendering(vmixer->device, NULL, NULL);
-
    vlRemoveDataHTAB(mixer);
 
    vl_compositor_cleanup_state(&vmixer->cstate);
@@ -284,7 +282,6 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
    }
 
    pipe_mutex_lock(vmixer->device->mutex);
-   vlVdpResolveDelayedRendering(vmixer->device, NULL, NULL);
 
    vl_compositor_clear_layers(&vmixer->cstate);
 
@@ -394,63 +391,59 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
       ++layers;
    }
 
-   if (!vmixer->noise_reduction.filter && !vmixer->sharpness.filter && !vmixer->bicubic.filter)
-      vlVdpSave4DelayedRendering(vmixer->device, destination_surface, &vmixer->cstate);
-   else {
-      vl_compositor_render(&vmixer->cstate, compositor, surface, &dirty_area, true);
+   vl_compositor_render(&vmixer->cstate, compositor, surface, &dirty_area, true);
 
-      if (vmixer->noise_reduction.filter) {
-         if (!vmixer->sharpness.filter && !vmixer->bicubic.filter) {
-            vl_median_filter_render(vmixer->noise_reduction.filter,
-                                    sampler_view, dst->surface);
-         } else {
-            res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
-            struct pipe_sampler_view *sampler_view_temp = pipe->create_sampler_view(pipe, res, &sv_templ);
-            struct pipe_surface *surface_temp = pipe->create_surface(pipe, res, &surf_templ);
-            pipe_resource_reference(&res, NULL);
+   if (vmixer->noise_reduction.filter) {
+      if (!vmixer->sharpness.filter && !vmixer->bicubic.filter) {
+         vl_median_filter_render(vmixer->noise_reduction.filter,
+                                 sampler_view, dst->surface);
+      } else {
+         res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
+         struct pipe_sampler_view *sampler_view_temp = pipe->create_sampler_view(pipe, res, &sv_templ);
+         struct pipe_surface *surface_temp = pipe->create_surface(pipe, res, &surf_templ);
+         pipe_resource_reference(&res, NULL);
 
-            vl_median_filter_render(vmixer->noise_reduction.filter,
-                                    sampler_view, surface_temp);
+         vl_median_filter_render(vmixer->noise_reduction.filter,
+                                 sampler_view, surface_temp);
 
-            pipe_sampler_view_reference(&sampler_view, NULL);
-            pipe_surface_reference(&surface, NULL);
+         pipe_sampler_view_reference(&sampler_view, NULL);
+         pipe_surface_reference(&surface, NULL);
 
-            sampler_view = sampler_view_temp;
-            surface = surface_temp;
-         }
+         sampler_view = sampler_view_temp;
+         surface = surface_temp;
       }
+   }
 
-      if (vmixer->sharpness.filter) {
-         if (!vmixer->bicubic.filter) {
-            vl_matrix_filter_render(vmixer->sharpness.filter,
-                                    sampler_view, dst->surface);
-         } else {
-            res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
-            struct pipe_sampler_view *sampler_view_temp = pipe->create_sampler_view(pipe, res, &sv_templ);
-            struct pipe_surface *surface_temp = pipe->create_surface(pipe, res, &surf_templ);
-            pipe_resource_reference(&res, NULL);
+   if (vmixer->sharpness.filter) {
+      if (!vmixer->bicubic.filter) {
+         vl_matrix_filter_render(vmixer->sharpness.filter,
+                                 sampler_view, dst->surface);
+      } else {
+         res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
+         struct pipe_sampler_view *sampler_view_temp = pipe->create_sampler_view(pipe, res, &sv_templ);
+         struct pipe_surface *surface_temp = pipe->create_surface(pipe, res, &surf_templ);
+         pipe_resource_reference(&res, NULL);
 
-            vl_matrix_filter_render(vmixer->sharpness.filter,
-                                    sampler_view, surface_temp);
+         vl_matrix_filter_render(vmixer->sharpness.filter,
+                                 sampler_view, surface_temp);
 
-            pipe_sampler_view_reference(&sampler_view, NULL);
-            pipe_surface_reference(&surface, NULL);
+         pipe_sampler_view_reference(&sampler_view, NULL);
+         pipe_surface_reference(&surface, NULL);
 
-            sampler_view = sampler_view_temp;
-            surface = surface_temp;
-         }
+         sampler_view = sampler_view_temp;
+         surface = surface_temp;
       }
+   }
 
-      if (vmixer->bicubic.filter)
-         vl_bicubic_filter_render(vmixer->bicubic.filter,
-                                 sampler_view, dst->surface,
-                                 RectToPipe(destination_video_rect, &rect),
-                                 RectToPipe(destination_rect, &clip));
+   if (vmixer->bicubic.filter)
+      vl_bicubic_filter_render(vmixer->bicubic.filter,
+                               sampler_view, dst->surface,
+                               RectToPipe(destination_video_rect, &rect),
+                               RectToPipe(destination_rect, &clip));
 
-      if(surface != dst->surface) {
-         pipe_sampler_view_reference(&sampler_view, NULL);
-         pipe_surface_reference(&surface, NULL);
-      }
+   if(surface != dst->surface) {
+      pipe_sampler_view_reference(&sampler_view, NULL);
+      pipe_surface_reference(&surface, NULL);
    }
    pipe_mutex_unlock(vmixer->device->mutex);
 
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
index f4d62a3..93b4d74 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -144,7 +144,6 @@ vlVdpOutputSurfaceDestroy(VdpOutputSurface surface)
    pipe = vlsurface->device->context;
 
    pipe_mutex_lock(vlsurface->device->mutex);
-   vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
 
    pipe_surface_reference(&vlsurface->surface, NULL);
    pipe_sampler_view_reference(&vlsurface->sampler_view, NULL);
@@ -209,7 +208,6 @@ vlVdpOutputSurfaceGetBitsNative(VdpOutputSurface surface,
        return VDP_STATUS_INVALID_POINTER;
 
    pipe_mutex_lock(vlsurface->device->mutex);
-   vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
 
    res = vlsurface->sampler_view->texture;
    box = RectToPipeBox(source_rect, res);
@@ -254,7 +252,6 @@ vlVdpOutputSurfacePutBitsNative(VdpOutputSurface surface,
        return VDP_STATUS_INVALID_POINTER;
 
    pipe_mutex_lock(vlsurface->device->mutex);
-   vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
 
    dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture);
    pipe->texture_subdata(pipe, vlsurface->sampler_view->texture, 0,
@@ -332,7 +329,6 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
    res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW;
 
    pipe_mutex_lock(vlsurface->device->mutex);
-   vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
 
    if (!CheckSurfaceParams(context->screen, &res_tmpl))
       goto error_resource;
@@ -450,7 +446,6 @@ vlVdpOutputSurfacePutBitsYCbCr(VdpOutputSurface surface,
        return VDP_STATUS_INVALID_POINTER;
 
    pipe_mutex_lock(vlsurface->device->mutex);
-   vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
    memset(&vtmpl, 0, sizeof(vtmpl));
    vtmpl.buffer_format = format;
    vtmpl.chroma_format = FormatYCBCRToPipeChroma(source_ycbcr_format);
@@ -663,7 +658,6 @@ vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface,
    }
 
    pipe_mutex_lock(dst_vlsurface->device->mutex);
-   vlVdpResolveDelayedRendering(dst_vlsurface->device, NULL, NULL);
 
    context = dst_vlsurface->device->context;
    compositor = &dst_vlsurface->device->compositor;
@@ -738,7 +732,6 @@ vlVdpOutputSurfaceRenderBitmapSurface(VdpOutputSurface destination_surface,
    cstate = &dst_vlsurface->cstate;
 
    pipe_mutex_lock(dst_vlsurface->device->mutex);
-   vlVdpResolveDelayedRendering(dst_vlsurface->device, NULL, NULL);
 
    blend = BlenderToPipe(context, blend_state);
 
@@ -766,7 +759,6 @@ struct pipe_resource *vlVdpOutputSurfaceGallium(VdpOutputSurface surface)
       return NULL;
 
    pipe_mutex_lock(vlsurface->device->mutex);
-   vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
    vlsurface->device->context->flush(vlsurface->device->context, NULL, 0);
    pipe_mutex_unlock(vlsurface->device->mutex);
 
@@ -788,7 +780,6 @@ VdpStatus vlVdpOutputSurfaceDMABuf(VdpOutputSurface surface,
       return VDP_STATUS_INVALID_HANDLE;
 
    pipe_mutex_lock(vlsurface->device->mutex);
-   vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
    vlsurface->device->context->flush(vlsurface->device->context, NULL, 0);
    pipe_mutex_unlock(vlsurface->device->mutex);
 
diff --git a/src/gallium/state_trackers/vdpau/presentation.c b/src/gallium/state_trackers/vdpau/presentation.c
index 9051b49..793d75e 100644
--- a/src/gallium/state_trackers/vdpau/presentation.c
+++ b/src/gallium/state_trackers/vdpau/presentation.c
@@ -252,27 +252,15 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue,
    dst_clip.x1 = clip_width ? clip_width : surf_draw->width;
    dst_clip.y1 = clip_height ? clip_height : surf_draw->height;
 
-   if (pq->device->delayed_rendering.surface == surface &&
-       dst_clip.x1 == surf_draw->width && dst_clip.y1 == surf_draw->height) {
-
-      // TODO: we correctly support the clipping here, but not the pq background color in the clipped area....
-      cstate = pq->device->delayed_rendering.cstate;
-      vl_compositor_set_dst_clip(cstate, &dst_clip);
-      vlVdpResolveDelayedRendering(pq->device, surf_draw, dirty_area);
-
-   } else {
-      vlVdpResolveDelayedRendering(pq->device, NULL, NULL);
-
-      src_rect.x0 = 0;
-      src_rect.y0 = 0;
-      src_rect.x1 = surf_draw->width;
-      src_rect.y1 = surf_draw->height;
-
-      vl_compositor_clear_layers(cstate);
-      vl_compositor_set_rgba_layer(cstate, compositor, 0, surf->sampler_view, &src_rect, NULL, NULL);
-      vl_compositor_set_dst_clip(cstate, &dst_clip);
-      vl_compositor_render(cstate, compositor, surf_draw, dirty_area, true);
-   }
+   src_rect.x0 = 0;
+   src_rect.y0 = 0;
+   src_rect.x1 = surf_draw->width;
+   src_rect.y1 = surf_draw->height;
+
+   vl_compositor_clear_layers(cstate);
+   vl_compositor_set_rgba_layer(cstate, compositor, 0, surf->sampler_view, &src_rect, NULL, NULL);
+   vl_compositor_set_dst_clip(cstate, &dst_clip);
+   vl_compositor_render(cstate, compositor, surf_draw, dirty_area, true);
 #endif
 
    vscreen->set_next_timestamp(vscreen, earliest_presentation_time);
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
index bcd4bb1..490a0bd 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -351,11 +351,6 @@ typedef struct
    struct vl_compositor compositor;
    struct pipe_sampler_view *dummy_sv;
    pipe_mutex mutex;
-
-   struct {
-      struct vl_compositor_state *cstate;
-      VdpOutputSurface surface;
-   } delayed_rendering;
 } vlVdpDevice;
 
 typedef struct
@@ -458,10 +453,6 @@ VdpDeviceCreateX11 vdp_imp_device_create_x11;
 
 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);
-
 /* Internal function pointers */
 VdpGetErrorString vlVdpGetErrorString;
 VdpDeviceDestroy vlVdpDeviceDestroy;
-- 
2.7.4



More information about the mesa-dev mailing list