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>
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
assert(pos == batch->used);
- free(batch->buffer);
free(batch);
}
struct glthread_batch *next;
/**
- * Points to the first command in the batch.
+ * Amount of data used by batch commands, in bytes.
*/
- uint8_t *buffer;
+ size_t used;
/**
- * Amount of data used by batch commands, in bytes.
+ * Data contained in the command buffer.
*/
- size_t used;
+ uint8_t buffer[MARSHAL_MAX_CMD_SIZE];
};
void _mesa_glthread_init(struct gl_context *ctx);