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 <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26548>
This commit is contained in:
Marek Olšák 2023-11-26 22:33:48 -05:00 committed by Marge Bot
parent 5af047d40a
commit c3b95d1507
2 changed files with 12 additions and 2 deletions

View file

@ -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;

View file

@ -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 {