diff options
author | Marek Olšák <[email protected]> | 2020-03-27 06:06:31 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-04-27 11:56:06 +0000 |
commit | b6b1ab8d548252f99df6c86cb124faa95abda26f (patch) | |
tree | 19f6ea28707606ab1e1d69a11cf13a6f46d31400 /src/mesa | |
parent | fc4b78f4cc31aa74054933ed65aae5712109bc4e (diff) |
glthread: reduce dereferences of the next batch
Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4758>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/glthread.c | 6 | ||||
-rw-r--r-- | src/mesa/main/glthread.h | 3 | ||||
-rw-r--r-- | src/mesa/main/glthread_marshal.h | 4 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c index 5d50e138150..b8e04c9f771 100644 --- a/src/mesa/main/glthread.c +++ b/src/mesa/main/glthread.c @@ -102,6 +102,7 @@ _mesa_glthread_init(struct gl_context *ctx) glthread->batches[i].ctx = ctx; util_queue_fence_init(&glthread->batches[i].fence); } + glthread->next_batch = &glthread->batches[glthread->next]; glthread->enabled = true; glthread->stats.queue = &glthread->queue; @@ -176,7 +177,7 @@ _mesa_glthread_flush_batch(struct gl_context *ctx) if (!glthread->enabled) return; - struct glthread_batch *next = &glthread->batches[glthread->next]; + struct glthread_batch *next = glthread->next_batch; if (!next->used) return; @@ -197,6 +198,7 @@ _mesa_glthread_flush_batch(struct gl_context *ctx) glthread_unmarshal_batch, NULL, 0); glthread->last = glthread->next; glthread->next = (glthread->next + 1) % MARSHAL_MAX_BATCHES; + glthread->next_batch = &glthread->batches[glthread->next]; } /** @@ -221,7 +223,7 @@ _mesa_glthread_finish(struct gl_context *ctx) return; struct glthread_batch *last = &glthread->batches[glthread->last]; - struct glthread_batch *next = &glthread->batches[glthread->next]; + struct glthread_batch *next = glthread->next_batch; bool synced = false; if (!util_queue_fence_is_signalled(&last->fence)) { diff --git a/src/mesa/main/glthread.h b/src/mesa/main/glthread.h index 9c1742eb2b4..a50b2f87ceb 100644 --- a/src/mesa/main/glthread.h +++ b/src/mesa/main/glthread.h @@ -94,6 +94,9 @@ struct glthread_state /** The ring of batches in memory. */ struct glthread_batch batches[MARSHAL_MAX_BATCHES]; + /** Pointer to the batch currently being filled. */ + struct glthread_batch *next_batch; + /** Index of the last submitted batch. */ unsigned last; diff --git a/src/mesa/main/glthread_marshal.h b/src/mesa/main/glthread_marshal.h index f464f2bd565..a519ff0c5cf 100644 --- a/src/mesa/main/glthread_marshal.h +++ b/src/mesa/main/glthread_marshal.h @@ -57,12 +57,12 @@ _mesa_glthread_allocate_command(struct gl_context *ctx, int size) { struct glthread_state *glthread = &ctx->GLThread; - struct glthread_batch *next = &glthread->batches[glthread->next]; + struct glthread_batch *next = glthread->next_batch; struct marshal_cmd_base *cmd_base; if (unlikely(next->used + size > MARSHAL_MAX_CMD_SIZE)) { _mesa_glthread_flush_batch(ctx); - next = &glthread->batches[glthread->next]; + next = glthread->next_batch; } const int aligned_size = align(size, 8); |