[Mesa-dev] [PATCH 0/5] Newbie Project : Implement ARB_clear_buffer_object

2013-12-10 Thread Pi Tabred
Hello,

these are some patches to implement "ARB_clear_buffer_object" (as suggested by 
Ian Romanick).
I also wrote some piglit tests and will be submitting those in a minute.

Best Regards,
Pi Tabred

*Note* that I don't have write access.

Pi Tabred (5):
  mesa: Add infrastructure for GL_ARB_clear_buffer_object
  mesa: Make validate_texbuffer_format function available externally
  mesa: add _mesa_bufferobj_range_mapped function
  mesa: Implement functions for clear_buffer_object extensions
  mesa: Add extension to release notes and to list of supported
extensions

 docs/relnotes/10.1.html|   1 +
 src/mapi/glapi/gen/ARB_clear_buffer_object.xml |  50 
 src/mapi/glapi/gen/gl_API.xml  |   6 +-
 src/mesa/main/bufferobj.c  | 258 +++-
 src/mesa/main/bufferobj.h  |   4 +
 src/mesa/main/dd.h |   5 +
 src/mesa/main/extensions.c |   1 +
 src/mesa/main/tests/dispatch_sanity.cpp|   4 +-
 src/mesa/main/teximage.c   | 398 +
 src/mesa/main/teximage.h   |   4 +
 10 files changed, 516 insertions(+), 215 deletions(-)
 create mode 100644 src/mapi/glapi/gen/ARB_clear_buffer_object.xml

-- 
1.8.3.1

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


[Mesa-dev] [PATCH 4/5] mesa: Implement functions for clear_buffer_object extensions

2013-12-10 Thread Pi Tabred
 - _mesa_buffer_clear_subdata: default callback for dd function table
 - _mesa_ClearBufferData: API function
 - _mesa_ClearBufferSubData: API function

*NOTE* According to the spec, it should be possible to clear some part of
a buffer, even if a different, non-overlapping part is mapped, this is currently
not possible. It was suggested to implement ClearBufferSubData using 
MapBufferRange. However, this does not work if a part of the buffer is already
mapped. I am open for suggestions.

Modify get_buffer to return the correct error for this extension
---
 src/mesa/main/bufferobj.c | 206 +-
 src/mesa/main/bufferobj.h |   4 +
 2 files changed, 209 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index bfeed83..66d6ad4 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -41,6 +41,9 @@
 #include "fbobject.h"
 #include "mtypes.h"
 #include "texobj.h"
+#include "teximage.h"
+#include "glformats.h"
+#include "texstore.h"
 #include "transformfeedback.h"
 #include "dispatch.h"
 
@@ -138,7 +141,13 @@ get_buffer(struct gl_context *ctx, const char *func, 
GLenum target)
}
 
if (!_mesa_is_bufferobj(*bufObj)) {
-  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(buffer 0)", func);
+  if (strcmp(func, "glClearBufferSubData\0") == 0 ||
+  strcmp(func, "glClearBufferData\0") == 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(no buffer bound)", func);
+  }
+  else {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(buffer 0)", func);
+  }
   return NULL;
}
 
@@ -539,6 +548,64 @@ _mesa_buffer_get_subdata( struct gl_context *ctx, 
GLintptrARB offset,
 
 
 /**
+ * Clear a subrange of buffer object with supplied data. If the data range
+ * specified by \c size + \c offset extends beyond the end of the buffer
+ * the error INVALID_VALUE is generated, if data is NULL the buffer is filled
+ * with zeros.
+ *
+ * This is the default callback for \c dd_function_table::ClearBufferSubData()
+ * Note that all GL error checking will have been done already.
+ *
+ * \param ctx GL context.
+ * \param internalformat  Internal format of the buffer data.
+ * \param offset  Offset of the first byte to be cleared.
+ * \param sizeSize, in bytes, of the data range.
+ * \param format  Format of the supplied data.
+ * \param typeType of the supplied data.
+ * \param dataSource of the data.
+ * \param bufObj  Object to be used.
+ *
+ * \sa glClearBufferSubDataARB, dd_function_table::ClearBufferSubData.
+ */
+static void
+_mesa_buffer_clear_subdata( struct gl_context *ctx, GLenum internalformat,
+GLintptr offset, GLsizeiptr size,
+GLenum format, GLenum type,
+const GLvoid *data, struct gl_buffer_object 
*bufObj )
+{
+   ASSERT(ctx->Driver.MapBufferRange);
+   void *dest = ctx->Driver.MapBufferRange(ctx, offset, size,
+GL_MAP_WRITE_BIT | 
GL_MAP_INVALIDATE_RANGE_BIT,
+bufObj);
+
+   if (data == NULL)
+   {
+  memset(dest, 0, size);
+  ctx->Driver.UnmapBuffer(ctx, bufObj);
+  return;
+   }
+
+   gl_format formatMesa = _mesa_validate_texbuffer_format(ctx, internalformat);
+   GLenum formatBase = _mesa_get_format_base_format(formatMesa);
+
+   size_t sizeOfFormat = _mesa_get_format_bytes(formatMesa);
+
+   GLubyte* src = malloc(sizeOfFormat);
+   _mesa_texstore(ctx, 1, formatBase, formatMesa, 0,
+  &src, 1, 1, 1, format, type, data, &ctx->Unpack);
+
+   for (int i = 0; i < size/sizeOfFormat; ++i)
+   {
+  memcpy(dest, src, sizeOfFormat);
+  dest += sizeOfFormat;
+   }
+   ctx->Driver.UnmapBuffer(ctx, bufObj);
+
+   free(src);
+}
+
+
+/**
  * Default fallback for \c dd_function_table::MapBufferRange().
  * Called via glMapBufferRange().
  */
@@ -844,6 +911,9 @@ _mesa_init_buffer_object_functions(struct dd_function_table 
*driver)
driver->GetBufferSubData = _mesa_buffer_get_subdata;
driver->UnmapBuffer = _mesa_buffer_unmap;
 
+   /* GL_ARB_clear_buffer_object */
+   driver->ClearBufferSubData = _mesa_buffer_clear_subdata;
+
/* GL_ARB_map_buffer_range */
driver->MapBufferRange = _mesa_buffer_map_range;
driver->FlushMappedBufferRange = _mesa_buffer_flush_mapped_range;
@@ -1172,6 +1242,140 @@ _mesa_GetBufferSubData(GLenum target, GLintptrARB 
offset,
 }
 
 
+void GLAPIENTRY
+_mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format,
+ GLenum type, const GLvoid * data)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   gl_format internalFormatMesa = _mesa_validate_texbuffer_format(ctx, 
internalformat);
+   if (internalFormatMesa == MESA_FORMAT_NONE) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "glClearBufferData(invalid internalformat)");
+  return;
+   }
+
+   /* NOTE: not 

[Mesa-dev] [PATCH 2/5] mesa: Make validate_texbuffer_format function available externally

2013-12-10 Thread Pi Tabred
 - change storage class from static to extern
 - rename validate_texbuffer_format to _mesa_validate_texbuffer_format
---
 src/mesa/main/teximage.c | 398 ---
 src/mesa/main/teximage.h |   4 +
 2 files changed, 206 insertions(+), 196 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 7ec3e20..6e04ba5 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1519,6 +1519,207 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, 
GLenum target,
 }
 
 
+static gl_format
+get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat)
+{
+   switch (internalFormat) {
+   case GL_ALPHA8:
+  return MESA_FORMAT_A8;
+   case GL_ALPHA16:
+  return MESA_FORMAT_A16;
+   case GL_ALPHA16F_ARB:
+  return MESA_FORMAT_ALPHA_FLOAT16;
+   case GL_ALPHA32F_ARB:
+  return MESA_FORMAT_ALPHA_FLOAT32;
+   case GL_ALPHA8I_EXT:
+  return MESA_FORMAT_ALPHA_INT8;
+   case GL_ALPHA16I_EXT:
+  return MESA_FORMAT_ALPHA_INT16;
+   case GL_ALPHA32I_EXT:
+  return MESA_FORMAT_ALPHA_INT32;
+   case GL_ALPHA8UI_EXT:
+  return MESA_FORMAT_ALPHA_UINT8;
+   case GL_ALPHA16UI_EXT:
+  return MESA_FORMAT_ALPHA_UINT16;
+   case GL_ALPHA32UI_EXT:
+  return MESA_FORMAT_ALPHA_UINT32;
+   case GL_LUMINANCE8:
+  return MESA_FORMAT_L8;
+   case GL_LUMINANCE16:
+  return MESA_FORMAT_L16;
+   case GL_LUMINANCE16F_ARB:
+  return MESA_FORMAT_LUMINANCE_FLOAT16;
+   case GL_LUMINANCE32F_ARB:
+  return MESA_FORMAT_LUMINANCE_FLOAT32;
+   case GL_LUMINANCE8I_EXT:
+  return MESA_FORMAT_LUMINANCE_INT8;
+   case GL_LUMINANCE16I_EXT:
+  return MESA_FORMAT_LUMINANCE_INT16;
+   case GL_LUMINANCE32I_EXT:
+  return MESA_FORMAT_LUMINANCE_INT32;
+   case GL_LUMINANCE8UI_EXT:
+  return MESA_FORMAT_LUMINANCE_UINT8;
+   case GL_LUMINANCE16UI_EXT:
+  return MESA_FORMAT_LUMINANCE_UINT16;
+   case GL_LUMINANCE32UI_EXT:
+  return MESA_FORMAT_LUMINANCE_UINT32;
+   case GL_LUMINANCE8_ALPHA8:
+  return MESA_FORMAT_AL88;
+   case GL_LUMINANCE16_ALPHA16:
+  return MESA_FORMAT_AL1616;
+   case GL_LUMINANCE_ALPHA16F_ARB:
+  return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16;
+   case GL_LUMINANCE_ALPHA32F_ARB:
+  return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32;
+   case GL_LUMINANCE_ALPHA8I_EXT:
+  return MESA_FORMAT_LUMINANCE_ALPHA_INT8;
+   case GL_LUMINANCE_ALPHA16I_EXT:
+  return MESA_FORMAT_LUMINANCE_ALPHA_INT8;
+   case GL_LUMINANCE_ALPHA32I_EXT:
+  return MESA_FORMAT_LUMINANCE_ALPHA_INT16;
+   case GL_LUMINANCE_ALPHA8UI_EXT:
+  return MESA_FORMAT_LUMINANCE_ALPHA_UINT8;
+   case GL_LUMINANCE_ALPHA16UI_EXT:
+  return MESA_FORMAT_LUMINANCE_ALPHA_UINT16;
+   case GL_LUMINANCE_ALPHA32UI_EXT:
+  return MESA_FORMAT_LUMINANCE_ALPHA_UINT32;
+   case GL_INTENSITY8:
+  return MESA_FORMAT_I8;
+   case GL_INTENSITY16:
+  return MESA_FORMAT_I16;
+   case GL_INTENSITY16F_ARB:
+  return MESA_FORMAT_INTENSITY_FLOAT16;
+   case GL_INTENSITY32F_ARB:
+  return MESA_FORMAT_INTENSITY_FLOAT32;
+   case GL_INTENSITY8I_EXT:
+  return MESA_FORMAT_INTENSITY_INT8;
+   case GL_INTENSITY16I_EXT:
+  return MESA_FORMAT_INTENSITY_INT16;
+   case GL_INTENSITY32I_EXT:
+  return MESA_FORMAT_INTENSITY_INT32;
+   case GL_INTENSITY8UI_EXT:
+  return MESA_FORMAT_INTENSITY_UINT8;
+   case GL_INTENSITY16UI_EXT:
+  return MESA_FORMAT_INTENSITY_UINT16;
+   case GL_INTENSITY32UI_EXT:
+  return MESA_FORMAT_INTENSITY_UINT32;
+   case GL_RGBA8:
+  return MESA_FORMAT_RGBA_REV;
+   case GL_RGBA16:
+  return MESA_FORMAT_RGBA_16;
+   case GL_RGBA16F_ARB:
+  return MESA_FORMAT_RGBA_FLOAT16;
+   case GL_RGBA32F_ARB:
+  return MESA_FORMAT_RGBA_FLOAT32;
+   case GL_RGBA8I_EXT:
+  return MESA_FORMAT_RGBA_INT8;
+   case GL_RGBA16I_EXT:
+  return MESA_FORMAT_RGBA_INT16;
+   case GL_RGBA32I_EXT:
+  return MESA_FORMAT_RGBA_INT32;
+   case GL_RGBA8UI_EXT:
+  return MESA_FORMAT_RGBA_UINT8;
+   case GL_RGBA16UI_EXT:
+  return MESA_FORMAT_RGBA_UINT16;
+   case GL_RGBA32UI_EXT:
+  return MESA_FORMAT_RGBA_UINT32;
+
+   case GL_RG8:
+  return MESA_FORMAT_GR88;
+   case GL_RG16:
+  return MESA_FORMAT_GR1616;
+   case GL_RG16F:
+  return MESA_FORMAT_RG_FLOAT16;
+   case GL_RG32F:
+  return MESA_FORMAT_RG_FLOAT32;
+   case GL_RG8I:
+  return MESA_FORMAT_RG_INT8;
+   case GL_RG16I:
+  return MESA_FORMAT_RG_INT16;
+   case GL_RG32I:
+  return MESA_FORMAT_RG_INT32;
+   case GL_RG8UI:
+  return MESA_FORMAT_RG_UINT8;
+   case GL_RG16UI:
+  return MESA_FORMAT_RG_UINT16;
+   case GL_RG32UI:
+  return MESA_FORMAT_RG_UINT32;
+
+   case GL_R8:
+  return MESA_FORMAT_R8;
+   case GL_R16:
+  return MESA_FORMAT_R16;
+   case GL_R16F:
+  return MESA_FORMAT_R_FLOAT16;
+   case GL_R32F:
+  return MESA_FORMAT_R_FLOAT32;
+   case GL_R8I:
+  return MESA_FORMAT_R_INT8;
+   case GL_R16I:
+  return MESA_FORMAT_R_INT16

[Mesa-dev] [PATCH 3/5] mesa: add _mesa_bufferobj_range_mapped function

2013-12-10 Thread Pi Tabred
Add function to test if the buffer is already mapped and
if so, if the to be mapped range overlaps with the mapped range.
Modify the _mesa_InvalidateBufferSubData function to use
the new function.
---
 src/mesa/main/bufferobj.c | 52 +--
 1 file changed, 37 insertions(+), 15 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 8b5ebc4..bfeed83 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -241,6 +241,40 @@ buffer_object_subdata_range_good( struct gl_context * ctx, 
GLenum target,
 
 
 /**
+ * Tests if to be used range is already mapped.
+ * The regions do not overlap if and only if the end of the discard
+ * region is before the mapped region or the start of the discard region
+ * is after the mapped region.
+ *
+ * Note that 'end' and 'mappEnd' are the first byte *after* the discard
+ * region and the mapped region, repsectively.  It is okay for that byte
+ * to be mapped (for 'end') or discarded (for 'mapEnd').
+ *
+ * \param obj Buffer object target on which to operate.
+ * \param offset  Offset of the first byte of the subdata range.
+ * \param sizeSize, in bytes, of the subdata range.
+ * \return   true if ranges overlap, false otherwise
+ *
+ */
+static GLboolean
+_mesa_bufferobj_range_mapped( const struct gl_buffer_object *obj,
+  GLintptr offset, GLsizeiptr size )
+{
+   if (_mesa_bufferobj_mapped(obj))
+   {
+  const GLintptr end = offset + size;
+  const GLintptr mapEnd = obj->Offset + obj->Length;
+
+  if (!(end <= obj->Offset || offset >= mapEnd))
+  {
+ return GL_TRUE;
+  }
+   }
+   return GL_FALSE;
+}
+
+
+/**
  * Allocate and initialize a new buffer object.
  * 
  * Default callback for the \c dd_function_table::NewBufferObject() hook.
@@ -2331,23 +2365,11 @@ _mesa_InvalidateBufferSubData(GLuint buffer, GLintptr 
offset,
 * mapped by MapBuffer, or if the invalidate range intersects the range
 * currently mapped by MapBufferRange."
 */
