[Mesa-dev] [PATCH 03/21] mesa: implement sparse storage buffer allocation

Ian Romanick idr at freedesktop.org
Thu Feb 9 12:57:33 UTC 2017


On 02/08/2017 01:42 PM, Nicolai Hähnle wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
> 
> ---
>  src/mesa/main/bufferobj.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index cbd9228..5f23868 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -1531,21 +1531,34 @@ _mesa_buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj,
>                       GLenum target, GLsizeiptr size, const GLvoid *data,
>                       GLbitfield flags, const char *func)
>  {
> +   GLbitfield valid_flags;

I'd move the declaration down to the initializer, but *shrug*.

> +
>     if (size <= 0) {
>        _mesa_error(ctx, GL_INVALID_VALUE, "%s(size <= 0)", func);
>        return;
>     }
>  
> -   if (flags & ~(GL_MAP_READ_BIT |
> +   valid_flags = GL_MAP_READ_BIT |
>                   GL_MAP_WRITE_BIT |
>                   GL_MAP_PERSISTENT_BIT |
>                   GL_MAP_COHERENT_BIT |
>                   GL_DYNAMIC_STORAGE_BIT |
> -                 GL_CLIENT_STORAGE_BIT)) {
> +                 GL_CLIENT_STORAGE_BIT;
> +
> +   if (ctx->Extensions.ARB_sparse_buffer)
> +      valid_flags |= GL_SPARSE_STORAGE_BIT_ARB;
> +
> +   if (flags & ~valid_flags) {
>        _mesa_error(ctx, GL_INVALID_VALUE, "%s(invalid flag bits set)", func);
>        return;
>     }
>  

Could we get a spec quote here?  It will surely help some poor fool later...

> +   if (flags & GL_SPARSE_STORAGE_BIT_ARB &&
> +       flags & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) {
> +      _mesa_error(ctx, GL_INVALID_VALUE, "%s(SPARSE_STORAGE and READ/WRITE)", func);
> +      return;
> +   }
> +
>     if (flags & GL_MAP_PERSISTENT_BIT &&
>         !(flags & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT))) {
>        _mesa_error(ctx, GL_INVALID_VALUE,
> 



More information about the mesa-dev mailing list