[Mesa-dev] [PATCH 11/18] mesa: Refactor set_ubo_binding()
Brian Paul
brianp at vmware.com
Wed Jan 22 09:00:57 PST 2014
On 01/21/2014 03:35 PM, Fredrik Höglund wrote:
> Make set_ubo_binding() just update the binding, and move the code
> that does validation, flushes the vertices etc. into a new
> bind_uniform_buffer() function.
> ---
> src/mesa/main/bufferobj.c | 50 ++++++++++++++++++++++++++++-----------------
> 1 file changed, 31 insertions(+), 19 deletions(-)
>
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index 81344ac..9ef9dd0 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -2456,15 +2456,30 @@ _mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name, GLenum pname,
>
> static void
> set_ubo_binding(struct gl_context *ctx,
> - int index,
> - struct gl_buffer_object *bufObj,
> - GLintptr offset,
> - GLsizeiptr size,
> - GLboolean autoSize)
> + struct gl_uniform_buffer_binding *binding,
> + struct gl_buffer_object *bufObj,
> + GLintptr offset,
> + GLsizeiptr size,
> + GLboolean autoSize)
> {
> - struct gl_uniform_buffer_binding *binding;
> + _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj);
> +
> + binding->Offset = offset;
> + binding->Size = size;
> + binding->AutomaticSize = autoSize;
> +}
> +
> +static void
> +bind_uniform_buffer(struct gl_context *ctx,
> + GLuint index,
> + struct gl_buffer_object *bufObj,
> + GLintptr offset,
> + GLsizeiptr size,
> + GLboolean autoSize)
I think we need comments on set_ubo_binding() and bind_uniform_buffer()
to explain how/why they're different.
> +{
> + struct gl_uniform_buffer_binding *binding =
> + &ctx->UniformBufferBindings[index];
>
> - binding = &ctx->UniformBufferBindings[index];
> if (binding->BufferObject == bufObj &&
> binding->Offset == offset &&
> binding->Size == size &&
> @@ -2475,10 +2490,7 @@ set_ubo_binding(struct gl_context *ctx,
> FLUSH_VERTICES(ctx, 0);
> ctx->NewDriverState |= ctx->DriverFlags.NewUniformBuffer;
>
> - _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj);
> - binding->Offset = offset;
> - binding->Size = size;
> - binding->AutomaticSize = autoSize;
> + set_ubo_binding(ctx, binding, bufObj, offset, size, autoSize);
> }
>
> /**
> @@ -2507,13 +2519,12 @@ bind_buffer_range_uniform_buffer(struct gl_context *ctx,
> return;
> }
>
> - if (bufObj == ctx->Shared->NullBufferObj) {
> - offset = -1;
> - size = -1;
> - }
> -
> _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, bufObj);
> - set_ubo_binding(ctx, index, bufObj, offset, size, GL_FALSE);
> +
> + if (bufObj == ctx->Shared->NullBufferObj)
> + bind_uniform_buffer(ctx, index, bufObj, -1, -1, GL_TRUE);
> + else
> + bind_uniform_buffer(ctx, index, bufObj, offset, size, GL_FALSE);
> }
>
>
> @@ -2532,10 +2543,11 @@ bind_buffer_base_uniform_buffer(struct gl_context *ctx,
> }
>
> _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, bufObj);
> +
> if (bufObj == ctx->Shared->NullBufferObj)
> - set_ubo_binding(ctx, index, bufObj, -1, -1, GL_TRUE);
> + bind_uniform_buffer(ctx, index, bufObj, -1, -1, GL_TRUE);
> else
> - set_ubo_binding(ctx, index, bufObj, 0, 0, GL_TRUE);
> + bind_uniform_buffer(ctx, index, bufObj, 0, 0, GL_TRUE);
> }
>
> static void
>
More information about the mesa-dev
mailing list