--- st_cb_syncobj.c.orig 2016-01-18 16:39:26.000000000 +0900 +++ st_cb_syncobj.c 2016-10-12 20:09:44.497104896 +0900 @@ -80,17 +80,21 @@ { struct pipe_screen *screen = st_context(ctx)->pipe->screen; struct st_sync_object *so = (struct st_sync_object*)obj; + struct pipe_fence_handle * fence = NULL; + screen->fence_reference(screen, &fence, so->fence); /* If the fence doesn't exist, assume it's signalled. */ - if (!so->fence) { + if (!fence) { so->b.StatusFlag = GL_TRUE; return; } - if (screen->fence_finish(screen, so->fence, 0)) { + if (screen->fence_finish(screen, fence, 0)) { + assert(0); screen->fence_reference(screen, &so->fence, NULL); so->b.StatusFlag = GL_TRUE; } + screen->fence_reference(screen, &fence, NULL); } static void st_client_wait_sync(struct gl_context *ctx, @@ -99,9 +103,11 @@ { struct pipe_screen *screen = st_context(ctx)->pipe->screen; struct st_sync_object *so = (struct st_sync_object*)obj; + struct pipe_fence_handle * fence = NULL; + screen->fence_reference(screen, &fence, so->fence); /* If the fence doesn't exist, assume it's signalled. */ - if (!so->fence) { + if (!fence) { so->b.StatusFlag = GL_TRUE; return; } @@ -109,11 +115,12 @@ /* We don't care about GL_SYNC_FLUSH_COMMANDS_BIT, because flush is * already called when creating a fence. */ - if (so->fence && - screen->fence_finish(screen, so->fence, timeout)) { + if (screen->fence_finish(screen, fence, timeout)) { + assert(0); screen->fence_reference(screen, &so->fence, NULL); so->b.StatusFlag = GL_TRUE; } + screen->fence_reference(screen, &fence, NULL); } static void st_server_wait_sync(struct gl_context *ctx,