Module: Mesa Branch: main Commit: c3b95d1507d809ff9c812c64021148a1681e47ce URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3b95d1507d809ff9c812c64021148a1681e47ce
Author: Marek Olšák <[email protected]> Date: Sun Nov 26 22:33:48 2023 -0500 glthread: add a marker at the end of batches indicating the end Unmarshal calls that "look ahead" in the batch will use it. Reviewed-by: Timothy Arceri <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26548> --- src/mesa/main/glthread.c | 5 +++++ src/mesa/main/glthread.h | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c index fb153af5ee9..a6e62516d02 100644 --- a/src/mesa/main/glthread.c +++ b/src/mesa/main/glthread.c @@ -340,6 +340,11 @@ _mesa_glthread_flush_batch(struct gl_context *ctx) struct glthread_batch *next = glthread->next_batch; + /* Mark the end of the batch, but don't increment "used". */ + struct marshal_cmd_base *last = + (struct marshal_cmd_base *)&next->buffer[glthread->used]; + last->cmd_id = NUM_DISPATCH_CMD; + p_atomic_add(&glthread->stats.num_offloaded_items, glthread->used); next->used = glthread->used; diff --git a/src/mesa/main/glthread.h b/src/mesa/main/glthread.h index 773c2f6e7c0..1a5399e33df 100644 --- a/src/mesa/main/glthread.h +++ b/src/mesa/main/glthread.h @@ -33,7 +33,12 @@ * chance of experiencing CPU cache thrashing * but it should be high enough so that u_queue overhead remains negligible. */ -#define MARSHAL_MAX_CMD_SIZE (8 * 1024) +#define MARSHAL_MAX_CMD_BUFFER_SIZE (8 * 1024) + +/* We need to leave 1 slot at the end to insert the END marker for unmarshal + * calls that look ahead to know where the batch ends. + */ +#define MARSHAL_MAX_CMD_SIZE (MARSHAL_MAX_CMD_BUFFER_SIZE - 8) /* The number of batch slots in memory. * @@ -136,7 +141,7 @@ struct glthread_batch unsigned used; /** Data contained in the command buffer. */ - uint64_t buffer[MARSHAL_MAX_CMD_SIZE / 8]; + uint64_t buffer[MARSHAL_MAX_CMD_BUFFER_SIZE / 8]; }; struct glthread_client_attrib {
