* to SwrSync call.
*/
static void
-swr_sync_cb(uint64_t userData, uint64_t userData2, uint64_t userData3)
+swr_fence_cb(uint64_t userData, uint64_t userData2, uint64_t userData3)
{
struct swr_fence *fence = (struct swr_fence *)userData;
+ /* Complete all work attached to the fence */
+ swr_fence_do_work(fence);
+
/* Correct value is in SwrSync data, and not the fence write field. */
fence->read = userData2;
}
fence->write++;
fence->pending = TRUE;
- SwrSync(ctx->swrContext, swr_sync_cb, (uint64_t)fence, fence->write, 0);
+ SwrSync(ctx->swrContext, swr_fence_cb, (uint64_t)fence, fence->write, 0);
}
/*
pipe_reference_init(&fence->reference, 1);
fence->id = fence_id++;
+ fence->work.tail = &fence->work.head;
return (struct pipe_fence_handle *)fence;
}
static void
swr_fence_destroy(struct swr_fence *fence)
{
+ /* Complete any work left if fence was not submitted */
+ swr_fence_do_work(fence);
FREE(fence);
}
old = NULL;
}
- if (pipe_reference(&old->reference, &fence->reference))
+ if (pipe_reference(&old->reference, &fence->reference)) {
+ swr_fence_finish(screen, NULL, (struct pipe_fence_handle *) old, 0);
swr_fence_destroy(old);
+ }
}
-static INLINE boolean
-swr_is_fence_done(struct pipe_fence_handle *fence_handle)
-{
- struct swr_fence *fence = swr_fence(fence_handle);
- return (fence->read == fence->write);
-}
/*
* Wait for the fence to finish.
*/
boolean
swr_fence_finish(struct pipe_screen *screen,
+ struct pipe_context *ctx,
struct pipe_fence_handle *fence_handle,
uint64_t timeout)
{