mesa: Statically allocate glthread command buffer in the batch struct.

This avoids an extra pointer dereference in the marshalling functions,
which, with the instruction count doing in the low 30s, could actually
matter for main-thread performance.

Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Acked-by: Marek Olšák <maraeo@gmail.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Tested-by: Mike Lothian <mike@fireburn.co.uk>
This commit is contained in:
Eric Anholt 2013-02-15 16:33:33 -08:00 committed by Timothy Arceri
parent 1d6b71c5c6
commit 47f819d3cb
2 changed files with 7 additions and 8 deletions

View File

@ -45,10 +45,10 @@ glthread_allocate_batch(struct gl_context *ctx)
struct glthread_state *glthread = ctx->GLThread;
/* TODO: handle memory allocation failure. */
glthread->batch = calloc(1, sizeof(*glthread->batch));
glthread->batch = malloc(sizeof(*glthread->batch));
if (!glthread->batch)
return;
glthread->batch->buffer = malloc(MARSHAL_MAX_CMD_SIZE);
memset(glthread->batch, 0, offsetof(struct glthread_batch, buffer));
}
static void
@ -63,7 +63,6 @@ glthread_unmarshal_batch(struct gl_context *ctx, struct glthread_batch *batch)
assert(pos == batch->used);
free(batch->buffer);
free(batch);
}

View File

@ -93,15 +93,15 @@ struct glthread_batch
*/
struct glthread_batch *next;
/**
* Points to the first command in the batch.
*/
uint8_t *buffer;
/**
* Amount of data used by batch commands, in bytes.
*/
size_t used;
/**
* Data contained in the command buffer.
*/
uint8_t buffer[MARSHAL_MAX_CMD_SIZE];
};
void _mesa_glthread_init(struct gl_context *ctx);