diff options
author | Chris Wilson <[email protected]> | 2020-02-19 23:45:59 +0000 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-05-01 19:00:02 +0000 |
commit | 3dbde891118af0c64a16c729be5b551447aaae18 (patch) | |
tree | 7e89c7fa59f5046347021e346dcc148c1d734384 | |
parent | fd1907efb385a6f668971e9bb93af2f64d7b8cda (diff) |
iris: Store a seqno for each batch in the fence
In the next patch, we will introduce deferred fences where we will need
to flush a fence later. To do this, we need to know which batch requires
flushing, so keep a 1:1 mapping between seqno[] and the associated
batch.
It's also substantially less confusing to have a 1:1 mapping.
Reviewed-by: Kenneth Graunke <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3802>
-rw-r--r-- | src/gallium/drivers/iris/iris_fence.c | 51 |
1 files changed, 22 insertions, 29 deletions
diff --git a/src/gallium/drivers/iris/iris_fence.c b/src/gallium/drivers/iris/iris_fence.c index ea61d769372..c43c892bb87 100644 --- a/src/gallium/drivers/iris/iris_fence.c +++ b/src/gallium/drivers/iris/iris_fence.c @@ -115,7 +115,6 @@ iris_batch_add_syncobj(struct iris_batch *batch, struct pipe_fence_handle { struct pipe_reference ref; struct iris_seqno *seqno[IRIS_BATCH_COUNT]; - unsigned count; }; static void @@ -124,7 +123,7 @@ iris_fence_destroy(struct pipe_screen *p_screen, { struct iris_screen *screen = (struct iris_screen *)p_screen; - for (unsigned i = 0; i < fence->count; i++) + for (unsigned i = 0; i < ARRAY_SIZE(fence->seqno); i++) iris_seqno_reference(screen, &fence->seqno[i], NULL); free(fence); @@ -201,9 +200,7 @@ iris_fence_flush(struct pipe_context *ctx, if (iris_seqno_signaled(batch->last_seqno)) continue; - iris_seqno_reference(screen, - &fence->seqno[fence->count++], - batch->last_seqno); + iris_seqno_reference(screen, &fence->seqno[b], batch->last_seqno); } iris_fence_reference(ctx->screen, out_fence, NULL); @@ -219,7 +216,7 @@ iris_fence_await(struct pipe_context *ctx, for (unsigned b = 0; b < IRIS_BATCH_COUNT; b++) { struct iris_batch *batch = &ice->batches[b]; - for (unsigned i = 0; i < fence->count; i++) { + for (unsigned i = 0; i < ARRAY_SIZE(fence->seqno); i++) { struct iris_seqno *seqno = fence->seqno[i]; if (iris_seqno_signaled(seqno)) @@ -264,12 +261,9 @@ iris_fence_finish(struct pipe_screen *p_screen, { struct iris_screen *screen = (struct iris_screen *)p_screen; - if (!fence->count) - return true; - unsigned int handle_count = 0; uint32_t handles[ARRAY_SIZE(fence->seqno)]; - for (unsigned i = 0; i < fence->count; i++) { + for (unsigned i = 0; i < ARRAY_SIZE(fence->seqno); i++) { struct iris_seqno *seqno = fence->seqno[i]; if (iris_seqno_signaled(seqno)) @@ -319,23 +313,7 @@ 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++) { + for (unsigned i = 0; i < ARRAY_SIZE(fence->seqno); i++) { struct iris_seqno *seqno = fence->seqno[i]; if (iris_seqno_signaled(seqno)) @@ -351,6 +329,22 @@ iris_fence_get_fd(struct pipe_screen *p_screen, fd = sync_merge_fd(fd, args.fd); } + if (fd == -1) { + /* 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; + } + return fd; } @@ -403,7 +397,7 @@ iris_fence_create_fd(struct pipe_context *ctx, seqno->flags = IRIS_SEQNO_END; pipe_reference_init(&seqno->reference, 1); - struct pipe_fence_handle *fence = malloc(sizeof(*fence)); + struct pipe_fence_handle *fence = calloc(1, sizeof(*fence)); if (!fence) { free(seqno); free(syncobj); @@ -412,7 +406,6 @@ iris_fence_create_fd(struct pipe_context *ctx, } pipe_reference_init(&fence->ref, 1); fence->seqno[0] = seqno; - fence->count = 1; *out = fence; } |