[Mesa-dev] [PATCH 17/17] mesa: Remove gl_context parameter from _mesa_initialize_buffer_object and dd:NewBufferObject
Ian Romanick
idr at freedesktop.org
Wed Sep 2 12:59:45 PDT 2015
On 08/26/2015 10:36 AM, Ilia Mirkin wrote:
> *every* other callback takes a ctx... this feels really asymmetric.
> I'd kinda rather just keep the ctx's in and add (void) uses on them.
> Don't feel too strongly about it though.
What if I told you that I have patches to remove unused ctx parameters
from other dd functions? :)
> On Wed, Aug 26, 2015 at 1:20 PM, Ian Romanick <idr at freedesktop.org> wrote:
>> From: Ian Romanick <ian.d.romanick at intel.com>
>>
>> _mesa_initialize_buffer_object did not use it. Once that parameter was
>> removed, none of the implementations of dd::NewBufferObject used it
>> either.
>>
>> Also silences a warning:
>>
>> main/bufferobj.c: In function '_mesa_initialize_buffer_object':
>> main/bufferobj.c:503:51: warning: unused parameter 'ctx' [-Wunused-parameter]
>> _mesa_initialize_buffer_object(struct gl_context *ctx,
>> ^
>>
>> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
>> ---
>> src/mesa/drivers/dri/i915/intel_buffer_objects.c | 4 ++--
>> src/mesa/drivers/dri/i965/intel_buffer_objects.c | 4 ++--
>> src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c | 4 ++--
>> src/mesa/drivers/dri/radeon/radeon_buffer_objects.c | 5 ++---
>> src/mesa/main/bufferobj.c | 13 +++++--------
>> src/mesa/main/bufferobj.h | 3 +--
>> src/mesa/main/dd.h | 3 +--
>> src/mesa/main/shared.c | 2 +-
>> src/mesa/state_tracker/st_cb_bufferobjects.c | 4 ++--
>> src/mesa/vbo/vbo_exec_api.c | 2 +-
>> src/mesa/vbo/vbo_save_api.c | 2 +-
>> 11 files changed, 20 insertions(+), 26 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i915/intel_buffer_objects.c b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
>> index ef06743..6db2a88 100644
>> --- a/src/mesa/drivers/dri/i915/intel_buffer_objects.c
>> +++ b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
>> @@ -68,11 +68,11 @@ release_buffer(struct intel_buffer_object *intel_obj)
>> * internal structure where somehow shared.
>> */
>> static struct gl_buffer_object *
>> -intel_bufferobj_alloc(struct gl_context * ctx, GLuint name)
>> +intel_bufferobj_alloc(GLuint name)
>> {
>> struct intel_buffer_object *obj = CALLOC_STRUCT(intel_buffer_object);
>>
>> - _mesa_initialize_buffer_object(ctx, &obj->Base, name);
>> + _mesa_initialize_buffer_object(&obj->Base, name);
>>
>> obj->buffer = NULL;
>>
>> diff --git a/src/mesa/drivers/dri/i965/intel_buffer_objects.c b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
>> index ff05b5c..3c34129 100644
>> --- a/src/mesa/drivers/dri/i965/intel_buffer_objects.c
>> +++ b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
>> @@ -134,14 +134,14 @@ release_buffer(struct intel_buffer_object *intel_obj)
>> * internal structure where somehow shared.
>> */
>> static struct gl_buffer_object *
>> -brw_new_buffer_object(struct gl_context * ctx, GLuint name)
>> +brw_new_buffer_object(GLuint name)
>> {
>> struct intel_buffer_object *obj = CALLOC_STRUCT(intel_buffer_object);
>> if (!obj) {
>> _mesa_error_no_memory(__func__);
>> }
>>
>> - _mesa_initialize_buffer_object(ctx, &obj->Base, name);
>> + _mesa_initialize_buffer_object(&obj->Base, name);
>>
>> obj->buffer = NULL;
>>
>> diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
>> index afccf35..aa0d6dd 100644
>> --- a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
>> +++ b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
>> @@ -48,7 +48,7 @@ get_bufferobj_map(struct gl_context *ctx, struct gl_buffer_object *obj,
>> }
>>
>> static struct gl_buffer_object *
>> -nouveau_bufferobj_new(struct gl_context *ctx, GLuint buffer)
>> +nouveau_bufferobj_new(GLuint buffer)
>> {
>> struct nouveau_bufferobj *nbo;
>>
>> @@ -56,7 +56,7 @@ nouveau_bufferobj_new(struct gl_context *ctx, GLuint buffer)
>> if (!nbo)
>> return NULL;
>>
>> - _mesa_initialize_buffer_object(ctx, &nbo->base, buffer);
>> + _mesa_initialize_buffer_object(&nbo->base, buffer);
>>
>> return &nbo->base;
>> }
>> diff --git a/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c b/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
>> index d9d4f5f..a40cf19 100644
>> --- a/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
>> +++ b/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
>> @@ -39,12 +39,11 @@ get_radeon_buffer_object(struct gl_buffer_object *obj)
>> }
>>
>> static struct gl_buffer_object *
>> -radeonNewBufferObject(struct gl_context * ctx,
>> - GLuint name)
>> +radeonNewBufferObject(GLuint name)
>> {
>> struct radeon_buffer_object *obj = CALLOC_STRUCT(radeon_buffer_object);
>>
>> - _mesa_initialize_buffer_object(ctx, &obj->Base, name);
>> + _mesa_initialize_buffer_object(&obj->Base, name);
>>
>> obj->bo = NULL;
>>
>> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
>> index 7c6c70a..c5823da 100644
>> --- a/src/mesa/main/bufferobj.c
>> +++ b/src/mesa/main/bufferobj.c
>> @@ -395,14 +395,12 @@ convert_clear_buffer_data(struct gl_context *ctx,
>> * Default callback for the \c dd_function_table::NewBufferObject() hook.
>> */
>> static struct gl_buffer_object *
>> -_mesa_new_buffer_object(struct gl_context *ctx, GLuint name)
>> +_mesa_new_buffer_object(GLuint name)
>> {
>> struct gl_buffer_object *obj;
>>
>> - (void) ctx;
>> -
>> obj = MALLOC_STRUCT(gl_buffer_object);
>> - _mesa_initialize_buffer_object(ctx, obj, name);
>> + _mesa_initialize_buffer_object(obj, name);
>> return obj;
>> }
>>
>> @@ -500,8 +498,7 @@ _mesa_reference_buffer_object_(struct gl_context *ctx,
>> * Initialize a buffer object to default values.
>> */
>> void
>> -_mesa_initialize_buffer_object(struct gl_context *ctx,
>> - struct gl_buffer_object *obj,
>> +_mesa_initialize_buffer_object(struct gl_buffer_object *obj,
>> GLuint name)
>> {
>> memset(obj, 0, sizeof(struct gl_buffer_object));
>> @@ -930,7 +927,7 @@ _mesa_handle_bind_buffer_gen(struct gl_context *ctx,
>> * never used before, allocate a buffer object now.
>> */
>> assert(ctx->Driver.NewBufferObject);
>> - buf = ctx->Driver.NewBufferObject(ctx, buffer);
>> + buf = ctx->Driver.NewBufferObject(buffer);
>> if (!buf) {
>> _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller);
>> return false;
>> @@ -1367,7 +1364,7 @@ create_buffers(GLsizei n, GLuint *buffers, bool dsa)
>> buffers[i] = first + i;
>> if (dsa) {
>> assert(ctx->Driver.NewBufferObject);
>> - buf = ctx->Driver.NewBufferObject(ctx, buffers[i]);
>> + buf = ctx->Driver.NewBufferObject(buffers[i]);
>> if (!buf) {
>> _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
>> mtx_unlock(&ctx->Shared->Mutex);
>> diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
>> index b7154c5..ae754be 100644
>> --- a/src/mesa/main/bufferobj.h
>> +++ b/src/mesa/main/bufferobj.h
>> @@ -104,8 +104,7 @@ _mesa_multi_bind_lookup_bufferobj(struct gl_context *ctx,
>> GLuint index, const char *caller);
>>
>> extern void
>> -_mesa_initialize_buffer_object(struct gl_context *ctx,
>> - struct gl_buffer_object *obj,
>> +_mesa_initialize_buffer_object(struct gl_buffer_object *obj,
>> GLuint name);
>>
>> extern void
>> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
>> index 87eb63e..2a9b531 100644
>> --- a/src/mesa/main/dd.h
>> +++ b/src/mesa/main/dd.h
>> @@ -622,8 +622,7 @@ struct dd_function_table {
>> * \name Vertex/pixel buffer object functions
>> */
>> /*@{*/
>> - struct gl_buffer_object * (*NewBufferObject)(struct gl_context *ctx,
>> - GLuint buffer);
>> + struct gl_buffer_object * (*NewBufferObject)(GLuint buffer);
>>
>> void (*DeleteBuffer)( struct gl_context *ctx, struct gl_buffer_object *obj );
>>
>> diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
>> index d5ac9f1..ff9ea7e 100644
>> --- a/src/mesa/main/shared.c
>> +++ b/src/mesa/main/shared.c
>> @@ -86,7 +86,7 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
>> shared->SamplerObjects = _mesa_NewHashTable();
>>
>> /* Allocate the default buffer object */
>> - shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0);
>> + shared->NullBufferObj = ctx->Driver.NewBufferObject(0);
>>
>> /* Create default texture objects */
>> for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
>> diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
>> index db254c2..df102d4 100644
>> --- a/src/mesa/state_tracker/st_cb_bufferobjects.c
>> +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
>> @@ -54,14 +54,14 @@
>> * internal structure where somehow shared.
>> */
>> static struct gl_buffer_object *
>> -st_bufferobj_alloc(struct gl_context *ctx, GLuint name)
>> +st_bufferobj_alloc(GLuint name)
>> {
>> struct st_buffer_object *st_obj = ST_CALLOC_STRUCT(st_buffer_object);
>>
>> if (!st_obj)
>> return NULL;
>>
>> - _mesa_initialize_buffer_object(ctx, &st_obj->Base, name);
>> + _mesa_initialize_buffer_object(&st_obj->Base, name);
>>
>> return &st_obj->Base;
>> }
>> diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
>> index 138cd60..3749e1f 100644
>> --- a/src/mesa/vbo/vbo_exec_api.c
>> +++ b/src/mesa/vbo/vbo_exec_api.c
>> @@ -1020,7 +1020,7 @@ void vbo_use_buffer_objects(struct gl_context *ctx)
>>
>> /* Allocate a real buffer object now */
>> _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL);
>> - exec->vtx.bufferobj = ctx->Driver.NewBufferObject(ctx, bufName);
>> + exec->vtx.bufferobj = ctx->Driver.NewBufferObject(bufName);
>> if (!ctx->Driver.BufferData(ctx, target, size, NULL, usage,
>> GL_MAP_WRITE_BIT |
>> GL_DYNAMIC_STORAGE_BIT |
>> diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
>> index 29de3d3..0da5ef6 100644
>> --- a/src/mesa/vbo/vbo_save_api.c
>> +++ b/src/mesa/vbo/vbo_save_api.c
>> @@ -191,7 +191,7 @@ alloc_vertex_store(struct gl_context *ctx)
>> * user. Perhaps there could be a special number for internal
>> * buffers:
>> */
>> - vertex_store->bufferobj = ctx->Driver.NewBufferObject(ctx, VBO_BUF_ID);
>> + vertex_store->bufferobj = ctx->Driver.NewBufferObject(VBO_BUF_ID);
>> if (vertex_store->bufferobj) {
>> save->out_of_memory =
>> !ctx->Driver.BufferData(ctx,
>> --
>> 2.1.0
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
More information about the mesa-dev
mailing list