[Mesa-dev] [PATCH v2 20/82] mesa: Implement _mesa_BindBufferRange for target GL_SHADER_STORAGE_BUFFER

Jordan Justen jordan.l.justen at intel.com
Wed Jun 17 12:15:50 PDT 2015


19-20 Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

On 2015-06-03 00:01:10, Iago Toral Quiroga wrote:
> ---
>  src/mesa/main/bufferobj.c | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
> 
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index fb5331e..4277880 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -3157,6 +3157,40 @@ bind_buffer_range_uniform_buffer(struct gl_context *ctx,
>     bind_uniform_buffer(ctx, index, bufObj, offset, size, GL_FALSE);
>  }
>  
> +/**
> + * 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
> +bind_buffer_range_shader_storage_buffer(struct gl_context *ctx,
> +                                        GLuint index,
> +                                        struct gl_buffer_object *bufObj,
> +                                        GLintptr offset,
> +                                        GLsizeiptr size)
> +{
> +   if (index >= ctx->Const.MaxShaderStorageBufferBindings) {
> +      _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(index=%d)", index);
> +      return;
> +   }
> +
> +   if (offset & (ctx->Const.ShaderStorageBufferOffsetAlignment - 1)) {
> +      _mesa_error(ctx, GL_INVALID_VALUE,
> +                  "glBindBufferRange(offset misaligned %d/%d)", (int) offset,
> +                  ctx->Const.ShaderStorageBufferOffsetAlignment);
> +      return;
> +   }
> +
> +   if (bufObj == ctx->Shared->NullBufferObj) {
> +      offset = -1;
> +      size = -1;
> +   }
> +
> +   _mesa_reference_buffer_object(ctx, &ctx->ShaderStorageBuffer, bufObj);
> +   bind_shader_storage_buffer(ctx, index, bufObj, offset, size, GL_FALSE);
> +}
>  
>  /**
>   * Bind a buffer object to a uniform block binding point.
> @@ -4227,6 +4261,9 @@ _mesa_BindBufferRange(GLenum target, GLuint index,
>     case GL_UNIFORM_BUFFER:
>        bind_buffer_range_uniform_buffer(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");
> -- 
> 1.9.1
> 
> _______________________________________________
> 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