freedreno: fence fix
authorRob Clark <robclark@freedesktop.org>
Fri, 8 May 2015 19:56:23 +0000 (15:56 -0400)
committerRob Clark <robclark@freedesktop.org>
Mon, 18 May 2015 21:47:54 +0000 (17:47 -0400)
A fence can outlive the ctx, so we shouldn't deref the ctx to get at the
screen.  We need some updates in libdrm_freedreno API to completely
handle fences properly, but this is at least an improvement.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/freedreno_fence.c

index 46b057d90622b47932a8385bed8823127646d794..375e58f702278e421ea10e00a34fbc05850076d1 100644 (file)
@@ -35,6 +35,7 @@
 struct pipe_fence_handle {
        struct pipe_reference reference;
        struct fd_context *ctx;
+       struct fd_screen *screen;
        uint32_t timestamp;
 };
 
@@ -68,7 +69,7 @@ boolean fd_screen_fence_finish(struct pipe_screen *screen,
                struct pipe_fence_handle *fence,
                uint64_t timeout)
 {
-       if (fd_pipe_wait(fence->ctx->screen->pipe, fence->timestamp))
+       if (fd_pipe_wait(fence->screen->pipe, fence->timestamp))
                return false;
 
        return true;
@@ -86,6 +87,7 @@ struct pipe_fence_handle * fd_fence_create(struct pipe_context *pctx)
        pipe_reference_init(&fence->reference, 1);
 
        fence->ctx = ctx;
+       fence->screen = ctx->screen;
        fence->timestamp = fd_ringbuffer_timestamp(ctx->ring);
 
        return fence;