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 {