-   if (_mesa_bufferobj_mapped(bufObj)) {
-  const GLintptr mapEnd = bufObj->Offset + bufObj->Length;
-
-  /* The regions do not overlap if and only if the end of the discard
-   * region is before the mapped region or the start of the discard region
-   * is after the mapped region.
-   *
-   * Note that 'end' and 'mapEnd' are the first byte *after* the discard
-   * region and the mapped region, repsectively.  It is okay for that byte
-   * to be mapped (for 'end') or discarded (for 'mapEnd').
-   */
-  if (!(end <= bufObj->Offset || offset >= mapEnd)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
+   if (_mesa_bufferobj_range_mapped(bufObj, offset, length)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
  "glInvalidateBufferSubData(intersection with mapped "
  "range)");
- return;
-  }
+  return;
}
 
/* We don't actually do anything for this yet.  Just return after
-- 
1.8.3.1

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


[Mesa-dev] [PATCH 1/5] mesa: Add infrastructure for GL_ARB_clear_buffer_object

2013-12-10 Thread Pi Tabred
 - add xml file for extension
 - add reference in gl_API.xml
 - add pointer to device driver function table
 - add new functions to list of available functions
---
 src/mapi/glapi/gen/ARB_clear_buffer_object.xml | 50 ++
 src/mapi/glapi/gen/gl_API.xml  |  6 +++-
 src/mesa/main/dd.h |  5 +++
 src/mesa/main/tests/dispatch_sanity.cpp|  4 +--
 4 files changed, 62 insertions(+), 3 deletions(-)
 create mode 100644 src/mapi/glapi/gen/ARB_clear_buffer_object.xml

diff --git a/src/mapi/glapi/gen/ARB_clear_buffer_object.xml 
b/src/mapi/glapi/gen/ARB_clear_buffer_object.xml
new file mode 100644
index 000..e7baf6f
--- /dev/null
+++ b/src/mapi/glapi/gen/ARB_clear_buffer_object.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 5c877aa..af8ab2e 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -8460,7 +8460,11 @@
 
 
 
-
+
+
+http://www.w3.org/2001/XInclude"/>
+
+
 
 http://www.w3.org/2001/XInclude"/>
 
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index b5b874f..0e2bda0 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -569,6 +569,11 @@ struct dd_function_table {
 GLintptrARB offset, GLsizeiptrARB size,
 GLvoid *data, struct gl_buffer_object *obj );
 
+   void (*ClearBufferSubData)( struct gl_context *ctx, GLenum internalformat, 
+   GLintptr offset, GLsizeiptr size, 
+   GLenum format, GLenum type, 
+   const GLvoid *data, struct gl_buffer_object 
*obj );
+
void (*CopyBufferSubData)( struct gl_context *ctx,
   struct gl_buffer_object *src,
   struct gl_buffer_object *dst,
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index e57fb52..a2ed04b 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -846,8 +846,8 @@ const struct function gl_core_functions_possible[] = {
 // { "glGetObjectLabel", 43, -1 },  // XXX: Add to xml
 // { "glObjectPtrLabel", 43, -1 },  // XXX: Add to xml
 // { "glGetObjectPtrLabel", 43, -1 },   // XXX: Add to xml
-// { "glClearBufferData", 43, -1 }, // XXX: Add to xml
-// { "glClearBufferSubData", 43, -1 },  // XXX: Add to xml
+   { "glClearBufferData", 43, -1 },
+   { "glClearBufferSubData", 43, -1 },
 // { "glClearNamedBufferDataEXT", 43, -1 }, // XXX: Add to xml
 // { "glClearNamedBufferSubDataEXT", 43, -1 },  // XXX: Add to xml
 // { "glDispatchCompute", 43, -1 }, // XXX: Add to xml
-- 
1.8.3.1

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


[Mesa-dev] [PATCH 5/5] mesa: Add extension to release notes and to list of supported extensions

2013-12-10 Thread Pi Tabred
---
 docs/relnotes/10.1.html| 1 +
 src/mesa/main/extensions.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/docs/relnotes/10.1.html b/docs/relnotes/10.1.html
index dfb0969..778ae6a 100644
--- a/docs/relnotes/10.1.html
+++ b/docs/relnotes/10.1.html
@@ -45,6 +45,7 @@ Note: some of the new features are only available with 
certain drivers.
 
 
 GL_ARB_draw_indirect on i965.
+GL_ARB_clear_buffer_object
 
 
 
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 0828c60..6162802 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -82,6 +82,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_ES3_compatibility",   o(ARB_ES3_compatibility),   
GL, 2012 },
{ "GL_ARB_base_instance",   o(ARB_base_instance),   
GL, 2011 },
{ "GL_ARB_blend_func_extended", o(ARB_blend_func_extended), 
GL, 2009 },
+   { "GL_ARB_clear_buffer_object", o(dummy_true),  
GL, 2012 },
{ "GL_ARB_color_buffer_float",  o(ARB_color_buffer_float),  
GL, 2004 },
{ "GL_ARB_copy_buffer", o(dummy_true),  
GL, 2008 },
{ "GL_ARB_conservative_depth",  o(ARB_conservative_depth),  
GL, 2011 },
-- 
1.8.3.1

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


Re: [Mesa-dev] [PATCH 1/5] mesa: Add infrastructure for GL_ARB_clear_buffer_object

2013-12-11 Thread Pi Tabred


On 10.12.2013 18:00, Marek Olšák wrote:
> On Tue, Dec 10, 2013 at 2:13 PM, Pi Tabred  wrote:
>>  - add xml file for extension
>>  - add reference in gl_API.xml
>>  - add pointer to device driver function table
>>  - add new functions to list of available functions
>> ---
>>  src/mapi/glapi/gen/ARB_clear_buffer_object.xml | 50 
>> ++
>>  src/mapi/glapi/gen/gl_API.xml  |  6 +++-
>>  src/mesa/main/dd.h |  5 +++
>>  src/mesa/main/tests/dispatch_sanity.cpp|  4 +--
>>  4 files changed, 62 insertions(+), 3 deletions(-)
>>  create mode 100644 src/mapi/glapi/gen/ARB_clear_buffer_object.xml
>>
>> diff --git a/src/mapi/glapi/gen/ARB_clear_buffer_object.xml 
>> b/src/mapi/glapi/gen/ARB_clear_buffer_object.xml
>> new file mode 100644
>> index 000..e7baf6f
>> --- /dev/null
>> +++ b/src/mapi/glapi/gen/ARB_clear_buffer_object.xml
>> @@ -0,0 +1,50 @@
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
>> index 5c877aa..af8ab2e 100644
>> --- a/src/mapi/glapi/gen/gl_API.xml
>> +++ b/src/mapi/glapi/gen/gl_API.xml
>> @@ -8460,7 +8460,11 @@
>>
>>  
>>
>> -
>> +
>> +
>> +> xmlns:xi="http://www.w3.org/2001/XInclude"/>
>> +
>> +
>>
>>  > xmlns:xi="http://www.w3.org/2001/XInclude"/>
>>
>> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
>> index b5b874f..0e2bda0 100644
>> --- a/src/mesa/main/dd.h
>> +++ b/src/mesa/main/dd.h
>> @@ -569,6 +569,11 @@ struct dd_function_table {
>>  GLintptrARB offset, GLsizeiptrARB size,
>>  GLvoid *data, struct gl_buffer_object *obj );
>>
>> +   void (*ClearBufferSubData)( struct gl_context *ctx, GLenum 
>> internalformat,
>> +   GLintptr offset, GLsizeiptr size,
>> +   GLenum format, GLenum type,
>> +   const GLvoid *data, struct gl_buffer_object 
>> *obj );
> 
> This interface could be simpler. The unpacking from the data to the
> internal format should take place in mesa/main, so that drivers only
> have to implement something like this:
> 
> void (*ClearBufferSubData)(struct gl_context *ctx, struct
> gl_buffer_object *obj, GLintptr offset, GLsizeiptr size, GLvoid
> *element, int element_size);
> 
> "offset" and "size" should stay. "element" is the clear value that has
> "element_size" bytes. "element_size" is the size of the internal
> format in bytes.
> 
> Marek
> 

That's something I considered, but I thought the drivers might have
their own way of converting the data to the internalformat.
If that's not the case, I'll change it.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 4/5] mesa: Implement functions for clear_buffer_object extensions

2013-12-11 Thread Pi Tabred


On 10.12.2013 17:44, Brian Paul wrote:
> On 12/10/2013 06:13 AM, Pi Tabred wrote:
>> ... 
>> +  }
>> +   }
>> +
>> +   if (!_mesa_is_color_format(format)) {
>> +  _mesa_error(ctx, GL_INVALID_ENUM,
>> +  "glClearBufferData(no color format)");
>> +   }
> 
> Are you sure about that error?  Where is this mentioned in the spec?
> Plus, you're missing a 'return' statement.

I am not sure, but is it possible to convert data from a depth/stencil
format to a color format? If not, the statement

"INVALID_ENUM is generated by ClearBufferSubData if  or 
is not one of the supported format or type tokens."

could be interpreted as to include this error as only certain color
formats are allowed for the internalformat.


Either way, you are right about the missing 'return'.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 4/5] mesa: Implement functions for clear_buffer_object extensions

2013-12-11 Thread Pi Tabred


On 11.12.2013 16:51, Brian Paul wrote:
> On 12/11/2013 05:21 AM, Pi Tabred wrote:
>>
>>
>> On 10.12.2013 17:44, Brian Paul wrote:
>>> On 12/10/2013 06:13 AM, Pi Tabred wrote:
>>>> ...
>>>> +  }
>>>> +   }
>>>> +
>>>> +   if (!_mesa_is_color_format(format)) {
>>>> +  _mesa_error(ctx, GL_INVALID_ENUM,
>>>> +  "glClearBufferData(no color format)");
>>>> +   }
>>>
>>> Are you sure about that error?  Where is this mentioned in the spec?
>>> Plus, you're missing a 'return' statement.
>>
>> I am not sure, but is it possible to convert data from a depth/stencil
>> format to a color format? If not, the statement
>>
>> "INVALID_ENUM is generated by ClearBufferSubData if  or 
>> is not one of the supported format or type tokens."
>>
>> could be interpreted as to include this error as only certain color
>> formats are allowed for the internalformat.
> 
> OK, I've read the spec, and I think you're right.  But the code as-is
> may need a few more changes.
> 
> Table 3.15 of the 4.2 spec lists a subset of internal formats compared
> to what we check for in get_texbuffer_format().  The 3.15 table doesn't
> contain luminance or intensity values.  Our code might be wrong.  It
> looks like luminance/intensity formats aren't legal for texture buffers
> in core profiles.
> 
> I think the call to _mesa_is_color_format() is too lenient since it
> accepts compressed formats, etc.  _mesa_error_check_format_and_type()
> might not catch all the invalid formats either.   format/type
> error checking is such a hassle.  I think you should write some piglit
> tests that exercise invalid format/type/internalformat combinations to
> make sure that we really catch these invalid combinations.
> 
> -Brian
> 

all luminance, intensity and alpha formats are removed in core profiles.
It's good that you mention this, that's something I wanted to ask about.
My solution would be to check in get_texbuffer_format() if it's a core
context and if that's the case return MESA_FORMAT_NONE for these formats.

with regards to your second point, I have to disagree. you are right
that _mesa_is_color_format() is too lenient, but the combination with
_mesa_error_check_format_and_type makes it work as compressed formats
are not allowed for the format parameter.
I already wrote some piglit tests for the format/type combination (see
piglit mailing list) but I can extend them.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH V2 00/10] Newbie Project : Implement ARB_clear_buffer_object

2013-12-11 Thread Pi Tabred
Hello,

second version of the patches to implement "ARB_clear_buffer_object" (as 
suggested by Ian Romanick).
I tried to include all hints and hope I have not forgotten any.

Best Regards,
Pi Tabred

Pi Tabred (10):
  mesa: Add infrastructure for GL_ARB_clear_buffer_object
  mesa: Make validate_texbuffer_format function available externally
  mesa: Modify format validation to check for extension not context
version
  mesa: get_texbuffer_format(): differentiate between core and compat
context
  mesa: Add bufferobj_range_mapped function
  mesa: Modify get_buffer() to allow for a variable error code
  mesa: Implement functions for clear_buffer_object extensions
  Add ARB_clear_buffer_object to list of supported extensions
  Modify release notes to include ARB_clear_buffer_object extension
  mesa: Cleanup mesa/main/bufferobj.h (column wrapping and space between
lines)

 docs/relnotes/10.1.html|   1 +
 src/mapi/glapi/gen/ARB_clear_buffer_object.xml |  50 
 src/mapi/glapi/gen/gl_API.xml  |   6 +-
 src/mesa/main/bufferobj.c  | 372 ++---
 src/mesa/main/bufferobj.h  |  59 +++-
 src/mesa/main/dd.h |   5 +
 src/mesa/main/extensions.c |   1 +
 src/mesa/main/tests/dispatch_sanity.cpp|   4 +-
 src/mesa/main/teximage.c   | 183 ++--
 src/mesa/main/teximage.h   |   4 +
 10 files changed, 538 insertions(+), 147 deletions(-)
 create mode 100644 src/mapi/glapi/gen/ARB_clear_buffer_object.xml

-- 
1.8.3.1

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


[Mesa-dev] [PATCH V2 02/10] mesa: Make validate_texbuffer_format function available externally

2013-12-11 Thread Pi Tabred
 - change storage class from static to extern
 - rename validate_texbuffer_format to _mesa_validate_texbuffer_format
---
 src/mesa/main/teximage.c | 7 ---
 src/mesa/main/teximage.h | 4 
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 7ec3e20..21dcef5 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -4036,8 +4036,9 @@ get_texbuffer_format(const struct gl_context *ctx, GLenum 
internalFormat)
 }
 
 
-static gl_format
-validate_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat)
+gl_format
+_mesa_validate_texbuffer_format(const struct gl_context *ctx,
+GLenum internalFormat)
 {
gl_format format = get_texbuffer_format(ctx, internalFormat);
GLenum datatype;
@@ -4087,7 +4088,7 @@ texbufferrange(struct gl_context *ctx, GLenum target, 
GLenum internalFormat,
   return;
}
 
-   format = validate_texbuffer_format(ctx, internalFormat);
+   format = _mesa_validate_texbuffer_format(ctx, internalFormat);
if (format == MESA_FORMAT_NONE) {
   _mesa_error(ctx, GL_INVALID_ENUM, "glTexBuffer(internalFormat 0x%x)",
   internalFormat);
diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
index 792383d..0b57863 100644
--- a/src/mesa/main/teximage.h
+++ b/src/mesa/main/teximage.h
@@ -147,6 +147,10 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, 
GLenum target,
GLint level, GLint width, GLint height,
GLint depth, GLint border);
 
+extern gl_format
+_mesa_validate_texbuffer_format(const struct gl_context *ctx,
+GLenum internalFormat);
+
 /**
  * Lock a texture for updating.  See also _mesa_lock_context_textures().
  */
-- 
1.8.3.1

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


[Mesa-dev] [PATCH V2 07/10] mesa: Implement functions for clear_buffer_object extensions

2013-12-11 Thread Pi Tabred
 - _mesa_buffer_clear_subdata: default callback for dd function table
 - _mesa_ClearBufferData: API function
 - _mesa_ClearBufferSubData: API function
 - buffer_object_format_good: helper function, check if the internalformat,
   format and type parameter are legal
 - buffer_object_convert_clear: helper function, convert the supplied data
   to the desired internalformat and clear the buffer by calling the
   callback for dd_function_table::ClearbufferSubData
---
 src/mesa/main/bufferobj.c | 250 ++
 src/mesa/main/bufferobj.h |   4 +
 2 files changed, 254 insertions(+)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 0e5b705..72515ef 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -41,6 +41,9 @@
 #include "fbobject.h"
 #include "mtypes.h"
 #include "texobj.h"
+#include "teximage.h"
+#include "glformats.h"
+#include "texstore.h"
 #include "transformfeedback.h"
 #include "dispatch.h"
 
@@ -283,6 +286,120 @@ buffer_object_subdata_range_good(struct gl_context * ctx, 
GLenum target,
 
 
 /**
+ * Tests the format and type parameters and sets the GL error code for
+ * \c glClearBufferData and \c glClearBufferSubData.
+ *
+ * \param ctxGL context.
+ * \param target Buffer object target on which to operate.
+ * \param offset Offset of the first byte of the subdata range.
+ * \param size   Size, in bytes, of the subdata range.
+ * \param mappedRangeIf true, checks if an overlapping range is mapped.
+ *   If false, checks if buffer is mapped.
+ * \param errorNoBuffer  Error code if no buffer is bound to target.
+ * \param caller Name of calling function for recording errors.
+ * \return   A pointer to the buffer object bound to \c target in the
+ *   specified context or \c NULL if any of the parameter or state
+ *   conditions are invalid.
+ *
+ * \sa glBufferSubDataARB, glGetBufferSubDataARB, glClearBufferSubData
+ */
+static gl_format
+buffer_object_format_good(struct gl_context *ctx,
+  const struct gl_buffer_object *obj,
+  GLenum internalformat, GLenum format, GLenum type,
+  const char* caller)
+{
+   gl_format internalFormatMesa;
+   GLenum errorFormatType;
+
+   internalFormatMesa = _mesa_validate_texbuffer_format(ctx, internalformat);
+   if (internalFormatMesa == MESA_FORMAT_NONE) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "%s(invalid internalformat)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   /* NOTE: not mentioned in ARB_clear_buffer_object but according to
+* EXT_texture_integer there is no conversion between integer and
+* non-integer formats
+   */
+   if (_mesa_is_enum_format_signed_int(format) !=
+   _mesa_is_format_integer_color(internalFormatMesa)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "%s(integer vs non-integer)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   if (!_mesa_is_color_format(format)) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "%s(format is not a color format)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   errorFormatType = _mesa_error_check_format_and_type(ctx, format,
+   type);
+   if (errorFormatType != GL_NO_ERROR) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "%s(invalid format or type)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   return internalFormatMesa;
+}
+
+
+/**
+ * Converts the supplied data to the internalformat and clears the desired
+ * range.
+ *
+ * \param ctx GL context.
+ * \param offset  Offset of the to be cleared range.
+ * \param sizeSize of the to be cleared range.
+ * \param internalformat  Format to which the data is converted.
+ * \param sizeOfFormatSize of the internalformat in bytes.
+ * \param format  Format of the supplied data.
+ * \param typeType of the supplied data.
+ * \param dataData which is used to clear the buffer.
+ * \param bufObj  To be cleared buffer.
+ * \return   A pointer to the buffer object bound to \c target in the
+ *   specified context or \c NULL if any of the parameter or state
+ *   conditions are invalid.
+ *
+ * \sa glClearBufferData, glClearBufferSubData
+ */
+static void
+buffer_object_convert_clear(struct gl_context *ctx,
+GLintptr offset, GLsizeiptr size,
+gl_format internalformat,
+unsigned int sizeOfFormat,
+GLenum format, GLenum type, const GLvoid* data,
+struct gl_buffer_object *bufObj)
+{
+   GLenum internalformatBase;
+   GLubyte* src;
+
+   if (data == NULL) {
+  ctx->Driver.ClearBufferSubData(ctx, 0, bufObj->Size,
+ NULL, 0, 

[Mesa-dev] [PATCH V2 06/10] mesa: Modify get_buffer() to allow for a variable error code

2013-12-11 Thread Pi Tabred
---
 src/mesa/main/bufferobj.c | 43 +++
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 98fd413..0e5b705 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -128,7 +128,8 @@ get_buffer_target(struct gl_context *ctx, GLenum target)
  *   specified context or \c NULL if \c target is invalid.
  */
 static inline struct gl_buffer_object *
-get_buffer(struct gl_context *ctx, const char *func, GLenum target)
+get_buffer(struct gl_context *ctx, const char *func, GLenum target,
+   GLenum error)
 {
struct gl_buffer_object **bufObj = get_buffer_target(ctx, target);
 
@@ -138,7 +139,7 @@ get_buffer(struct gl_context *ctx, const char *func, GLenum 
target)
}
 
if (!_mesa_is_bufferobj(*bufObj)) {
-  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(buffer 0)", func);
+  _mesa_error(ctx, error, "%s(no buffer bound)", func);
   return NULL;
}
 
@@ -225,6 +226,7 @@ bufferobj_range_mapped(const struct gl_buffer_object *obj,
  * \param sizeSize, in bytes, of the subdata range.
  * \param mappedRange  If true, checks if an overlapping range is mapped.
  * If false, checks if buffer is mapped.
+ * \param errorNoBuffer  Error code if no buffer is bound to target.
  * \param caller  Name of calling function for recording errors.
  * \return   A pointer to the buffer object bound to \c target in the
  *   specified context or \c NULL if any of the parameter or state
@@ -235,7 +237,8 @@ bufferobj_range_mapped(const struct gl_buffer_object *obj,
 static struct gl_buffer_object *
 buffer_object_subdata_range_good(struct gl_context * ctx, GLenum target,
  GLintptrARB offset, GLsizeiptrARB size,
- bool mappedRange, const char *caller)
+ bool mappedRange, GLenum errorNoBuffer,
+ const char *caller)
 {
struct gl_buffer_object *bufObj;
 
@@ -249,7 +252,7 @@ buffer_object_subdata_range_good(struct gl_context * ctx, 
GLenum target,
   return NULL;
}
 
-   bufObj = get_buffer(ctx, caller, target);
+   bufObj = get_buffer(ctx, caller, target, errorNoBuffer);
if (!bufObj)
   return NULL;
 
@@ -1103,7 +1106,7 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size,
   return;
}
 
-   bufObj = get_buffer(ctx, "glBufferDataARB", target);
+   bufObj = get_buffer(ctx, "glBufferDataARB", target, GL_INVALID_OPERATION);
if (!bufObj)
   return;
 
@@ -1142,7 +1145,8 @@ _mesa_BufferSubData(GLenum target, GLintptrARB offset,
struct gl_buffer_object *bufObj;
 
bufObj = buffer_object_subdata_range_good( ctx, target, offset, size,
-  false, "glBufferSubDataARB");
+  false, GL_INVALID_OPERATION,
+  "glBufferSubDataARB" );
if (!bufObj) {
   /* error already recorded */
   return;
@@ -1166,7 +1170,8 @@ _mesa_GetBufferSubData(GLenum target, GLintptrARB offset,
struct gl_buffer_object *bufObj;
 
bufObj = buffer_object_subdata_range_good(ctx, target, offset, size,
- false, "glGetBufferSubDataARB");
+ false, GL_INVALID_OPERATION,
+ "glGetBufferSubDataARB");
if (!bufObj) {
   /* error already recorded */
   return;
@@ -1211,7 +1216,7 @@ _mesa_MapBuffer(GLenum target, GLenum access)
   return NULL;
}
 
-   bufObj = get_buffer(ctx, "glMapBufferARB", target);
+   bufObj = get_buffer(ctx, "glMapBufferARB", target, GL_INVALID_OPERATION);
if (!bufObj)
   return NULL;
 
@@ -1280,7 +1285,7 @@ _mesa_UnmapBuffer(GLenum target)
GLboolean status = GL_TRUE;
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
 
-   bufObj = get_buffer(ctx, "glUnmapBufferARB", target);
+   bufObj = get_buffer(ctx, "glUnmapBufferARB", target, GL_INVALID_OPERATION);
if (!bufObj)
   return GL_FALSE;
 
@@ -1341,7 +1346,8 @@ _mesa_GetBufferParameteriv(GLenum target, GLenum pname, 
GLint *params)
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
 
-   bufObj = get_buffer(ctx, "glGetBufferParameterivARB", target);
+   bufObj = get_buffer(ctx, "glGetBufferParameterivARB", target,
+   GL_INVALID_OPERATION);
if (!bufObj)
   return;
 
@@ -1394,7 +1400,8 @@ _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, 
GLint64 *params)
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
 
-   bufObj = get_buffer(ctx, "glGetBufferParameteri64v", target);
+   bufObj = get_buffer(ctx, "glGetBufferParameteri64v", target,
+   GL_INVALID_OPERATION);
if (!bufObj)
   return;
 
@@ -1447,7 +1454,8 @@ _mesa_GetBufferPointerv(GLenum target, G

[Mesa-dev] [PATCH V2 05/10] mesa: Add bufferobj_range_mapped function

2013-12-11 Thread Pi Tabred
Add function to test if the buffer is already mapped and if so,
if the mapped range overlaps the given range.
Modify the _mesa_InvalidateBufferSubData function to use
the new function.

Enable buffer_object_subdata_range_good() to use bufferobj_range_mapped
---
 src/mesa/main/bufferobj.c | 87 +++
 1 file changed, 57 insertions(+), 30 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 8b5ebc4..98fd413 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -186,25 +186,56 @@ simplified_access_mode(struct gl_context *ctx, GLbitfield 
access)
 
 
 /**
+ * Test if the buffer is mapped, and if so, if the mapped range overlaps the
+ * given range.
+ * The regions do not overlap if and only if the end of the discard
+ * region is before the mapped region or the start of the discard region
+ * is after the mapped region.
+ *
+ * \param obj Buffer object target on which to operate.
+ * \param offset  Offset of the first byte of the subdata range.
+ * \param sizeSize, in bytes, of the subdata range.
+ * \return   true if ranges overlap, false otherwise
+ *
+ */
+static bool
+bufferobj_range_mapped(const struct gl_buffer_object *obj,
+  GLintptr offset, GLsizeiptr size)
+{
+   if (_mesa_bufferobj_mapped(obj)) {
+  const GLintptr end = offset + size;
+  const GLintptr mapEnd = obj->Offset + obj->Length;
+
+  if (!(end <= obj->Offset || offset >= mapEnd)) {
+ return true;
+  }
+   }
+   return false;
+}
+
+
+/**
  * Tests the subdata range parameters and sets the GL error code for
- * \c glBufferSubDataARB and \c glGetBufferSubDataARB.
+ * \c glBufferSubDataARB, \c glGetBufferSubDataARB and
+ * \c glClearBufferSubData.
  *
  * \param ctx GL context.
  * \param target  Buffer object target on which to operate.
  * \param offset  Offset of the first byte of the subdata range.
  * \param sizeSize, in bytes, of the subdata range.
+ * \param mappedRange  If true, checks if an overlapping range is mapped.
+ * If false, checks if buffer is mapped.
  * \param caller  Name of calling function for recording errors.
  * \return   A pointer to the buffer object bound to \c target in the
  *   specified context or \c NULL if any of the parameter or state
- *   conditions for \c glBufferSubDataARB or \c glGetBufferSubDataARB
- *   are invalid.
+ *   conditions are invalid.
  *
- * \sa glBufferSubDataARB, glGetBufferSubDataARB
+ * \sa glBufferSubDataARB, glGetBufferSubDataARB, glClearBufferSubData
  */
 static struct gl_buffer_object *
-buffer_object_subdata_range_good( struct gl_context * ctx, GLenum target, 
-  GLintptrARB offset, GLsizeiptrARB size,
-  const char *caller )
+buffer_object_subdata_range_good(struct gl_context * ctx, GLenum target,
+ GLintptrARB offset, GLsizeiptrARB size,
+ bool mappedRange, const char *caller)
 {
struct gl_buffer_object *bufObj;
 
@@ -224,16 +255,24 @@ buffer_object_subdata_range_good( struct gl_context * 
ctx, GLenum target,
 
if (offset + size > bufObj->Size) {
   _mesa_error(ctx, GL_INVALID_VALUE,
- "%s(offset %lu + size %lu > buffer size %lu)", caller,
+  "%s(offset %lu + size %lu > buffer size %lu)", caller,
   (unsigned long) offset,
   (unsigned long) size,
   (unsigned long) bufObj->Size);
   return NULL;
}
-   if (_mesa_bufferobj_mapped(bufObj)) {
-  /* Buffer is currently mapped */
-  _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);
-  return NULL;
+
+   if (mappedRange == true) {
+  if (bufferobj_range_mapped(bufObj, offset, size)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);
+ return NULL;
+  }
+   }
+   else {
+  if (_mesa_bufferobj_mapped(bufObj)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);
+ return NULL;
+  }
}
 
return bufObj;
@@ -1103,7 +1142,7 @@ _mesa_BufferSubData(GLenum target, GLintptrARB offset,
struct gl_buffer_object *bufObj;
 
bufObj = buffer_object_subdata_range_good( ctx, target, offset, size,
-  "glBufferSubDataARB" );
+  false, "glBufferSubDataARB");
if (!bufObj) {
   /* error already recorded */
   return;
@@ -1126,8 +1165,8 @@ _mesa_GetBufferSubData(GLenum target, GLintptrARB offset,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
 
-   bufObj = buffer_object_subdata_range_good( ctx, target, offset, size,
-  "glGetBufferSubDataARB" );
+   bufObj = buffer_object_subdata_range_good(ctx, target, offset, size,
+ false, "glGe

[Mesa-dev] [PATCH V2 09/10] Modify release notes to include ARB_clear_buffer_object extension

2013-12-11 Thread Pi Tabred
---
 docs/relnotes/10.1.html | 1 +
 1 file changed, 1 insertion(+)

diff --git a/docs/relnotes/10.1.html b/docs/relnotes/10.1.html
index dfb0969..778ae6a 100644
--- a/docs/relnotes/10.1.html
+++ b/docs/relnotes/10.1.html
@@ -45,6 +45,7 @@ Note: some of the new features are only available with 
certain drivers.
 
 
 GL_ARB_draw_indirect on i965.
+GL_ARB_clear_buffer_object
 
 
 
-- 
1.8.3.1

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


[Mesa-dev] [PATCH V2 10/10] mesa: Cleanup mesa/main/bufferobj.h (column wrapping and space between lines)

2013-12-11 Thread Pi Tabred
---
 src/mesa/main/bufferobj.h | 59 ---
 1 file changed, 45 insertions(+), 14 deletions(-)

diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index b38519f..71988b0 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -57,10 +57,10 @@ _mesa_is_bufferobj(const struct gl_buffer_object *obj)
 
 
 extern void
-_mesa_init_buffer_objects( struct gl_context *ctx );
+_mesa_init_buffer_objects(struct gl_context *ctx);
 
 extern void
-_mesa_free_buffer_objects( struct gl_context *ctx );
+_mesa_free_buffer_objects(struct gl_context *ctx);
 
 extern bool
 _mesa_handle_bind_buffer_gen(struct gl_context *ctx,
@@ -77,9 +77,9 @@ extern struct gl_buffer_object *
 _mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer);
 
 extern void
-_mesa_initialize_buffer_object( struct gl_context *ctx,
-   struct gl_buffer_object *obj,
-   GLuint name, GLenum target );
+_mesa_initialize_buffer_object(struct gl_context *ctx,
+   struct gl_buffer_object *obj,
+   GLuint name, GLenum target);
 
 extern void
 _mesa_reference_buffer_object_(struct gl_context *ctx,
@@ -105,59 +105,90 @@ _mesa_init_buffer_object_functions(struct 
dd_function_table *driver);
 /*
  * API functions
  */
-
 void GLAPIENTRY
 _mesa_BindBuffer(GLenum target, GLuint buffer);
+
 void GLAPIENTRY
 _mesa_DeleteBuffers(GLsizei n, const GLuint * buffer);
+
 void GLAPIENTRY
 _mesa_GenBuffers(GLsizei n, GLuint * buffer);
+
 GLboolean GLAPIENTRY
 _mesa_IsBuffer(GLuint buffer);
+
 void GLAPIENTRY
-_mesa_BufferData(GLenum target, GLsizeiptrARB size, const GLvoid * data, 
GLenum usage);
+_mesa_BufferData(GLenum target, GLsizeiptrARB size,
+ const GLvoid * data, GLenum usage);
+
 void GLAPIENTRY
-_mesa_BufferSubData(GLenum target, GLintptrARB offset, GLsizeiptrARB size, 
const GLvoid * data);
+_mesa_BufferSubData(GLenum target, GLintptrARB offset,
+GLsizeiptrARB size, const GLvoid * data);
+
 void GLAPIENTRY
-_mesa_GetBufferSubData(GLenum target, GLintptrARB offset, GLsizeiptrARB size, 
void * data);
+_mesa_GetBufferSubData(GLenum target, GLintptrARB offset,
+   GLsizeiptrARB size, void * data);
+
 void GLAPIENTRY
-_mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format, 
GLenum type, const GLvoid * data);
+_mesa_ClearBufferData(GLenum target, GLenum internalformat,
+  GLenum format, GLenum type,
+  const GLvoid * data);
+
 void GLAPIENTRY
-_mesa_ClearBufferSubData(GLenum target, GLenum internalformat, GLintptr 
offset, GLsizeiptr size, GLenum format, GLenum type, const GLvoid * data);
+_mesa_ClearBufferSubData(GLenum target, GLenum internalformat,
+ GLintptr offset, GLsizeiptr size,
+ GLenum format, GLenum type,
+ const GLvoid * data);
+
 void * GLAPIENTRY
 _mesa_MapBuffer(GLenum target, GLenum access);
+
 GLboolean GLAPIENTRY
 _mesa_UnmapBuffer(GLenum target);
+
 void GLAPIENTRY
 _mesa_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params);
+
 void GLAPIENTRY
 _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params);
+
 void GLAPIENTRY
 _mesa_GetBufferPointerv(GLenum target, GLenum pname, GLvoid **params);
+
 void GLAPIENTRY
 _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
 GLintptr readOffset, GLintptr writeOffset,
 GLsizeiptr size);
+
 void * GLAPIENTRY
 _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
  GLbitfield access);
+
 void GLAPIENTRY
-_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr 
length);
+_mesa_FlushMappedBufferRange(GLenum target,
+ GLintptr offset, GLsizeiptr length);
+
 GLenum GLAPIENTRY
 _mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option);
+
 GLenum GLAPIENTRY
 _mesa_ObjectUnpurgeableAPPLE(GLenum objectType, GLuint name, GLenum option);
+
 void GLAPIENTRY
-_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name, GLenum pname,
-GLint* params);
+_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name,
+GLenum pname, GLint* params);
+
 void GLAPIENTRY
 _mesa_BindBufferRange(GLenum target, GLuint index,
   GLuint buffer, GLintptr offset, GLsizeiptr size);
+
 void GLAPIENTRY
 _mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer);
+
 void GLAPIENTRY
 _mesa_InvalidateBufferSubData(GLuint buffer, GLintptr offset,
   GLsizeiptr length);
+
 void GLAPIENTRY
 _mesa_InvalidateBufferData(GLuint buffer);
 
-- 
1.8.3.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/li

[Mesa-dev] [PATCH V2 01/10] mesa: Add infrastructure for GL_ARB_clear_buffer_object

2013-12-11 Thread Pi Tabred
 - add xml file for extension
 - add reference in gl_API.xml
 - add pointer to device driver function table
 - add new functions to list of available functions
---
 src/mapi/glapi/gen/ARB_clear_buffer_object.xml | 50 ++
 src/mapi/glapi/gen/gl_API.xml  |  6 +++-
 src/mesa/main/dd.h |  5 +++
 src/mesa/main/tests/dispatch_sanity.cpp|  4 +--
 4 files changed, 62 insertions(+), 3 deletions(-)
 create mode 100644 src/mapi/glapi/gen/ARB_clear_buffer_object.xml

diff --git a/src/mapi/glapi/gen/ARB_clear_buffer_object.xml 
b/src/mapi/glapi/gen/ARB_clear_buffer_object.xml
new file mode 100644
index 000..e7baf6f
--- /dev/null
+++ b/src/mapi/glapi/gen/ARB_clear_buffer_object.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 5c877aa..af8ab2e 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -8460,7 +8460,11 @@
 
 
 
-
+
+
+http://www.w3.org/2001/XInclude"/>
+
+
 
 http://www.w3.org/2001/XInclude"/>
 
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index b5b874f..ae7b696 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -569,6 +569,11 @@ struct dd_function_table {
 GLintptrARB offset, GLsizeiptrARB size,
 GLvoid *data, struct gl_buffer_object *obj );
 
+   void (*ClearBufferSubData)( struct gl_context *ctx,
+   GLintptr offset, GLsizeiptr size,
+   const GLvoid* data, unsigned int dataSize,
+   struct gl_buffer_object *obj );
+
void (*CopyBufferSubData)( struct gl_context *ctx,
   struct gl_buffer_object *src,
   struct gl_buffer_object *dst,
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index e57fb52..a2ed04b 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -846,8 +846,8 @@ const struct function gl_core_functions_possible[] = {
 // { "glGetObjectLabel", 43, -1 },  // XXX: Add to xml
 // { "glObjectPtrLabel", 43, -1 },  // XXX: Add to xml
 // { "glGetObjectPtrLabel", 43, -1 },   // XXX: Add to xml
-// { "glClearBufferData", 43, -1 }, // XXX: Add to xml
-// { "glClearBufferSubData", 43, -1 },  // XXX: Add to xml
+   { "glClearBufferData", 43, -1 },
+   { "glClearBufferSubData", 43, -1 },
 // { "glClearNamedBufferDataEXT", 43, -1 }, // XXX: Add to xml
 // { "glClearNamedBufferSubDataEXT", 43, -1 },  // XXX: Add to xml
 // { "glDispatchCompute", 43, -1 }, // XXX: Add to xml
-- 
1.8.3.1

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


[Mesa-dev] [PATCH V2 08/10] Add ARB_clear_buffer_object to list of supported extensions

2013-12-11 Thread Pi Tabred
---
 src/mesa/main/extensions.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 0828c60..6162802 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -82,6 +82,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_ES3_compatibility",   o(ARB_ES3_compatibility),   
GL, 2012 },
{ "GL_ARB_base_instance",   o(ARB_base_instance),   
GL, 2011 },
{ "GL_ARB_blend_func_extended", o(ARB_blend_func_extended), 
GL, 2009 },
+   { "GL_ARB_clear_buffer_object", o(dummy_true),  
GL, 2012 },
{ "GL_ARB_color_buffer_float",  o(ARB_color_buffer_float),  
GL, 2004 },
{ "GL_ARB_copy_buffer", o(dummy_true),  
GL, 2008 },
{ "GL_ARB_conservative_depth",  o(ARB_conservative_depth),  
GL, 2011 },
-- 
1.8.3.1

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


[Mesa-dev] [PATCH V2 03/10] mesa: Modify format validation to check for extension not context version

2013-12-11 Thread Pi Tabred
---
 src/mesa/main/teximage.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 21dcef5..cbe572c 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -4053,15 +4053,10 @@ _mesa_validate_texbuffer_format(const struct gl_context 
*ctx,
if (datatype == GL_HALF_FLOAT && !ctx->Extensions.ARB_half_float_pixel)
   return MESA_FORMAT_NONE;
 
-   /* The GL_ARB_texture_rg and GL_ARB_texture_buffer_object specs don't make
-* any mention of R/RG formats, but they appear in the GL 3.1 core
-* specification.
-*/
-   if (ctx->Version <= 30) {
+   if (!ctx->Extensions.ARB_texture_rg) {
   GLenum base_format = _mesa_get_format_base_format(format);
-
   if (base_format == GL_R || base_format == GL_RG)
-return MESA_FORMAT_NONE;
+ return MESA_FORMAT_NONE;
}
 
if (!ctx->Extensions.ARB_texture_buffer_object_rgb32) {
-- 
1.8.3.1

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


[Mesa-dev] [PATCH V2 04/10] mesa: get_texbuffer_format(): differentiate between core and compat context

2013-12-11 Thread Pi Tabred
alpha, lumincance and intensity formats are illegal in a core context.
Add a check to return MESA_FORMAT_NONE if one of those is requested within
a core context.
---
 src/mesa/main/teximage.c | 167 ---
 1 file changed, 87 insertions(+), 80 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index cbe572c..cf8c52e 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3879,87 +3879,94 @@ _mesa_CompressedTexSubImage3D(GLenum target, GLint 
level, GLint xoffset,
 static gl_format
 get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat)
 {
+   if (ctx->API != API_OPENGL_CORE) {
+  switch (internalFormat) {
+  case GL_ALPHA8:
+ return MESA_FORMAT_A8;
+  case  GL_ALPHA16:
+ return MESA_FORMAT_A16;
+  case  GL_ALPHA16F_ARB:
+ return MESA_FORMAT_ALPHA_FLOAT16;
+  case  GL_ALPHA32F_ARB:
+ return MESA_FORMAT_ALPHA_FLOAT32;
+  case  GL_ALPHA8I_EXT:
+ return MESA_FORMAT_ALPHA_INT8;
+  case  GL_ALPHA16I_EXT:
+ return MESA_FORMAT_ALPHA_INT16;
+  case  GL_ALPHA32I_EXT:
+ return MESA_FORMAT_ALPHA_INT32;
+  case  GL_ALPHA8UI_EXT:
+ return MESA_FORMAT_ALPHA_UINT8;
+  case  GL_ALPHA16UI_EXT:
+ return MESA_FORMAT_ALPHA_UINT16;
+  case  GL_ALPHA32UI_EXT:
+ return MESA_FORMAT_ALPHA_UINT32;
+  case  GL_LUMINANCE8:
+ return MESA_FORMAT_L8;
+  case  GL_LUMINANCE16:
+ return MESA_FORMAT_L16;
+  case  GL_LUMINANCE16F_ARB:
+ return MESA_FORMAT_LUMINANCE_FLOAT16;
+  case  GL_LUMINANCE32F_ARB:
+ return MESA_FORMAT_LUMINANCE_FLOAT32;
+  case  GL_LUMINANCE8I_EXT:
+ return MESA_FORMAT_LUMINANCE_INT8;
+  case  GL_LUMINANCE16I_EXT:
+ return MESA_FORMAT_LUMINANCE_INT16;
+  case  GL_LUMINANCE32I_EXT:
+ return MESA_FORMAT_LUMINANCE_INT32;
+  case  GL_LUMINANCE8UI_EXT:
+ return MESA_FORMAT_LUMINANCE_UINT8;
+  case  GL_LUMINANCE16UI_EXT:
+ return MESA_FORMAT_LUMINANCE_UINT16;
+  case  GL_LUMINANCE32UI_EXT:
+ return MESA_FORMAT_LUMINANCE_UINT32;
+  case  GL_LUMINANCE8_ALPHA8:
+ return MESA_FORMAT_AL88;
+  case  GL_LUMINANCE16_ALPHA16:
+ return MESA_FORMAT_AL1616;
+  case  GL_LUMINANCE_ALPHA16F_ARB:
+ return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16;
+  case  GL_LUMINANCE_ALPHA32F_ARB:
+ return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32;
+  case  GL_LUMINANCE_ALPHA8I_EXT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_INT8;
+  case  GL_LUMINANCE_ALPHA16I_EXT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_INT8;
+  case  GL_LUMINANCE_ALPHA32I_EXT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_INT16;
+  case  GL_LUMINANCE_ALPHA8UI_EXT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_UINT8;
+  case  GL_LUMINANCE_ALPHA16UI_EXT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_UINT16;
+  case  GL_LUMINANCE_ALPHA32UI_EXT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_UINT32;
+  case  GL_INTENSITY8:
+ return MESA_FORMAT_I8;
+  case  GL_INTENSITY16:
+ return MESA_FORMAT_I16;
+  case  GL_INTENSITY16F_ARB:
+ return MESA_FORMAT_INTENSITY_FLOAT16;
+  case  GL_INTENSITY32F_ARB:
+ return MESA_FORMAT_INTENSITY_FLOAT32;
+  case  GL_INTENSITY8I_EXT:
+ return MESA_FORMAT_INTENSITY_INT8;
+  case  GL_INTENSITY16I_EXT:
+ return MESA_FORMAT_INTENSITY_INT16;
+  case  GL_INTENSITY32I_EXT:
+ return MESA_FORMAT_INTENSITY_INT32;
+  case  GL_INTENSITY8UI_EXT:
+ return MESA_FORMAT_INTENSITY_UINT8;
+  case  GL_INTENSITY16UI_EXT:
+ return MESA_FORMAT_INTENSITY_UINT16;
+  case  GL_INTENSITY32UI_EXT:
+ return MESA_FORMAT_INTENSITY_UINT32;
+  default:
+ break;
+  }
+   }
+
switch (internalFormat) {
-   case GL_ALPHA8:
-  return MESA_FORMAT_A8;
-   case GL_ALPHA16:
-  return MESA_FORMAT_A16;
-   case GL_ALPHA16F_ARB:
-  return MESA_FORMAT_ALPHA_FLOAT16;
-   case GL_ALPHA32F_ARB:
-  return MESA_FORMAT_ALPHA_FLOAT32;
-   case GL_ALPHA8I_EXT:
-  return MESA_FORMAT_ALPHA_INT8;
-   case GL_ALPHA16I_EXT:
-  return MESA_FORMAT_ALPHA_INT16;
-   case GL_ALPHA32I_EXT:
-  return MESA_FORMAT_ALPHA_INT32;
-   case GL_ALPHA8UI_EXT:
-  return MESA_FORMAT_ALPHA_UINT8;
-   case GL_ALPHA16UI_EXT:
-  return MESA_FORMAT_ALPHA_UINT16;
-   case GL_ALPHA32UI_EXT:
-  return MESA_FORMAT_ALPHA_UINT32;
-   case GL_LUMINANCE8:
-  return MESA_FORMAT_L8;
-   case GL_LUMINANCE16:
-  return MESA_FORMAT_L16;
-   case GL_LUMINANCE16F_ARB:
-  return MESA_FORMAT_LUMINANCE_FLOAT16;
-   case GL_LUMINANCE32F_ARB:
-  return MESA_FORMAT_LUMINANCE_FLOAT32;
-   case GL_LUMINANCE8I_EXT:
-  return MESA_FORMAT_LUMINANCE_INT8;
-   case GL_LUMINANCE16I_EXT:
-  return MESA_FORMAT_LUMINANCE_INT16;
-   case GL_LUMINANCE32I_EXT:
-  return 

Re: [Mesa-dev] [PATCH V2 01/10] mesa: Add infrastructure for GL_ARB_clear_buffer_object

2013-12-12 Thread Pi Tabred


On 12.12.2013 01:39, Brian Paul wrote:
> On 12/11/2013 02:55 PM, Pi Tabred wrote:
>>   - add xml file for extension
>>   - add reference in gl_API.xml
>>   - add pointer to device driver function table
>>   - add new functions to list of available functions
> 
> Or "- update dispatch_sanity.cpp"
> 
> 
>> ---
>>   src/mapi/glapi/gen/ARB_clear_buffer_object.xml | 50
>> ++
>>   src/mapi/glapi/gen/gl_API.xml  |  6 +++-
>>   src/mesa/main/dd.h |  5 +++
>>   src/mesa/main/tests/dispatch_sanity.cpp|  4 +--
>>   4 files changed, 62 insertions(+), 3 deletions(-)
>>   create mode 100644 src/mapi/glapi/gen/ARB_clear_buffer_object.xml
>>
>> diff --git a/src/mapi/glapi/gen/ARB_clear_buffer_object.xml
>> b/src/mapi/glapi/gen/ARB_clear_buffer_object.xml
>> new file mode 100644
>> index 000..e7baf6f
>> --- /dev/null
>> +++ b/src/mapi/glapi/gen/ARB_clear_buffer_object.xml
>> @@ -0,0 +1,50 @@
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +
>> +

Re: [Mesa-dev] [PATCH V2 07/10] mesa: Implement functions for clear_buffer_object extensions

2013-12-12 Thread Pi Tabred


On 12.12.2013 01:39, Brian Paul wrote:
> On 12/11/2013 02:55 PM, Pi Tabred wrote:
>>   - _mesa_buffer_clear_subdata: default callback for dd function table
>>   - _mesa_ClearBufferData: API function
>>   - _mesa_ClearBufferSubData: API function
>>   - buffer_object_format_good: helper function, check if the
>> internalformat,
>> format and type parameter are legal
>>   - buffer_object_convert_clear: helper function, convert the supplied
>> data
>> to the desired internalformat and clear the buffer by calling the
>> callback for dd_function_table::ClearbufferSubData
>> ---
>>   src/mesa/main/bufferobj.c | 250
>> ++
>>   src/mesa/main/bufferobj.h |   4 +
>>   2 files changed, 254 insertions(+)
>>
>> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
>> index 0e5b705..72515ef 100644
>> --- a/src/mesa/main/bufferobj.c
>> +++ b/src/mesa/main/bufferobj.c
>> @@ -41,6 +41,9 @@
>>   #include "fbobject.h"
>>   #include "mtypes.h"
>>   #include "texobj.h"
>> +#include "teximage.h"
>> +#include "glformats.h"
>> +#include "texstore.h"
>>   #include "transformfeedback.h"
>>   #include "dispatch.h"
>>
>> @@ -283,6 +286,120 @@ buffer_object_subdata_range_good(struct
>> gl_context * ctx, GLenum target,
>>
>>
>>   /**
>> + * Tests the format and type parameters and sets the GL error code for
>> + * \c glClearBufferData and \c glClearBufferSubData.
>> + *
>> + * \param ctxGL context.
>> + * \param target Buffer object target on which to operate.
>> + * \param offset Offset of the first byte of the subdata range.
>> + * \param size   Size, in bytes, of the subdata range.
>> + * \param mappedRangeIf true, checks if an overlapping range is
>> mapped.
>> + *   If false, checks if buffer is mapped.
>> + * \param errorNoBuffer  Error code if no buffer is bound to target.
>> + * \param caller Name of calling function for recording errors.
>> + * \return   A pointer to the buffer object bound to \c target in the
>> + *   specified context or \c NULL if any of the parameter or
>> state
>> + *   conditions are invalid.
> 
> But the code below returns a gl_format, not a pointer.
> 

sorry about that, to much copy-paste.

>> + *
>> + * \sa glBufferSubDataARB, glGetBufferSubDataARB, glClearBufferSubData
>> + */
>> +static gl_format
>> +buffer_object_format_good(struct gl_context *ctx,
>> +  const struct gl_buffer_object *obj,
>> +  GLenum internalformat, GLenum format,
>> GLenum type,
>> +  const char* caller)
> 
> Let's rename this function to something like
> "validate_buffer_clear_format".
> 
> 

sure, I just tried to be in line with the naming of the
buffer_object_subdata_range_good function

>> +{
>> +   gl_format internalFormatMesa;
> 
> I think mesaFormat would be more concise.
> 
> 
>> +   GLenum errorFormatType;
>> +
>> +   internalFormatMesa = _mesa_validate_texbuffer_format(ctx,
>> internalformat);
>> +   if (internalFormatMesa == MESA_FORMAT_NONE) {
>> +  _mesa_error(ctx, GL_INVALID_ENUM,
>> +  "%s(invalid internalformat)", caller);
>> +  return MESA_FORMAT_NONE;
>> +   }
>> +
>> +   /* NOTE: not mentioned in ARB_clear_buffer_object but according to
>> +* EXT_texture_integer there is no conversion between integer and
>> +* non-integer formats
>> +   */
>> +   if (_mesa_is_enum_format_signed_int(format) !=
>> +   _mesa_is_format_integer_color(internalFormatMesa)) {
>> +  _mesa_error(ctx, GL_INVALID_OPERATION,
>> +  "%s(integer vs non-integer)", caller);
>> +  return MESA_FORMAT_NONE;
>> +   }
>> +
>> +   if (!_mesa_is_color_format(format)) {
>> +  _mesa_error(ctx, GL_INVALID_ENUM,
>> +  "%s(format is not a color format)", caller);
>> +  return MESA_FORMAT_NONE;
>> +   }
>> +
>> +   errorFormatType = _mesa_error_check_format_and_type(ctx, format,
>> +   type);
>> +   if (errorFormatType != GL_NO_ERROR) {
>> +  _mesa_error(ctx, GL_INVALID_ENUM,
>> +  "%s(invalid format or type)", caller);
>> +  return MESA_FORMAT

Re: [Mesa-dev] [PATCH V2 07/10] mesa: Implement functions for clear_buffer_object extensions

2013-12-12 Thread Pi Tabred
I incorporated all hints except for the one regarding the malloc, not
sure about this one.

There is still the issue regarding the following:
According to the spec, it should be possible to clear some part of a
buffer, even if a different, non-overlapping part is mapped, this is
currently not possible. It was suggested to implement ClearBufferSubData
using MapBufferRange. However, this does not work if a part of the
buffer is already mapped.
I am not sure how to handle this. Maybe that's something that has to be
done inside the different drivers?

 - _mesa_buffer_clear_subdata: default callback for dd function table
 - _mesa_ClearBufferData: API function
 - _mesa_ClearBufferSubData: API function
 - validate_clear_buffer_format: helper function, check if the
internalformat,
   format and type parameter are legal
 - convert_clear_buffer_data: helper function, convert the supplied data
   to the desired internalformat.
---
 src/mesa/main/bufferobj.c | 249
++
 src/mesa/main/bufferobj.h |   4 +
 2 files changed, 253 insertions(+)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 1219891..6fb28a5 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -41,6 +41,9 @@
 #include "fbobject.h"
 #include "mtypes.h"
 #include "texobj.h"
+#include "teximage.h"
+#include "glformats.h"
+#include "texstore.h"
 #include "transformfeedback.h"
 #include "dispatch.h"

@@ -283,6 +286,97 @@ buffer_object_subdata_range_good(struct gl_context
* ctx, GLenum target,


 /**
+ * Test the format and type parameters and set the GL error code for
+ * \c glClearBufferData and \c glClearBufferSubData.
+ *
+ * \param ctx GL context.
+ * \param internalformat  Format to which the data is to be converted.
+ * \param format  Format of the supplied data.
+ * \param typeType of the supplied data.
+ * \param caller  Name of calling function for recording errors.
+ * \return   If internalformat, format and type are legal the gl_format
+ *   corresponding to internalformat, otherwise MESA_FORMAT_NONE.
+ *
+ * \sa glClearBufferData and glClearBufferSubData
+ */
+static gl_format
+validate_clear_buffer_format(struct gl_context *ctx,
+ GLenum internalformat,
+ GLenum format, GLenum type,
+ const char* caller)
+{
+   gl_format mesaFormat;
+   GLenum errorFormatType;
+
+   mesaFormat = _mesa_validate_texbuffer_format(ctx, internalformat);
+   if (mesaFormat == MESA_FORMAT_NONE) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "%s(invalid internalformat)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   /* NOTE: not mentioned in ARB_clear_buffer_object but according to
+* EXT_texture_integer there is no conversion between integer and
+* non-integer formats
+   */
+   if (_mesa_is_enum_format_signed_int(format) !=
+   _mesa_is_format_integer_color(mesaFormat)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "%s(integer vs non-integer)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   if (!_mesa_is_color_format(format)) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "%s(format is not a color format)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   errorFormatType = _mesa_error_check_format_and_type(ctx, format,
+   type);
+   if (errorFormatType != GL_NO_ERROR) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "%s(invalid format or type)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   return mesaFormat;
+}
+
+
+/**
+ * Convert the supplied data to the internalformat and clear the desired
+ * range.
+ *
+ * \param ctx GL context.
+ * \param internalformat  Format to which the data is converted.
+ * \param clearValue  Pointer, store converted data here.
+ * \param format  Format of the supplied data.
+ * \param typeType of the supplied data.
+ * \param dataData which is to be converted to internalformat
+ *
+ * \sa glClearBufferData, glClearBufferSubData
+ */
+static void
+convert_clear_buffer_data(struct gl_context *ctx,
+  gl_format internalformat,
+  GLubyte *clearValue, GLenum format, GLenum type,
+  const GLvoid *data)
+{
+   GLenum internalformatBase;
+
+   internalformatBase = _mesa_get_format_base_format(internalformat);
+
+
+   GLboolean success = _mesa_texstore(ctx, 1, internalformatBase,
+  internalformat, 0, &clearValue,
+  1, 1, 1,
+  format, type, data, &ctx->Unpack);
+   assert(success);
+}
+
+
+/**
  * Allocate and initialize a new buffer object.
  *
  * Default callback for the \c dd_function_table::NewBufferObject() hook.
@@ -547,6 +641,55 @@ _mesa_buffer_get_

Re: [Mesa-dev] [PATCH V2 07/10] mesa: Implement functions for clear_buffer_object extensions

2013-12-13 Thread Pi Tabred
I tried to tackle this issue:
>> There is still the issue regarding the following:
>> According to the spec, it should be possible to clear some part of a
>> buffer, even if a different, non-overlapping part is mapped, this is
>> currently not possible. It was suggested to implement ClearBufferSubData
>> using MapBufferRange. However, this does not work if a part of the
>> buffer is already mapped.
>> I am not sure how to handle this. Maybe that's something that has to be
>> done inside the different drivers?

I used BufferSubData to transfer the data, however according to the spec
BufferSubData is only guaranteed to work if the complete buffer is
unmapped.

 - _mesa_buffer_clear_subdata: default callback for dd function table
 - _mesa_ClearBufferData: API function
 - _mesa_ClearBufferSubData: API function
 - validate_clear_buffer_format: helper function, check if the
internalformat,
   format and type parameter are legal
 - convert_clear_buffer_data: helper function, convert the supplied data
   to the desired internalformat.
---
 src/mesa/main/bufferobj.c | 259
++
 src/mesa/main/bufferobj.h |   4 +
 2 files changed, 263 insertions(+)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 1219891..fb09aa9 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -41,6 +41,9 @@
 #include "fbobject.h"
 #include "mtypes.h"
 #include "texobj.h"
+#include "teximage.h"
+#include "glformats.h"
+#include "texstore.h"
 #include "transformfeedback.h"
 #include "dispatch.h"

@@ -283,6 +286,96 @@ buffer_object_subdata_range_good(struct gl_context
* ctx, GLenum target,


 /**
+ * Test the format and type parameters and set the GL error code for
+ * \c glClearBufferData and \c glClearBufferSubData.
+ *
+ * \param ctx GL context.
+ * \param internalformat  Format to which the data is to be converted.
+ * \param format  Format of the supplied data.
+ * \param typeType of the supplied data.
+ * \param caller  Name of calling function for recording errors.
+ * \return   If internalformat, format and type are legal the gl_format
+ *   corresponding to internalformat, otherwise MESA_FORMAT_NONE.
+ *
+ * \sa glClearBufferData and glClearBufferSubData
+ */
+static gl_format
+validate_clear_buffer_format(struct gl_context *ctx,
+ GLenum internalformat,
+ GLenum format, GLenum type,
+ const char* caller)
+{
+   gl_format mesaFormat;
+   GLenum errorFormatType;
+
+   mesaFormat = _mesa_validate_texbuffer_format(ctx, internalformat);
+   if (mesaFormat == MESA_FORMAT_NONE) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "%s(invalid internalformat)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   /* NOTE: not mentioned in ARB_clear_buffer_object but according to
+* EXT_texture_integer there is no conversion between integer and
+* non-integer formats
+   */
+   if (_mesa_is_enum_format_signed_int(format) !=
+   _mesa_is_format_integer_color(mesaFormat)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "%s(integer vs non-integer)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   if (!_mesa_is_color_format(format)) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "%s(format is not a color format)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   errorFormatType = _mesa_error_check_format_and_type(ctx, format,
+   type);
+   if (errorFormatType != GL_NO_ERROR) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "%s(invalid format or type)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   return mesaFormat;
+}
+
+
+/**
+ * Convert user-specified clear value to the specified internal format.
+ *
+ * \param ctx GL context.
+ * \param internalformat  Format to which the data is converted.
+ * \param clearValue  Pointer, store converted data here.
+ * \param format  Format of the supplied data.
+ * \param typeType of the supplied data.
+ * \param dataData which is to be converted to internalformat
+ *
+ * \sa glClearBufferData, glClearBufferSubData
+ */
+static void
+convert_clear_buffer_data(struct gl_context *ctx,
+  gl_format internalformat,
+  GLubyte *clearValue, GLenum format, GLenum type,
+  const GLvoid *data)
+{
+   GLenum internalformatBase;
+
+   internalformatBase = _mesa_get_format_base_format(internalformat);
+
+
+   GLboolean success = _mesa_texstore(ctx, 1, internalformatBase,
+  internalformat, 0, &clearValue,
+  1, 1, 1,
+  format, type, data, &ctx->Unpack);
+   assert(success);
+}
+
+
+/**
  * Allocate and initialize a new buffer object.
  *
  * Default 

[Mesa-dev] [PATCH V3 00/10] Newbie Project : Implement ARB_clear_buffer_object

2013-12-14 Thread Pi Tabred
Hello,

third version of the patches to implement "ARB_clear_buffer_object".
I hope I got everything this time.

Best Regards,
Pi Tabred

Pi Tabred (10):
  mesa: Add infrastructure for GL_ARB_clear_buffer_object
  mesa: Make validate_texbuffer_format function available externally
  mesa: Modify format validation to check for extension not context
version
  mesa: get_texbuffer_format(): differentiate between core and compat
context
  mesa: Add bufferobj_range_mapped function
  mesa: Modify get_buffer() to allow for a variable error code
  mesa: Implement functions for clear_buffer_object extensions
  Add ARB_clear_buffer_object to list of supported extensions
  Modify release notes to include ARB_clear_buffer_object extension
  mesa: Cleanup mesa/main/bufferobj.h (column wrapping and space between
lines)

 docs/relnotes/10.1.html|   1 +
 src/mapi/glapi/gen/ARB_clear_buffer_object.xml |  50 
 src/mapi/glapi/gen/gl_API.xml  |   6 +-
 src/mesa/main/bufferobj.c  | 397 ++---
 src/mesa/main/bufferobj.h  |  59 +++-
 src/mesa/main/dd.h |   6 +
 src/mesa/main/extensions.c |   1 +
 src/mesa/main/tests/dispatch_sanity.cpp|   4 +-
 src/mesa/main/teximage.c   | 183 ++--
 src/mesa/main/teximage.h   |   4 +
 10 files changed, 562 insertions(+), 149 deletions(-)
 create mode 100644 src/mapi/glapi/gen/ARB_clear_buffer_object.xml

-- 
1.8.3.1

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


[Mesa-dev] [PATCH V3 04/10] mesa: get_texbuffer_format(): differentiate between core and compat context

2013-12-14 Thread Pi Tabred
alpha, lumincance and intensity formats are illegal in a core context.
Add a check to return MESA_FORMAT_NONE if one of those is requested within
a core context.
---
 src/mesa/main/teximage.c | 167 ---
 1 file changed, 87 insertions(+), 80 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index f92dc1a..a05c65d 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3880,87 +3880,94 @@ _mesa_CompressedTexSubImage3D(GLenum target, GLint 
level, GLint xoffset,
 static gl_format
 get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat)
 {
+   if (ctx->API != API_OPENGL_CORE) {
+  switch (internalFormat) {
+  case GL_ALPHA8:
+ return MESA_FORMAT_A8;
+  case  GL_ALPHA16:
+ return MESA_FORMAT_A16;
+  case  GL_ALPHA16F_ARB:
+ return MESA_FORMAT_ALPHA_FLOAT16;
+  case  GL_ALPHA32F_ARB:
+ return MESA_FORMAT_ALPHA_FLOAT32;
+  case  GL_ALPHA8I_EXT:
+ return MESA_FORMAT_ALPHA_INT8;
+  case  GL_ALPHA16I_EXT:
+ return MESA_FORMAT_ALPHA_INT16;
+  case  GL_ALPHA32I_EXT:
+ return MESA_FORMAT_ALPHA_INT32;
+  case  GL_ALPHA8UI_EXT:
+ return MESA_FORMAT_ALPHA_UINT8;
+  case  GL_ALPHA16UI_EXT:
+ return MESA_FORMAT_ALPHA_UINT16;
+  case  GL_ALPHA32UI_EXT:
+ return MESA_FORMAT_ALPHA_UINT32;
+  case  GL_LUMINANCE8:
+ return MESA_FORMAT_L8;
+  case  GL_LUMINANCE16:
+ return MESA_FORMAT_L16;
+  case  GL_LUMINANCE16F_ARB:
+ return MESA_FORMAT_LUMINANCE_FLOAT16;
+  case  GL_LUMINANCE32F_ARB:
+ return MESA_FORMAT_LUMINANCE_FLOAT32;
+  case  GL_LUMINANCE8I_EXT:
+ return MESA_FORMAT_LUMINANCE_INT8;
+  case  GL_LUMINANCE16I_EXT:
+ return MESA_FORMAT_LUMINANCE_INT16;
+  case  GL_LUMINANCE32I_EXT:
+ return MESA_FORMAT_LUMINANCE_INT32;
+  case  GL_LUMINANCE8UI_EXT:
+ return MESA_FORMAT_LUMINANCE_UINT8;
+  case  GL_LUMINANCE16UI_EXT:
+ return MESA_FORMAT_LUMINANCE_UINT16;
+  case  GL_LUMINANCE32UI_EXT:
+ return MESA_FORMAT_LUMINANCE_UINT32;
+  case  GL_LUMINANCE8_ALPHA8:
+ return MESA_FORMAT_AL88;
+  case  GL_LUMINANCE16_ALPHA16:
+ return MESA_FORMAT_AL1616;
+  case  GL_LUMINANCE_ALPHA16F_ARB:
+ return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16;
+  case  GL_LUMINANCE_ALPHA32F_ARB:
+ return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32;
+  case  GL_LUMINANCE_ALPHA8I_EXT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_INT8;
+  case  GL_LUMINANCE_ALPHA16I_EXT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_INT8;
+  case  GL_LUMINANCE_ALPHA32I_EXT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_INT16;
+  case  GL_LUMINANCE_ALPHA8UI_EXT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_UINT8;
+  case  GL_LUMINANCE_ALPHA16UI_EXT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_UINT16;
+  case  GL_LUMINANCE_ALPHA32UI_EXT:
+ return MESA_FORMAT_LUMINANCE_ALPHA_UINT32;
+  case  GL_INTENSITY8:
+ return MESA_FORMAT_I8;
+  case  GL_INTENSITY16:
+ return MESA_FORMAT_I16;
+  case  GL_INTENSITY16F_ARB:
+ return MESA_FORMAT_INTENSITY_FLOAT16;
+  case  GL_INTENSITY32F_ARB:
+ return MESA_FORMAT_INTENSITY_FLOAT32;
+  case  GL_INTENSITY8I_EXT:
+ return MESA_FORMAT_INTENSITY_INT8;
+  case  GL_INTENSITY16I_EXT:
+ return MESA_FORMAT_INTENSITY_INT16;
+  case  GL_INTENSITY32I_EXT:
+ return MESA_FORMAT_INTENSITY_INT32;
+  case  GL_INTENSITY8UI_EXT:
+ return MESA_FORMAT_INTENSITY_UINT8;
+  case  GL_INTENSITY16UI_EXT:
+ return MESA_FORMAT_INTENSITY_UINT16;
+  case  GL_INTENSITY32UI_EXT:
+ return MESA_FORMAT_INTENSITY_UINT32;
+  default:
+ break;
+  }
+   }
+
switch (internalFormat) {
-   case GL_ALPHA8:
-  return MESA_FORMAT_A8;
-   case GL_ALPHA16:
-  return MESA_FORMAT_A16;
-   case GL_ALPHA16F_ARB:
-  return MESA_FORMAT_ALPHA_FLOAT16;
-   case GL_ALPHA32F_ARB:
-  return MESA_FORMAT_ALPHA_FLOAT32;
-   case GL_ALPHA8I_EXT:
-  return MESA_FORMAT_ALPHA_INT8;
-   case GL_ALPHA16I_EXT:
-  return MESA_FORMAT_ALPHA_INT16;
-   case GL_ALPHA32I_EXT:
-  return MESA_FORMAT_ALPHA_INT32;
-   case GL_ALPHA8UI_EXT:
-  return MESA_FORMAT_ALPHA_UINT8;
-   case GL_ALPHA16UI_EXT:
-  return MESA_FORMAT_ALPHA_UINT16;
-   case GL_ALPHA32UI_EXT:
-  return MESA_FORMAT_ALPHA_UINT32;
-   case GL_LUMINANCE8:
-  return MESA_FORMAT_L8;
-   case GL_LUMINANCE16:
-  return MESA_FORMAT_L16;
-   case GL_LUMINANCE16F_ARB:
-  return MESA_FORMAT_LUMINANCE_FLOAT16;
-   case GL_LUMINANCE32F_ARB:
-  return MESA_FORMAT_LUMINANCE_FLOAT32;
-   case GL_LUMINANCE8I_EXT:
-  return MESA_FORMAT_LUMINANCE_INT8;
-   case GL_LUMINANCE16I_EXT:
-  return MESA_FORMAT_LUMINANCE_INT16;
-   case GL_LUMINANCE32I_EXT:
-  return 

[Mesa-dev] [PATCH V3 07/10] mesa: Implement functions for clear_buffer_object extensions

2013-12-14 Thread Pi Tabred
---
 src/mesa/main/bufferobj.c | 271 ++
 src/mesa/main/bufferobj.h |   4 +
 2 files changed, 275 insertions(+)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 820cbcb..21f0ae1 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -41,6 +41,9 @@
 #include "fbobject.h"
 #include "mtypes.h"
 #include "texobj.h"
+#include "teximage.h"
+#include "glformats.h"
+#include "texstore.h"
 #include "transformfeedback.h"
 #include "dispatch.h"
 
@@ -283,6 +286,100 @@ buffer_object_subdata_range_good(struct gl_context * ctx, 
GLenum target,
 
 
 /**
+ * Test the format and type parameters and set the GL error code for
+ * \c glClearBufferData and \c glClearBufferSubData.
+ *
+ * \param ctx GL context.
+ * \param internalformat  Format to which the data is to be converted.
+ * \param format  Format of the supplied data.
+ * \param typeType of the supplied data.
+ * \param caller  Name of calling function for recording errors.
+ * \return   If internalformat, format and type are legal the gl_format
+ *   corresponding to internalformat, otherwise MESA_FORMAT_NONE.
+ *
+ * \sa glClearBufferData and glClearBufferSubData
+ */
+static gl_format
+validate_clear_buffer_format(struct gl_context *ctx,
+ GLenum internalformat,
+ GLenum format, GLenum type,
+ const char *caller)
+{
+   gl_format mesaFormat;
+   GLenum errorFormatType;
+
+   mesaFormat = _mesa_validate_texbuffer_format(ctx, internalformat);
+   if (mesaFormat == MESA_FORMAT_NONE) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "%s(invalid internalformat)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   /* NOTE: not mentioned in ARB_clear_buffer_object but according to
+* EXT_texture_integer there is no conversion between integer and
+* non-integer formats
+   */
+   if (_mesa_is_enum_format_signed_int(format) !=
+   _mesa_is_format_integer_color(mesaFormat)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "%s(integer vs non-integer)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   if (!_mesa_is_color_format(format)) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "%s(format is not a color format)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   errorFormatType = _mesa_error_check_format_and_type(ctx, format,
+   type);
+   if (errorFormatType != GL_NO_ERROR) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "%s(invalid format or type)", caller);
+  return MESA_FORMAT_NONE;
+   }
+
+   return mesaFormat;
+}
+
+
+/**
+ * Convert user-specified clear value to the specified internal format.
+ *
+ * \param ctx GL context.
+ * \param internalformat  Format to which the data is converted.
+ * \param clearValue  Pointer, store converted data here.
+ * \param format  Format of the supplied data.
+ * \param typeType of the supplied data.
+ * \param dataData which is to be converted to internalformat.
+ * \param caller  Name of calling function for recording errors.
+ * \return   true if data could be converted, false otherwise.
+ *
+ * \sa glClearBufferData, glClearBufferSubData
+ */
+static bool
+convert_clear_buffer_data(struct gl_context *ctx,
+  gl_format internalformat,
+  GLubyte *clearValue, GLenum format, GLenum type,
+  const GLvoid *data, const char *caller)
+{
+   GLenum internalformatBase = _mesa_get_format_base_format(internalformat);
+
+   if (_mesa_texstore(ctx, 1, internalformatBase, internalformat,
+  0, &clearValue, 1, 1, 1,
+  format, type, data, &ctx->Unpack)) {
+  return true;
+   }
+   else {
+  _mesa_error(ctx, GL_OUT_OF_MEMORY,
+  "%s", caller);
+  return false;
+   }
+}
+
+
+/**
  * Allocate and initialize a new buffer object.
  * 
  * Default callback for the \c dd_function_table::NewBufferObject() hook.
@@ -547,6 +644,75 @@ _mesa_buffer_get_subdata( struct gl_context *ctx, 
GLintptrARB offset,
 
 
 /**
+ * Clear a subrange of the buffer object with copies of the supplied data.
+ * If data is NULL the buffer is filled with zeros.
+ *
+ * This is the default callback for \c dd_function_table::ClearBufferSubData()
+ * Note that all GL error checking will have been done already.
+ *
+ * \param ctx GL context.
+ * \param offset  Offset of the first byte to be cleared.
+ * \param sizeSize, in bytes, of the to be cleared range.
+ * \param clearValue  Source of the data.
+ * \param clearValueSize  Size, in bytes, of the supplied data.
+ * \param bufObj  Object to be cleared.
+ *
+ * \sa glClearBufferSubData, glClearBufferData and
+ * dd_function_table::ClearBuff

[Mesa-dev] [PATCH V3 08/10] Add ARB_clear_buffer_object to list of supported extensions

2013-12-14 Thread Pi Tabred
---
 src/mesa/main/extensions.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index cc85f78..2404d38 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -82,6 +82,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_ES3_compatibility",   o(ARB_ES3_compatibility),   
GL, 2012 },
{ "GL_ARB_base_instance",   o(ARB_base_instance),   
GL, 2011 },
{ "GL_ARB_blend_func_extended", o(ARB_blend_func_extended), 
GL, 2009 },
+   { "GL_ARB_clear_buffer_object", o(dummy_true),  
GL, 2012 },
{ "GL_ARB_color_buffer_float",  o(ARB_color_buffer_float),  
GL, 2004 },
{ "GL_ARB_copy_buffer", o(dummy_true),  
GL, 2008 },
{ "GL_ARB_conservative_depth",  o(ARB_conservative_depth),  
GL, 2011 },
-- 
1.8.3.1

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


[Mesa-dev] [PATCH V3 05/10] mesa: Add bufferobj_range_mapped function

2013-12-14 Thread Pi Tabred
Add function to test if the buffer is already mapped and if so,
if the mapped range overlaps the given range.
Modify the _mesa_InvalidateBufferSubData function to use
the new function.

Enable buffer_object_subdata_range_good() to use bufferobj_range_mapped
---
 src/mesa/main/bufferobj.c | 91 ++-
 1 file changed, 59 insertions(+), 32 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 8b5ebc4..8f0dc8c 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -186,25 +186,56 @@ simplified_access_mode(struct gl_context *ctx, GLbitfield 
access)
 
 
 /**
+ * Test if the buffer is mapped, and if so, if the mapped range overlaps the
+ * given range.
+ * The regions do not overlap if and only if the end of the given
+ * region is before the mapped region or the start of the given region
+ * is after the mapped region.
+ *
+ * \param obj Buffer object target on which to operate.
+ * \param offset  Offset of the first byte of the subdata range.
+ * \param sizeSize, in bytes, of the subdata range.
+ * \return   true if ranges overlap, false otherwise
+ *
+ */
+static bool
+bufferobj_range_mapped(const struct gl_buffer_object *obj,
+   GLintptr offset, GLsizeiptr size)
+{
+   if (_mesa_bufferobj_mapped(obj)) {
+  const GLintptr end = offset + size;
+  const GLintptr mapEnd = obj->Offset + obj->Length;
+
+  if (!(end <= obj->Offset || offset >= mapEnd)) {
+ return true;
+  }
+   }
+   return false;
+}
+
+
+/**
  * Tests the subdata range parameters and sets the GL error code for
- * \c glBufferSubDataARB and \c glGetBufferSubDataARB.
+ * \c glBufferSubDataARB, \c glGetBufferSubDataARB and
+ * \c glClearBufferSubData.
  *
  * \param ctx GL context.
  * \param target  Buffer object target on which to operate.
  * \param offset  Offset of the first byte of the subdata range.
  * \param sizeSize, in bytes, of the subdata range.
+ * \param mappedRange  If true, checks if an overlapping range is mapped.
+ * If false, checks if buffer is mapped.
  * \param caller  Name of calling function for recording errors.
  * \return   A pointer to the buffer object bound to \c target in the
  *   specified context or \c NULL if any of the parameter or state
- *   conditions for \c glBufferSubDataARB or \c glGetBufferSubDataARB
- *   are invalid.
+ *   conditions are invalid.
  *
- * \sa glBufferSubDataARB, glGetBufferSubDataARB
+ * \sa glBufferSubDataARB, glGetBufferSubDataARB, glClearBufferSubData
  */
 static struct gl_buffer_object *
-buffer_object_subdata_range_good( struct gl_context * ctx, GLenum target, 
-  GLintptrARB offset, GLsizeiptrARB size,
-  const char *caller )
+buffer_object_subdata_range_good(struct gl_context * ctx, GLenum target,
+ GLintptrARB offset, GLsizeiptrARB size,
+ bool mappedRange, const char *caller)
 {
struct gl_buffer_object *bufObj;
 
@@ -224,16 +255,24 @@ buffer_object_subdata_range_good( struct gl_context * 
ctx, GLenum target,
 
if (offset + size > bufObj->Size) {
   _mesa_error(ctx, GL_INVALID_VALUE,
- "%s(offset %lu + size %lu > buffer size %lu)", caller,
+  "%s(offset %lu + size %lu > buffer size %lu)", caller,
   (unsigned long) offset,
   (unsigned long) size,
   (unsigned long) bufObj->Size);
   return NULL;
}
-   if (_mesa_bufferobj_mapped(bufObj)) {
-  /* Buffer is currently mapped */
-  _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);
-  return NULL;
+
+   if (mappedRange) {
+  if (bufferobj_range_mapped(bufObj, offset, size)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);
+ return NULL;
+  }
+   }
+   else {
+  if (_mesa_bufferobj_mapped(bufObj)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);
+ return NULL;
+  }
}
 
return bufObj;
@@ -1103,7 +1142,7 @@ _mesa_BufferSubData(GLenum target, GLintptrARB offset,
struct gl_buffer_object *bufObj;
 
bufObj = buffer_object_subdata_range_good( ctx, target, offset, size,
-  "glBufferSubDataARB" );
+  false, "glBufferSubDataARB");
if (!bufObj) {
   /* error already recorded */
   return;
@@ -1126,8 +1165,8 @@ _mesa_GetBufferSubData(GLenum target, GLintptrARB offset,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
 
-   bufObj = buffer_object_subdata_range_good( ctx, target, offset, size,
-  "glGetBufferSubDataARB" );
+   bufObj = buffer_object_subdata_range_good(ctx, target, offset, size,
+ false, "glGetBufferSubDataARB")

[Mesa-dev] [PATCH V3 09/10] Modify release notes to include ARB_clear_buffer_object extension

2013-12-14 Thread Pi Tabred
---
 docs/relnotes/10.1.html | 1 +
 1 file changed, 1 insertion(+)

diff --git a/docs/relnotes/10.1.html b/docs/relnotes/10.1.html
index dfb0969..778ae6a 100644
--- a/docs/relnotes/10.1.html
+++ b/docs/relnotes/10.1.html
@@ -45,6 +45,7 @@ Note: some of the new features are only available with 
certain drivers.
 
 
 GL_ARB_draw_indirect on i965.
+GL_ARB_clear_buffer_object
 
 
 
-- 
1.8.3.1

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


[Mesa-dev] [PATCH V3 01/10] mesa: Add infrastructure for GL_ARB_clear_buffer_object

2013-12-14 Thread Pi Tabred
 - add xml file for extension
 - add reference in gl_API.xml
 - add pointer to device driver function table (dd.h)
 - update dispatch_sanity.cpp
---
 src/mapi/glapi/gen/ARB_clear_buffer_object.xml | 50 ++
 src/mapi/glapi/gen/gl_API.xml  |  6 +++-
 src/mesa/main/dd.h |  6 
 src/mesa/main/tests/dispatch_sanity.cpp|  4 +--
 4 files changed, 63 insertions(+), 3 deletions(-)
 create mode 100644 src/mapi/glapi/gen/ARB_clear_buffer_object.xml

diff --git a/src/mapi/glapi/gen/ARB_clear_buffer_object.xml 
b/src/mapi/glapi/gen/ARB_clear_buffer_object.xml
new file mode 100644
index 000..cb97a01
--- /dev/null
+++ b/src/mapi/glapi/gen/ARB_clear_buffer_object.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 778f3aa..697b2ec 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -8460,10 +8460,14 @@
 
 
 
+
 
-
+http://www.w3.org/2001/XInclude"/>
+
+
 
 http://www.w3.org/2001/XInclude"/>
+
 http://www.w3.org/2001/XInclude"/>
 
 
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 3e263f4..6e73691 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -574,6 +574,12 @@ struct dd_function_table {
 GLintptrARB offset, GLsizeiptrARB size,
 GLvoid *data, struct gl_buffer_object *obj );
 
+   void (*ClearBufferSubData)( struct gl_context *ctx,
+   GLintptr offset, GLsizeiptr size,
+   const GLvoid *clearValue,
+   GLsizeiptr clearValueSize,
+   struct gl_buffer_object *obj );
+
void (*CopyBufferSubData)( struct gl_context *ctx,
   struct gl_buffer_object *src,
   struct gl_buffer_object *dst,
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index 2f4539a..227a4fd 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -846,8 +846,8 @@ const struct function gl_core_functions_possible[] = {
 // { "glGetObjectLabel", 43, -1 },  // XXX: Add to xml
 // { "glObjectPtrLabel", 43, -1 },  // XXX: Add to xml
 // { "glGetObjectPtrLabel", 43, -1 },   // XXX: Add to xml
-// { "glClearBufferData", 43, -1 }, // XXX: Add to xml
-// { "glClearBufferSubData", 43, -1 },  // XXX: Add to xml
+   { "glClearBufferData", 43, -1 },
+   { "glClearBufferSubData", 43, -1 },
 // { "glClearNamedBufferDataEXT", 43, -1 }, // XXX: Add to xml
 // { "glClearNamedBufferSubDataEXT", 43, -1 },  // XXX: Add to xml
 // { "glDispatchCompute", 43, -1 }, // XXX: Add to xml
-- 
1.8.3.1

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


[Mesa-dev] [PATCH V3 03/10] mesa: Modify format validation to check for extension not context version

2013-12-14 Thread Pi Tabred
---
 src/mesa/main/teximage.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 0d436b2..f92dc1a 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -4054,15 +4054,10 @@ _mesa_validate_texbuffer_format(const struct gl_context 
*ctx,
if (datatype == GL_HALF_FLOAT && !ctx->Extensions.ARB_half_float_pixel)
   return MESA_FORMAT_NONE;
 
-   /* The GL_ARB_texture_rg and GL_ARB_texture_buffer_object specs don't make
-* any mention of R/RG formats, but they appear in the GL 3.1 core
-* specification.
-*/
-   if (ctx->Version <= 30) {
+   if (!ctx->Extensions.ARB_texture_rg) {
   GLenum base_format = _mesa_get_format_base_format(format);
-
   if (base_format == GL_R || base_format == GL_RG)
-return MESA_FORMAT_NONE;
+ return MESA_FORMAT_NONE;
}
 
if (!ctx->Extensions.ARB_texture_buffer_object_rgb32) {
-- 
1.8.3.1

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


[Mesa-dev] [PATCH V3 10/10] mesa: Cleanup mesa/main/bufferobj.h (column wrapping and space between lines)

2013-12-14 Thread Pi Tabred
---
 src/mesa/main/bufferobj.h | 59 ---
 1 file changed, 45 insertions(+), 14 deletions(-)

diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index b38519f..71988b0 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -57,10 +57,10 @@ _mesa_is_bufferobj(const struct gl_buffer_object *obj)
 
 
 extern void
-_mesa_init_buffer_objects( struct gl_context *ctx );
+_mesa_init_buffer_objects(struct gl_context *ctx);
 
 extern void
-_mesa_free_buffer_objects( struct gl_context *ctx );
+_mesa_free_buffer_objects(struct gl_context *ctx);
 
 extern bool
 _mesa_handle_bind_buffer_gen(struct gl_context *ctx,
@@ -77,9 +77,9 @@ extern struct gl_buffer_object *
 _mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer);
 
 extern void
-_mesa_initialize_buffer_object( struct gl_context *ctx,
-   struct gl_buffer_object *obj,
-   GLuint name, GLenum target );
+_mesa_initialize_buffer_object(struct gl_context *ctx,
+   struct gl_buffer_object *obj,
+   GLuint name, GLenum target);
 
 extern void
 _mesa_reference_buffer_object_(struct gl_context *ctx,
@@ -105,59 +105,90 @@ _mesa_init_buffer_object_functions(struct 
dd_function_table *driver);
 /*
  * API functions
  */
-
 void GLAPIENTRY
 _mesa_BindBuffer(GLenum target, GLuint buffer);
+
 void GLAPIENTRY
 _mesa_DeleteBuffers(GLsizei n, const GLuint * buffer);
+
 void GLAPIENTRY
 _mesa_GenBuffers(GLsizei n, GLuint * buffer);
+
 GLboolean GLAPIENTRY
 _mesa_IsBuffer(GLuint buffer);
+
 void GLAPIENTRY
-_mesa_BufferData(GLenum target, GLsizeiptrARB size, const GLvoid * data, 
GLenum usage);
+_mesa_BufferData(GLenum target, GLsizeiptrARB size,
+ const GLvoid * data, GLenum usage);
+
 void GLAPIENTRY
-_mesa_BufferSubData(GLenum target, GLintptrARB offset, GLsizeiptrARB size, 
const GLvoid * data);
+_mesa_BufferSubData(GLenum target, GLintptrARB offset,
+GLsizeiptrARB size, const GLvoid * data);
+
 void GLAPIENTRY
-_mesa_GetBufferSubData(GLenum target, GLintptrARB offset, GLsizeiptrARB size, 
void * data);
+_mesa_GetBufferSubData(GLenum target, GLintptrARB offset,
+   GLsizeiptrARB size, void * data);
+
 void GLAPIENTRY
-_mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format, 
GLenum type, const GLvoid * data);
+_mesa_ClearBufferData(GLenum target, GLenum internalformat,
+  GLenum format, GLenum type,
+  const GLvoid * data);
+
 void GLAPIENTRY
-_mesa_ClearBufferSubData(GLenum target, GLenum internalformat, GLintptr 
offset, GLsizeiptr size, GLenum format, GLenum type, const GLvoid * data);
+_mesa_ClearBufferSubData(GLenum target, GLenum internalformat,
+ GLintptr offset, GLsizeiptr size,
+ GLenum format, GLenum type,
+ const GLvoid * data);
+
 void * GLAPIENTRY
 _mesa_MapBuffer(GLenum target, GLenum access);
+
 GLboolean GLAPIENTRY
 _mesa_UnmapBuffer(GLenum target);
+
 void GLAPIENTRY
 _mesa_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params);
+
 void GLAPIENTRY
 _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params);
+
 void GLAPIENTRY
 _mesa_GetBufferPointerv(GLenum target, GLenum pname, GLvoid **params);
+
 void GLAPIENTRY
 _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
 GLintptr readOffset, GLintptr writeOffset,
 GLsizeiptr size);
+
 void * GLAPIENTRY
 _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
  GLbitfield access);
+
 void GLAPIENTRY
-_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr 
length);
+_mesa_FlushMappedBufferRange(GLenum target,
+ GLintptr offset, GLsizeiptr length);
+
 GLenum GLAPIENTRY
 _mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option);
+
 GLenum GLAPIENTRY
 _mesa_ObjectUnpurgeableAPPLE(GLenum objectType, GLuint name, GLenum option);
+
 void GLAPIENTRY
-_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name, GLenum pname,
-GLint* params);
+_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name,
+GLenum pname, GLint* params);
+
 void GLAPIENTRY
 _mesa_BindBufferRange(GLenum target, GLuint index,
   GLuint buffer, GLintptr offset, GLsizeiptr size);
+
 void GLAPIENTRY
 _mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer);
+
 void GLAPIENTRY
 _mesa_InvalidateBufferSubData(GLuint buffer, GLintptr offset,
   GLsizeiptr length);
+
 void GLAPIENTRY
 _mesa_InvalidateBufferData(GLuint buffer);
 
-- 
1.8.3.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/li

[Mesa-dev] [PATCH V3 06/10] mesa: Modify get_buffer() to allow for a variable error code

2013-12-14 Thread Pi Tabred
---
 src/mesa/main/bufferobj.c | 43 +++
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 8f0dc8c..820cbcb 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -128,7 +128,8 @@ get_buffer_target(struct gl_context *ctx, GLenum target)
  *   specified context or \c NULL if \c target is invalid.
  */
 static inline struct gl_buffer_object *
-get_buffer(struct gl_context *ctx, const char *func, GLenum target)
+get_buffer(struct gl_context *ctx, const char *func, GLenum target,
+   GLenum error)
 {
struct gl_buffer_object **bufObj = get_buffer_target(ctx, target);
 
@@ -138,7 +139,7 @@ get_buffer(struct gl_context *ctx, const char *func, GLenum 
target)
}
 
if (!_mesa_is_bufferobj(*bufObj)) {
-  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(buffer 0)", func);
+  _mesa_error(ctx, error, "%s(no buffer bound)", func);
   return NULL;
}
 
@@ -225,6 +226,7 @@ bufferobj_range_mapped(const struct gl_buffer_object *obj,
  * \param sizeSize, in bytes, of the subdata range.
  * \param mappedRange  If true, checks if an overlapping range is mapped.
  * If false, checks if buffer is mapped.
+ * \param errorNoBuffer  Error code if no buffer is bound to target.
  * \param caller  Name of calling function for recording errors.
  * \return   A pointer to the buffer object bound to \c target in the
  *   specified context or \c NULL if any of the parameter or state
@@ -235,7 +237,8 @@ bufferobj_range_mapped(const struct gl_buffer_object *obj,
 static struct gl_buffer_object *
 buffer_object_subdata_range_good(struct gl_context * ctx, GLenum target,
  GLintptrARB offset, GLsizeiptrARB size,
- bool mappedRange, const char *caller)
+ bool mappedRange, GLenum errorNoBuffer,
+ const char *caller)
 {
struct gl_buffer_object *bufObj;
 
@@ -249,7 +252,7 @@ buffer_object_subdata_range_good(struct gl_context * ctx, 
GLenum target,
   return NULL;
}
 
-   bufObj = get_buffer(ctx, caller, target);
+   bufObj = get_buffer(ctx, caller, target, errorNoBuffer);
if (!bufObj)
   return NULL;
 
@@ -1103,7 +1106,7 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size,
   return;
}
 
-   bufObj = get_buffer(ctx, "glBufferDataARB", target);
+   bufObj = get_buffer(ctx, "glBufferDataARB", target, GL_INVALID_OPERATION);
if (!bufObj)
   return;
 
@@ -1142,7 +1145,8 @@ _mesa_BufferSubData(GLenum target, GLintptrARB offset,
struct gl_buffer_object *bufObj;
 
bufObj = buffer_object_subdata_range_good( ctx, target, offset, size,
-  false, "glBufferSubDataARB");
+  false, GL_INVALID_OPERATION,
+  "glBufferSubDataARB" );
if (!bufObj) {
   /* error already recorded */
   return;
@@ -1166,7 +1170,8 @@ _mesa_GetBufferSubData(GLenum target, GLintptrARB offset,
struct gl_buffer_object *bufObj;
 
bufObj = buffer_object_subdata_range_good(ctx, target, offset, size,
- false, "glGetBufferSubDataARB");
+ false, GL_INVALID_OPERATION,
+ "glGetBufferSubDataARB");
if (!bufObj) {
   /* error already recorded */
   return;
@@ -1211,7 +1216,7 @@ _mesa_MapBuffer(GLenum target, GLenum access)
   return NULL;
}
 
-   bufObj = get_buffer(ctx, "glMapBufferARB", target);
+   bufObj = get_buffer(ctx, "glMapBufferARB", target, GL_INVALID_OPERATION);
if (!bufObj)
   return NULL;
 
@@ -1280,7 +1285,7 @@ _mesa_UnmapBuffer(GLenum target)
GLboolean status = GL_TRUE;
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
 
-   bufObj = get_buffer(ctx, "glUnmapBufferARB", target);
+   bufObj = get_buffer(ctx, "glUnmapBufferARB", target, GL_INVALID_OPERATION);
if (!bufObj)
   return GL_FALSE;
 
@@ -1341,7 +1346,8 @@ _mesa_GetBufferParameteriv(GLenum target, GLenum pname, 
GLint *params)
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
 
-   bufObj = get_buffer(ctx, "glGetBufferParameterivARB", target);
+   bufObj = get_buffer(ctx, "glGetBufferParameterivARB", target,
+   GL_INVALID_OPERATION);
if (!bufObj)
   return;
 
@@ -1394,7 +1400,8 @@ _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, 
GLint64 *params)
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
 
-   bufObj = get_buffer(ctx, "glGetBufferParameteri64v", target);
+   bufObj = get_buffer(ctx, "glGetBufferParameteri64v", target,
+   GL_INVALID_OPERATION);
if (!bufObj)
   return;
 
@@ -1447,7 +1454,8 @@ _mesa_GetBufferPointerv(GLenum target, G

[Mesa-dev] [PATCH V3 02/10] mesa: Make validate_texbuffer_format function available externally

2013-12-14 Thread Pi Tabred
 - change storage class from static to extern
 - rename validate_texbuffer_format to _mesa_validate_texbuffer_format
---
 src/mesa/main/teximage.c | 7 ---
 src/mesa/main/teximage.h | 4 
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index f9427dc..0d436b2 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -4037,8 +4037,9 @@ get_texbuffer_format(const struct gl_context *ctx, GLenum 
internalFormat)
 }
 
 
-static gl_format
-validate_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat)
+gl_format
+_mesa_validate_texbuffer_format(const struct gl_context *ctx,
+GLenum internalFormat)
 {
gl_format format = get_texbuffer_format(ctx, internalFormat);
GLenum datatype;
@@ -4088,7 +4089,7 @@ texbufferrange(struct gl_context *ctx, GLenum target, 
GLenum internalFormat,
   return;
}
 
-   format = validate_texbuffer_format(ctx, internalFormat);
+   format = _mesa_validate_texbuffer_format(ctx, internalFormat);
if (format == MESA_FORMAT_NONE) {
   _mesa_error(ctx, GL_INVALID_ENUM, "glTexBuffer(internalFormat 0x%x)",
   internalFormat);
diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
index 792383d..0b57863 100644
--- a/src/mesa/main/teximage.h
+++ b/src/mesa/main/teximage.h
@@ -147,6 +147,10 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, 
GLenum target,
GLint level, GLint width, GLint height,
GLint depth, GLint border);
 
+extern gl_format
+_mesa_validate_texbuffer_format(const struct gl_context *ctx,
+GLenum internalFormat);
+
 /**
  * Lock a texture for updating.  See also _mesa_lock_context_textures().
  */
-- 
1.8.3.1

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