[Mesa-dev] [PATCH 04/10] mesa: split bind_buffer_range_uniform_buffer() in two

Iago Toral itoral at igalia.com
Tue May 23 08:53:40 UTC 2017


Patches 4-9 are:

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>

I dropped a minor suggestion on patch 10, if you agree with it you can
add my Rb to that patch too.

On Mon, 2017-05-22 at 15:46 +1000, Timothy Arceri wrote:
> This will help us implement KHR_no_error support.
> ---
>  src/mesa/main/bufferobj.c | 32 +++++++++++++++++++-------------
>  1 file changed, 19 insertions(+), 13 deletions(-)
> 
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index 461d697..2c5d56b 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -3112,53 +3112,59 @@ bind_shader_storage_buffer(struct gl_context
> *ctx,
>         binding->AutomaticSize == autoSize) {
>        return;
>     }
>  
>     FLUSH_VERTICES(ctx, 0);
>     ctx->NewDriverState |= ctx->DriverFlags.NewShaderStorageBuffer;
>  
>     set_ssbo_binding(ctx, binding, bufObj, offset, size, autoSize);
>  }
>  
> +static void
> +bind_buffer_range_uniform_buffer(struct gl_context *ctx, GLuint
> index,
> +                                 struct gl_buffer_object *bufObj,
> +                                 GLintptr offset, GLsizeiptr size)
> +{
> +   if (bufObj == ctx->Shared->NullBufferObj) {
> +      offset = -1;
> +      size = -1;
> +   }
> +
> +   _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, bufObj);
> +   bind_uniform_buffer(ctx, index, bufObj, offset, size, GL_FALSE);
> +}
> +
>  /**
>   * Bind a region of a buffer object to a uniform block binding
> point.
>   * \param index  the uniform buffer binding point index
>   * \param bufObj  the buffer object
>   * \param offset  offset to the start of buffer object region
>   * \param size  size of the buffer object region
>   */
>  static void
> -bind_buffer_range_uniform_buffer(struct gl_context *ctx,
> -				 GLuint index,
> -				 struct gl_buffer_object *bufObj,
> -				 GLintptr offset,
> -				 GLsizeiptr size)
> +bind_buffer_range_uniform_buffer_err(struct gl_context *ctx, GLuint
> index,
> +                                     struct gl_buffer_object
> *bufObj,
> +                                     GLintptr offset, GLsizeiptr
> size)
>  {
>     if (index >= ctx->Const.MaxUniformBufferBindings) {
>        _mesa_error(ctx, GL_INVALID_VALUE,
> "glBindBufferRange(index=%d)", index);
>        return;
>     }
>  
>     if (offset & (ctx->Const.UniformBufferOffsetAlignment - 1)) {
>        _mesa_error(ctx, GL_INVALID_VALUE,
>                    "glBindBufferRange(offset misaligned %d/%d)",
> (int) offset,
>  		  ctx->Const.UniformBufferOffsetAlignment);
>        return;
>     }
>  
> -   if (bufObj == ctx->Shared->NullBufferObj) {
> -      offset = -1;
> -      size = -1;
> -   }
> -
> -   _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, bufObj);
> -   bind_uniform_buffer(ctx, index, bufObj, offset, size, GL_FALSE);
> +   bind_buffer_range_uniform_buffer(ctx, index, bufObj, offset,
> size);
>  }
>  
>  /**
>   * Bind a region of a buffer object to a shader storage block
> binding point.
>   * \param index  the shader storage buffer binding point index
>   * \param bufObj  the buffer object
>   * \param offset  offset to the start of buffer object region
>   * \param size  size of the buffer object region
>   */
>  static void
> @@ -4009,21 +4015,21 @@ _mesa_BindBufferRange(GLenum target, GLuint
> index,
>     }
>  
>     switch (target) {
>     case GL_TRANSFORM_FEEDBACK_BUFFER:
>        _mesa_bind_buffer_range_transform_feedback(ctx,
>                                                   ctx-
> >TransformFeedback.CurrentObject,
>                                                   index, bufObj,
> offset, size,
>                                                   false);
>        return;
>     case GL_UNIFORM_BUFFER:
> -      bind_buffer_range_uniform_buffer(ctx, index, bufObj, offset,
> size);
> +      bind_buffer_range_uniform_buffer_err(ctx, index, bufObj,
> offset, size);
>        return;
>     case GL_SHADER_STORAGE_BUFFER:
>        bind_buffer_range_shader_storage_buffer(ctx, index, bufObj,
> offset, size);
>        return;
>     case GL_ATOMIC_COUNTER_BUFFER:
>        bind_atomic_buffer(ctx, index, bufObj, offset, size,
>                           "glBindBufferRange");
>        return;
>     default:
>        _mesa_error(ctx, GL_INVALID_ENUM,
> "glBindBufferRange(target)");


More information about the mesa-dev mailing list