fd_ringbuffer_set_parent(batch->draw, batch->gmem);
fd_ringbuffer_set_parent(batch->binning, batch->gmem);
+ batch->in_fence_fd = -1;
+
batch->cleared = batch->partial_cleared = 0;
batch->restore = batch->resolve = 0;
batch->needs_flush = false;
{
pipe_resource_reference(&batch->query_buf, NULL);
+ if (batch->in_fence_fd != -1)
+ close(batch->in_fence_fd);
+
fd_ringbuffer_del(batch->draw);
fd_ringbuffer_del(batch->binning);
fd_ringbuffer_del(batch->gmem);
unsigned seqno;
unsigned idx;
+ int in_fence_fd;
+ bool needs_out_fence_fd;
+
struct fd_context *ctx;
struct util_queue_fence flush_fence;
{
struct fd_context *ctx = fd_context(pctx);
+ if (flags & PIPE_FLUSH_FENCE_FD)
+ ctx->batch->needs_out_fence_fd = true;
+
if (!ctx->screen->reorder) {
fd_batch_flush(ctx->batch, true);
} else {
pctx->flush = fd_context_flush;
pctx->emit_string_marker = fd_emit_string_marker;
pctx->set_debug_callback = fd_set_debug_callback;
+ pctx->create_fence_fd = fd_create_fence_fd;
+ pctx->fence_server_sync = fd_fence_server_sync;
/* TODO what about compute? Ideally it creates it's own independent
* batches per compute job (since it isn't using tiling, so no point
* Rob Clark <robclark@freedesktop.org>
*/
+#include <libsync.h>
+
#include "util/u_inlines.h"
#include "freedreno_fence.h"
struct pipe_reference reference;
struct fd_context *ctx;
struct fd_screen *screen;
+ int fence_fd;
uint32_t timestamp;
};
-void
-fd_fence_ref(struct pipe_screen *pscreen,
+static void fd_fence_destroy(struct pipe_fence_handle *fence)
+{
+ if (fence->fence_fd != -1)
+ close(fence->fence_fd);
+ FREE(fence);
+}
+
+void fd_fence_ref(struct pipe_screen *pscreen,
struct pipe_fence_handle **ptr,
struct pipe_fence_handle *pfence)
{
if (pipe_reference(&(*ptr)->reference, &pfence->reference))
- FREE(*ptr);
+ fd_fence_destroy(*ptr);
*ptr = pfence;
}
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->screen->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));
+}
+
+void fd_fence_server_sync(struct pipe_context *pctx,
+ struct pipe_fence_handle *fence)
+{
+ struct fd_context *ctx = fd_context(pctx);
+ struct fd_batch *batch = ctx->batch;
+
+ if (sync_accumulate("freedreno", &batch->in_fence_fd, fence->fence_fd)) {
+ /* error */
+ }
+}
+
+int fd_fence_get_fd(struct pipe_screen *pscreen,
+ struct pipe_fence_handle *fence)
+{
+ return dup(fence->fence_fd);
+}
+
struct pipe_fence_handle * fd_fence_create(struct fd_context *ctx,
- uint32_t timestamp)
+ uint32_t timestamp, int fence_fd)
{
struct pipe_fence_handle *fence;
fence->ctx = ctx;
fence->screen = ctx->screen;
fence->timestamp = timestamp;
+ fence->fence_fd = fence_fd;
return fence;
}
struct pipe_context *ctx,
struct pipe_fence_handle *pfence,
uint64_t timeout);
+void fd_create_fence_fd(struct pipe_context *pctx,
+ struct pipe_fence_handle **pfence, int fd);
+void fd_fence_server_sync(struct pipe_context *pctx,
+ struct pipe_fence_handle *fence);
+int fd_fence_get_fd(struct pipe_screen *pscreen,
+ struct pipe_fence_handle *pfence);
struct fd_context;
struct pipe_fence_handle * fd_fence_create(struct fd_context *ctx,
- uint32_t timestamp);
+ uint32_t timestamp, int fence_fd);
#endif /* FREEDRENO_FENCE_H_ */
ctx->stats.batch_gmem++;
}
- fd_ringbuffer_flush(batch->gmem);
+ int out_fence_fd = -1;
+ fd_ringbuffer_flush2(batch->gmem, batch->in_fence_fd,
+ batch->needs_out_fence_fd ? &out_fence_fd : NULL);
fd_fence_ref(&ctx->screen->base, &ctx->last_fence, NULL);
- ctx->last_fence = fd_fence_create(ctx, fd_ringbuffer_timestamp(batch->gmem));
+ ctx->last_fence = fd_fence_create(ctx,
+ fd_ringbuffer_timestamp(batch->gmem), out_fence_fd);
}
/* tile needs restore if it isn't completely contained within the
case PIPE_CAP_UMA:
return 1;
case PIPE_CAP_NATIVE_FENCE_FD:
- return 0;
+ return fd_device_version(screen->dev) >= FD_VERSION_FENCE_FD;
}
debug_printf("unknown param %d\n", param);
return 0;
pscreen->fence_reference = fd_fence_ref;
pscreen->fence_finish = fd_fence_finish;
+ pscreen->fence_get_fd = fd_fence_get_fd;
slab_create_parent(&screen->transfer_pool, sizeof(struct fd_transfer), 16);