diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-08-26 05:30:39 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-08-26 05:30:39 +0000 |
commit | 27c93456b58343162f7c4ad20ca6bea0c9a91646 (patch) | |
tree | 945c20b63e0b9975ee40f114c5312f8d8f1a2d0b /lib/mesa/src/gallium/drivers/iris/iris_fence.c | |
parent | 875b83a3ee95e248388fbf72271acc80f6f97987 (diff) |
Import Mesa 20.1.6
Diffstat (limited to 'lib/mesa/src/gallium/drivers/iris/iris_fence.c')
-rw-r--r-- | lib/mesa/src/gallium/drivers/iris/iris_fence.c | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/lib/mesa/src/gallium/drivers/iris/iris_fence.c b/lib/mesa/src/gallium/drivers/iris/iris_fence.c index 3aaa0af22..0d3144d61 100644 --- a/lib/mesa/src/gallium/drivers/iris/iris_fence.c +++ b/lib/mesa/src/gallium/drivers/iris/iris_fence.c @@ -133,7 +133,8 @@ iris_fence_reference(struct pipe_screen *p_screen, struct pipe_fence_handle **dst, struct pipe_fence_handle *src) { - if (pipe_reference(&(*dst)->ref, &src->ref)) + if (pipe_reference(*dst ? &(*dst)->ref : NULL, + src ? &src->ref : NULL)) iris_fence_destroy(p_screen, *dst); *dst = src; @@ -156,6 +157,10 @@ iris_wait_syncpt(struct pipe_screen *p_screen, return gen_ioctl(screen->fd, DRM_IOCTL_SYNCOBJ_WAIT, &args); } +#define CSI "\e[" +#define BLUE_HEADER CSI "0;97;44m" +#define NORMAL CSI "0m" + static void iris_fence_flush(struct pipe_context *ctx, struct pipe_fence_handle **out_fence, @@ -164,6 +169,17 @@ iris_fence_flush(struct pipe_context *ctx, struct iris_screen *screen = (void *) ctx->screen; struct iris_context *ice = (struct iris_context *)ctx; + if (flags & PIPE_FLUSH_END_OF_FRAME) { + ice->frame++; + + if (INTEL_DEBUG & DEBUG_SUBMIT) { + fprintf(stderr, "%s ::: FRAME %-10u (ctx %p)%-35c%s\n", + (INTEL_DEBUG & DEBUG_COLOR) ? BLUE_HEADER : "", + ice->frame, ctx, ' ', + (INTEL_DEBUG & DEBUG_COLOR) ? NORMAL : ""); + } + } + /* XXX PIPE_FLUSH_DEFERRED */ for (unsigned i = 0; i < IRIS_BATCH_COUNT; i++) iris_batch_flush(&ice->batches[i]); @@ -184,6 +200,8 @@ iris_fence_flush(struct pipe_context *ctx, iris_syncpt_reference(screen, &fence->syncpt[fence->count++], ice->batches[b].last_syncpt); } + + iris_fence_reference(ctx->screen, out_fence, NULL); *out_fence = fence; } @@ -298,6 +316,22 @@ iris_fence_get_fd(struct pipe_screen *p_screen, struct iris_screen *screen = (struct iris_screen *)p_screen; int fd = -1; + if (fence->count == 0) { + /* Our fence has no syncobj's recorded. This means that all of the + * batches had already completed, their syncobj's had been signalled, + * and so we didn't bother to record them. But we're being asked to + * export such a fence. So export a dummy already-signalled syncobj. + */ + struct drm_syncobj_handle args = { + .flags = DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE, .fd = -1, + }; + + args.handle = gem_syncobj_create(screen->fd, DRM_SYNCOBJ_CREATE_SIGNALED); + gen_ioctl(screen->fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args); + gem_syncobj_destroy(screen->fd, args.handle); + return args.fd; + } + for (unsigned i = 0; i < fence->count; i++) { struct drm_syncobj_handle args = { .handle = fence->syncpt[i]->handle, @@ -322,10 +356,17 @@ iris_fence_create_fd(struct pipe_context *ctx, struct iris_screen *screen = (struct iris_screen *)ctx->screen; struct drm_syncobj_handle args = { + .handle = gem_syncobj_create(screen->fd, DRM_SYNCOBJ_CREATE_SIGNALED), .flags = DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE, .fd = fd, }; - gen_ioctl(screen->fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args); + if (gen_ioctl(screen->fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args) == -1) { + fprintf(stderr, "DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE failed: %s\n", + strerror(errno)); + gem_syncobj_destroy(screen->fd, args.handle); + *out = NULL; + return; + } struct iris_syncpt *syncpt = malloc(sizeof(*syncpt)); syncpt->handle = args.handle; |