-/* TODO we need to spiff out libdrm_freedreno a bit to allow passing
- * the timeout.. and maybe a better way to check if fence has been
- * signaled. The current implementation is a bit lame for now to
- * avoid bumping libdrm version requirement.
- */
+boolean fd_fence_finish(struct pipe_screen *pscreen,
+ struct pipe_context *ctx,
+ struct pipe_fence_handle *fence,
+ uint64_t timeout)
+{
+ if (fence->fence_fd != -1) {
+ int ret = sync_wait(fence->fence_fd, timeout / 1000000);
+ return ret == 0;
+ }
+
+ if (fd_pipe_wait_timeout(fence->ctx->pipe, fence->timestamp, timeout))
+ return false;
+
+ return true;
+}
+
+void fd_create_fence_fd(struct pipe_context *pctx,
+ struct pipe_fence_handle **pfence, int fd)
+{
+ *pfence = fd_fence_create(fd_context(pctx), 0, dup(fd));
+}