Re: [Mesa-dev] [PATCH 04/21] mesa: implement sparse buffer commitment

2017-02-09 Thread Ian Romanick
Patches 1, 2, and 4 are

Reviewed-by: Ian Romanick 

I sent some comments on patch 3, and I'll leave review of the Gallium
patches to people who actually know Gallium. :)

On 02/08/2017 01:42 PM, Nicolai Hähnle wrote:
> From: Nicolai Hähnle 
> 
> ---
>  src/mesa/main/bufferobj.c | 66 
> +++
>  src/mesa/main/dd.h| 10 +++
>  2 files changed, 76 insertions(+)
> 
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index 5f23868..14b4eef 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -4057,14 +4057,80 @@ _mesa_InvalidateBufferData(GLuint buffer)
>ctx->Driver.InvalidateBufferSubData(ctx, bufObj, 0, bufObj->Size);
>  }
>  
> +static void
> +buffer_page_commitment(struct gl_context *ctx,
> +   struct gl_buffer_object *bufferObj,
> +   GLintptr offset, GLsizeiptr size,
> +   GLboolean commit, const char *func)
> +{
> +   if (!(bufferObj->StorageFlags & GL_SPARSE_STORAGE_BIT_ARB)) {
> +  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(not a sparse buffer 
> object)",
> +  func);
> +  return;
> +   }
> +
> +   if (size < 0 || size > bufferObj->Size ||
> +   offset < 0 || offset > bufferObj->Size - size) {
> +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(out of bounds)",
> +  func);
> +  return;
> +   }
> +
> +   /* The GL_ARB_sparse_buffer extension specification says:
> +*
> +* "INVALID_VALUE is generated by BufferPageCommitmentARB if  
> is
> +* not an integer multiple of SPARSE_BUFFER_PAGE_SIZE_ARB, or if 
> 
> +* is not an integer multiple of SPARSE_BUFFER_PAGE_SIZE_ARB and does
> +* not extend to the end of the buffer's data store."
> +*/
> +   if (offset % ctx->Const.SparseBufferPageSize != 0) {
> +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(offset not aligned to page 
> size)",
> +  func);
> +  return;
> +   }
> +
> +   if (size % ctx->Const.SparseBufferPageSize != 0 &&
> +   offset + size != bufferObj->Size) {
> +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(size not aligned to page size)",
> +  func);
> +  return;
> +   }
> +
> +   ctx->Driver.BufferPageCommitment(ctx, bufferObj, offset, size, commit);
> +}
> +
>  void GLAPIENTRY
>  _mesa_BufferPageCommitmentARB(GLenum target, GLintptr offset, GLsizeiptr 
> size,
>GLboolean commit)
>  {
> +   GET_CURRENT_CONTEXT(ctx);
> +   struct gl_buffer_object *bufferObj;
> +
> +   bufferObj = get_buffer(ctx, "glBufferPageCommitmentARB", target,
> +  GL_INVALID_ENUM);
> +   if (!bufferObj)
> +  return;
> +
> +   buffer_page_commitment(ctx, bufferObj, offset, size, commit,
> +  "glBufferPageCommitmentARB");
>  }
>  
>  void GLAPIENTRY
>  _mesa_NamedBufferPageCommitmentARB(GLuint buffer, GLintptr offset,
> GLsizeiptr size, GLboolean commit)
>  {
> +   GET_CURRENT_CONTEXT(ctx);
> +   struct gl_buffer_object *bufferObj;
> +
> +   bufferObj = _mesa_lookup_bufferobj(ctx, buffer);
> +   if (!bufferObj || bufferObj == ) {
> +  /* Note: the extension spec is not clear about the excpected error 
> value. */
> +  _mesa_error(ctx, GL_INVALID_VALUE,
> +  "glNamedBufferPageCommitmentARB(name = %u) invalid object",
> +  buffer);
> +  return;
> +   }
> +
> +   buffer_page_commitment(ctx, bufferObj, offset, size, commit,
> +  "glNamedBufferPageCommitmentARB");
>  }
> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
> index 7ebd084..4fe9d5e 100644
> --- a/src/mesa/main/dd.h
> +++ b/src/mesa/main/dd.h
> @@ -984,6 +984,16 @@ struct dd_function_table {
>  */
> void (*QueryMemoryInfo)(struct gl_context *ctx,
> struct gl_memory_info *info);
> +
> +   /**
> +* \name GL_ARB_sparse_buffer interface
> +*/
> +   /*@{*/
> +   void (*BufferPageCommitment)(struct gl_context *ctx,
> +struct gl_buffer_object *bufferObj,
> +GLintptr offset, GLsizeiptr size,
> +GLboolean commit);
> +   /*@}*/
>  };
>  
>  
> 

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 04/21] mesa: implement sparse buffer commitment

