[Mesa-dev] [PATCH 09/18] mesa: Refactor set_atomic_buffer_binding()

Francisco Jerez currojerez at riseup.net
Thu Feb 13 07:01:56 PST 2014


Fredrik Höglund <fredrik at kde.org> writes:

> Make set_atomic_buffer_binding() just update the binding, and move
> the code that does validation, flushes the vertices etc. into a new
> bind_atomic_buffer() function.

If you add two short comments on the difference between
set_atomic_buffer_binding() and bind_atomic_buffer(), as Brian
suggested, this patch is:

Reviewed-by: Francisco Jerez <currojerez at riseup.net>

> ---
>  src/mesa/main/bufferobj.c |   42 ++++++++++++++++++++++++++----------------
>  1 file changed, 26 insertions(+), 16 deletions(-)
>
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index e46516d..4094e31 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -2474,11 +2474,29 @@ bind_buffer_base_uniform_buffer(struct gl_context *ctx,
>  
>  static void
>  set_atomic_buffer_binding(struct gl_context *ctx,
> -                          unsigned index,
> +                          struct gl_atomic_buffer_binding *binding,
>                            struct gl_buffer_object *bufObj,
>                            GLintptr offset,
> -                          GLsizeiptr size,
> -                          const char *name)
> +                          GLsizeiptr size)
> +{
> +   _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj);
> +
> +   if (bufObj == ctx->Shared->NullBufferObj) {
> +      binding->Offset = -1;
> +      binding->Size = -1;
> +   } else {
> +      binding->Offset = offset;
> +      binding->Size = size;
> +   }
> +}
> +
> +static void
> +bind_atomic_buffer(struct gl_context *ctx,
> +                   unsigned index,
> +                   struct gl_buffer_object *bufObj,
> +                   GLintptr offset,
> +                   GLsizeiptr size,
> +                   const char *name)
>  {
>     struct gl_atomic_buffer_binding *binding;
>  
> @@ -2506,15 +2524,7 @@ set_atomic_buffer_binding(struct gl_context *ctx,
>     FLUSH_VERTICES(ctx, 0);
>     ctx->NewDriverState |= ctx->DriverFlags.NewAtomicBuffer;
>  
> -   _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj);
> -
> -   if (bufObj == ctx->Shared->NullBufferObj) {
> -      binding->Offset = -1;
> -      binding->Size = -1;
> -   } else {
> -      binding->Offset = offset;
> -      binding->Size = size;
> -   }
> +   set_atomic_buffer_binding(ctx, binding, bufObj, offset, size);
>  }
>  
>  void GLAPIENTRY
> @@ -2556,8 +2566,8 @@ _mesa_BindBufferRange(GLenum target, GLuint index,
>        bind_buffer_range_uniform_buffer(ctx, index, bufObj, offset, size);
>        return;
>     case GL_ATOMIC_COUNTER_BUFFER:
> -      set_atomic_buffer_binding(ctx, index, bufObj, offset, size,
> -                                "glBindBufferRange");
> +      bind_atomic_buffer(ctx, index, bufObj, offset, size,
> +                         "glBindBufferRange");
>        return;
>     default:
>        _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferRange(target)");
> @@ -2620,8 +2630,8 @@ _mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer)
>        bind_buffer_base_uniform_buffer(ctx, index, bufObj);
>        return;
>     case GL_ATOMIC_COUNTER_BUFFER:
> -      set_atomic_buffer_binding(ctx, index, bufObj, 0, 0,
> -                                "glBindBufferBase");
> +      bind_atomic_buffer(ctx, index, bufObj, 0, 0,
> +                         "glBindBufferBase");
>        return;
>     default:
>        _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferBase(target)");
> -- 
> 1.7.10.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 229 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140213/f28d6717/attachment.pgp>


More information about the mesa-dev mailing list