[g3dvl] rework fence handling and add r600g workaround
authorChristian König <deathsimple@vodafone.de>
Sun, 24 Apr 2011 18:08:11 +0000 (20:08 +0200)
committerChristian König <deathsimple@vodafone.de>
Sun, 24 Apr 2011 18:08:11 +0000 (20:08 +0200)
src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
src/gallium/include/pipe/p_video_context.h
src/gallium/state_trackers/xorg/xvmc/surface.c
src/gallium/state_trackers/xorg/xvmc/xvmc_private.h

index 296f46aba52ebb823aa8d57c551ed99b76aea2fd..37789707a6b04ca872035c749f1659b3d797fa40 100644 (file)
@@ -498,8 +498,7 @@ static void
 vl_mpeg12_decoder_flush_buffer(struct pipe_video_decode_buffer *buffer,
                                unsigned num_ycbcr_blocks[3],
                                struct pipe_video_buffer *refs[2],
-                               struct pipe_video_buffer *dst,
-                               struct pipe_fence_handle **fence)
+                               struct pipe_video_buffer *dst)
 {
    struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer *)buffer;
    struct vl_mpeg12_decoder *dec;
@@ -567,8 +566,6 @@ vl_mpeg12_decoder_flush_buffer(struct pipe_video_decode_buffer *buffer,
          vl_mc_render_ycbcr(&buf->mc[i], mc_source_sv[component], j, num_ycbcr_blocks[component]);
       }
    }
-
-   dec->pipe->flush(dec->pipe, fence);
 }
 
 static bool
index 88d3ca1f4e49e99bb308afc67e86bc0acb1e36fb..41f2e320580ae37b37e31377cf4043fe0687e6d5 100644 (file)
@@ -159,8 +159,7 @@ struct pipe_video_decoder
    void (*flush_buffer)(struct pipe_video_decode_buffer *decbuf,
                         unsigned num_ycbcr_blocks[3],
                         struct pipe_video_buffer *ref_frames[2],
-                        struct pipe_video_buffer *dst,
-                        struct pipe_fence_handle **fence);
+                        struct pipe_video_buffer *dst);
 };
 
 /**
index cfa15e120d9a1ea79aca4ece353e792f1d93e1b4..fc4593dbc5f2a8a838b66998c271c7cc4144c433 100644 (file)
@@ -275,8 +275,7 @@ unmap_and_flush_surface(XvMCSurfacePrivate *surface)
       context_priv->decoder->flush_buffer(surface->decode_buffer,
                                           num_ycbcr_blocks,
                                           ref_frames,
-                                          surface->video_buffer,
-                                          &surface->flush_fence);
+                                          surface->video_buffer);
       surface->mapped = 0;
    }
 }
@@ -537,7 +536,10 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
       subpicture_priv->surface = NULL;
    }
 
-   compositor->render_picture(compositor, PictureToPipe(flags), drawable_surface, &dst_rect, &surface_priv->disp_fence);
+   // Workaround for r600g, there seems to be a bug in the fence refcounting code
+   vpipe->screen->fence_reference(vpipe->screen, &surface_priv->fence, NULL);
+
+   compositor->render_picture(compositor, PictureToPipe(flags), drawable_surface, &dst_rect, &surface_priv->fence);
 
    XVMC_MSG(XVMC_TRACE, "[XvMC] Submitted surface %p for display. Pushing to front buffer.\n", surface);
 
@@ -572,6 +574,10 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
 PUBLIC
 Status XvMCGetSurfaceStatus(Display *dpy, XvMCSurface *surface, int *status)
 {
+   struct pipe_video_context *vpipe;
+   XvMCSurfacePrivate *surface_priv;
+   XvMCContextPrivate *context_priv;
+
    assert(dpy);
 
    if (!surface)
@@ -579,8 +585,16 @@ Status XvMCGetSurfaceStatus(Display *dpy, XvMCSurface *surface, int *status)
 
    assert(status);
 
+   surface_priv = surface->privData;
+   context_priv = surface_priv->context->privData;
+   vpipe = context_priv->vctx->vpipe;
+
    *status = 0;
 
+   if (surface_priv->fence)
+      if (!vpipe->screen->fence_signalled(vpipe->screen, surface_priv->fence))
+         *status |= XVMC_RENDERING;
+
    return Success;
 }
 
index bdcda3bb56fe3a14eccbec469fbfab03753f4475..262adac7ab6431b53408386107828d3bde988fb0 100644 (file)
@@ -83,9 +83,7 @@ typedef struct
       struct pipe_motionvector *mv;
    } ref[2];
 
-   struct pipe_fence_handle *flush_fence;
-   struct pipe_fence_handle *render_fence;
-   struct pipe_fence_handle *disp_fence;
+   struct pipe_fence_handle *fence;
 
    /* The subpicture associated with this surface, if any. */
    XvMCSubpicture *subpicture;