2017-02-08 Thread Nicolai Hähnle
From: Nicolai Hähnle 

---
 src/mesa/main/bufferobj.c | 66 +++
 src/mesa/main/dd.h| 10 +++
 2 files changed, 76 insertions(+)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 5f23868..14b4eef 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -4057,14 +4057,80 @@ _mesa_InvalidateBufferData(GLuint buffer)
   ctx->Driver.InvalidateBufferSubData(ctx, bufObj, 0, bufObj->Size);
 }
 
+static void
+buffer_page_commitment(struct gl_context *ctx,
+   struct gl_buffer_object *bufferObj,
+   GLintptr offset, GLsizeiptr size,
+   GLboolean commit, const char *func)
+{
+   if (!(bufferObj->StorageFlags & GL_SPARSE_STORAGE_BIT_ARB)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(not a sparse buffer object)",
+  func);
+  return;
+   }
+
+   if (size < 0 || size > bufferObj->Size ||
+   offset < 0 || offset > bufferObj->Size - size) {
+  _mesa_error(ctx, GL_INVALID_VALUE, "%s(out of bounds)",
+  func);
+  return;
+   }
+
+   /* The GL_ARB_sparse_buffer extension specification says:
+*
+* "INVALID_VALUE is generated by BufferPageCommitmentARB if  is
+* not an integer multiple of SPARSE_BUFFER_PAGE_SIZE_ARB, or if 
+* is not an integer multiple of SPARSE_BUFFER_PAGE_SIZE_ARB and does
+* not extend to the end of the buffer's data store."
+*/
+   if (offset % ctx->Const.SparseBufferPageSize != 0) {
+  _mesa_error(ctx, GL_INVALID_VALUE, "%s(offset not aligned to page size)",
+  func);
+  return;
+   }
+
+   if (size % ctx->Const.SparseBufferPageSize != 0 &&
+   offset + size != bufferObj->Size) {
+  _mesa_error(ctx, GL_INVALID_VALUE, "%s(size not aligned to page size)",
+  func);
+  return;
+   }
+
+   ctx->Driver.BufferPageCommitment(ctx, bufferObj, offset, size, commit);
+}
+
 void GLAPIENTRY
 _mesa_BufferPageCommitmentARB(GLenum target, GLintptr offset, GLsizeiptr size,
   GLboolean commit)
 {
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufferObj;
+
+   bufferObj = get_buffer(ctx, "glBufferPageCommitmentARB", target,
+  GL_INVALID_ENUM);
+   if (!bufferObj)
+  return;
+
+   buffer_page_commitment(ctx, bufferObj, offset, size, commit,
+  "glBufferPageCommitmentARB");
 }
 
 void GLAPIENTRY
 _mesa_NamedBufferPageCommitmentARB(GLuint buffer, GLintptr offset,
GLsizeiptr size, GLboolean commit)
 {
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufferObj;
+
+   bufferObj = _mesa_lookup_bufferobj(ctx, buffer);
+   if (!bufferObj || bufferObj == ) {
+  /* Note: the extension spec is not clear about the excpected error 
value. */
+  _mesa_error(ctx, GL_INVALID_VALUE,
+  "glNamedBufferPageCommitmentARB(name = %u) invalid object",
+  buffer);
+  return;
+   }
+
+   buffer_page_commitment(ctx, bufferObj, offset, size, commit,
+  "glNamedBufferPageCommitmentARB");
 }
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 7ebd084..4fe9d5e 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -984,6 +984,16 @@ struct dd_function_table {
 */
void (*QueryMemoryInfo)(struct gl_context *ctx,
struct gl_memory_info *info);
+
+   /**
+* \name GL_ARB_sparse_buffer interface
+*/
+   /*@{*/
+   void (*BufferPageCommitment)(struct gl_context *ctx,
+struct gl_buffer_object *bufferObj,
+GLintptr offset, GLsizeiptr size,
+GLboolean commit);
+   /*@}*/
 };
 
 
-- 
2.9.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev