Lines Matching refs:fence
38 fence_flush(struct pipe_context *pctx, struct pipe_fence_handle *fence,
45 if (!util_queue_fence_is_signalled(&fence->ready)) {
46 if (fence->tc_token) {
47 threaded_context_flush(pctx, fence->tc_token, timeout == 0);
54 util_queue_fence_wait(&fence->ready);
57 if (!util_queue_fence_wait_timeout(&fence->ready, abs_timeout)) {
62 util_queue_fence_wait(&fence->submit_fence.ready);
64 /* We've already waited for batch to be flushed and fence->batch
67 assert(!fence->batch);
71 if (fence->batch)
72 fd_batch_flush(fence->batch);
74 util_queue_fence_wait(&fence->submit_fence.ready);
76 assert(!fence->batch);
82 fd_fence_repopulate(struct pipe_fence_handle *fence, struct pipe_fence_handle *last_fence)
85 fd_fence_repopulate(fence, last_fence->last_fence);
87 /* The fence we are re-populating must not be an fd-fence (but last_fince
90 assert(!fence->submit_fence.use_fence_fd);
93 fd_fence_ref(&fence->last_fence, last_fence);
98 fd_fence_set_batch(fence, NULL);
102 fd_fence_destroy(struct pipe_fence_handle *fence)
104 fd_fence_ref(&fence->last_fence, NULL);
106 tc_unflushed_batch_token_reference(&fence->tc_token, NULL);
107 if (fence->submit_fence.use_fence_fd)
108 close(fence->submit_fence.fence_fd);
109 if (fence->syncobj)
110 drmSyncobjDestroy(fd_device_fd(fence->screen->dev), fence->syncobj);
111 fd_pipe_del(fence->pipe);
118 util_queue_fence_wait(&fence->submit_fence.ready);
120 FREE(fence);
134 struct pipe_fence_handle *fence, uint64_t timeout)
136 /* Note: for TC deferred fence, pctx->flush() may not have been called
138 * fence->last_fence
140 if (!fence_flush(pctx, fence, timeout))
143 if (fence->last_fence)
144 return fd_fence_finish(pscreen, pctx, fence->last_fence, timeout);
146 if (fence->last_fence)
147 fence = fence->last_fence;
149 if (fence->submit_fence.use_fence_fd) {
150 int ret = sync_wait(fence->submit_fence.fence_fd, timeout / 1000000);
154 if (fd_pipe_wait_timeout(fence->pipe, &fence->submit_fence.fence, timeout))
164 struct pipe_fence_handle *fence;
166 fence = CALLOC_STRUCT(pipe_fence_handle);
167 if (!fence)
170 pipe_reference_init(&fence->reference, 1);
171 util_queue_fence_init(&fence->ready);
172 util_queue_fence_init(&fence->submit_fence.ready);
174 fence->ctx = ctx;
175 fd_fence_set_batch(fence, batch);
176 fence->pipe = fd_pipe_ref(ctx->pipe);
177 fence->screen = ctx->screen;
178 fence->submit_fence.fence_fd = fence_fd;
179 fence->submit_fence.use_fence_fd = (fence_fd != -1);
180 fence->syncobj = syncobj;
182 return fence;
209 unreachable("Unhandled fence type");
214 fd_fence_server_sync(struct pipe_context *pctx, struct pipe_fence_handle *fence)
218 /* NOTE: we don't expect the combination of fence-fd + async-flush-fence,
221 fence_flush(pctx, fence, 0);
223 if (fence->last_fence) {
224 fd_fence_server_sync(pctx, fence->last_fence);
228 /* if not an external fence, then nothing more to do without preemption: */
229 if (!fence->submit_fence.use_fence_fd)
232 if (sync_accumulate("freedreno", &ctx->in_fence_fd, fence->submit_fence.fence_fd)) {
239 struct pipe_fence_handle *fence)
243 if (fence->syncobj) {
244 drmSyncobjSignal(fd_device_fd(ctx->screen->dev), &fence->syncobj, 1);
249 fd_fence_get_fd(struct pipe_screen *pscreen, struct pipe_fence_handle *fence)
251 /* We don't expect deferred flush to be combined with fence-fd: */
252 assert(!fence->last_fence);
254 assert(fence->submit_fence.use_fence_fd);
256 /* NOTE: in the deferred fence case, the pctx we want is the threaded-ctx
260 fence_flush(&fence->ctx->tc->base, fence, PIPE_TIMEOUT_INFINITE);
261 return os_dupfd_cloexec(fence->submit_fence.fence_fd);
265 fd_fence_is_fd(struct pipe_fence_handle *fence)
267 return fence->submit_fence.use_fence_fd;
277 fd_fence_set_batch(struct pipe_fence_handle *fence, struct fd_batch *batch)
280 assert(!fence->batch);
281 fence->batch = batch;
284 fence->batch = NULL;
286 /* When the batch is dis-associated with the fence, we can signal TC
287 * that the fence is flushed
289 if (fence->needs_signal) {
290 util_queue_fence_signal(&fence->ready);
291 fence->needs_signal = false;
300 struct pipe_fence_handle *fence =
302 fence->needs_signal = true;
303 util_queue_fence_reset(&fence->ready);
304 tc_unflushed_batch_token_reference(&fence->tc_token, tc_token);
305 return fence;