main: Add entry point for NamedBufferData.
authorLaura Ekstrand <laura@jlekstrand.net>
Tue, 10 Feb 2015 01:57:46 +0000 (17:57 -0800)
committerLaura Ekstrand <laura@jlekstrand.net>
Tue, 17 Mar 2015 17:18:33 +0000 (10:18 -0700)
v2: review from Ian Romanick
   - Fix space in ARB_direct_state_access.xml.
   - Remove "_mesa" from the name of buffer_data static fallback.
   - Restore VBO_DEBUG and BOUNDS_CHECK.
   - Fix beginning of comment to start on same line as /*

Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
src/mapi/glapi/gen/ARB_direct_state_access.xml
src/mesa/main/bufferobj.c
src/mesa/main/bufferobj.h
src/mesa/main/tests/dispatch_sanity.cpp

index ff81c212812751173a2e97c92b15a04ab13e2175..7779262ea76fb10138bcba36ecb0f79734fd0f11 100644 (file)
       <param name="flags" type="GLbitfield" />
    </function>
 
+   <function name="NamedBufferData" offset="assign">
+      <param name="buffer" type="GLuint" />
+      <param name="size" type="GLsizeiptr" />
+      <param name="data" type="const GLvoid *" />
+      <param name="usage" type="GLenum" />
+   </function>
+
    <!-- Texture object functions -->
 
    <function name="CreateTextures" offset="assign">
index 73d4cb3dcdb31f3090cffb24ac141435db8b15bb..7d90a1f52f158f41719a53a4ebc6083233f0b776 100644 (file)
@@ -561,9 +561,9 @@ _mesa_total_buffer_object_memory(struct gl_context *ctx)
  * \sa glBufferDataARB, dd_function_table::BufferData.
  */
 static GLboolean
-_mesa_buffer_data( struct gl_context *ctx, GLenum target, GLsizeiptrARB size,
-                  const GLvoid * data, GLenum usage, GLenum storageFlags,
-                  struct gl_buffer_object * bufObj )
+buffer_data_fallback(struct gl_context *ctx, GLenum target, GLsizeiptr size,
+                     const GLvoid *data, GLenum usage, GLenum storageFlags,
+                     struct gl_buffer_object *bufObj)
 {
    void * new_data;
 
@@ -1117,7 +1117,7 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver)
    /* GL_ARB_vertex/pixel_buffer_object */
    driver->NewBufferObject = _mesa_new_buffer_object;
    driver->DeleteBuffer = _mesa_delete_buffer_object;
-   driver->BufferData = _mesa_buffer_data;
+   driver->BufferData = buffer_data_fallback;
    driver->BufferSubData = _mesa_buffer_subdata;
    driver->GetBufferSubData = _mesa_buffer_get_subdata;
    driver->UnmapBuffer = _mesa_buffer_unmap;
@@ -1492,23 +1492,22 @@ _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data,
 }
 
 
-
-void GLAPIENTRY
-_mesa_BufferData(GLenum target, GLsizeiptrARB size,
-                    const GLvoid * data, GLenum usage)
+void
+_mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
+                  GLenum target, GLsizeiptr size, const GLvoid *data,
+                  GLenum usage, const char *func)
 {
-   GET_CURRENT_CONTEXT(ctx);
-   struct gl_buffer_object *bufObj;
    bool valid_usage;
 
    if (MESA_VERBOSE & VERBOSE_API)
-      _mesa_debug(ctx, "glBufferData(%s, %ld, %p, %s)\n",
+      _mesa_debug(ctx, "%s(%s, %ld, %p, %s)\n",
+                  func,
                   _mesa_lookup_enum_by_nr(target),
                   (long int) size, data,
                   _mesa_lookup_enum_by_nr(usage));
 
    if (size < 0) {
-      _mesa_error(ctx, GL_INVALID_VALUE, "glBufferDataARB(size < 0)");
+      _mesa_error(ctx, GL_INVALID_VALUE, "%s(size < 0)", func);
       return;
    }
 
@@ -1537,16 +1536,13 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size,
    }
 
    if (!valid_usage) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glBufferData(usage)");
+      _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid usage: %s)", func,
+                  _mesa_lookup_enum_by_nr(usage));
       return;
    }
 
-   bufObj = get_buffer(ctx, "glBufferDataARB", target, GL_INVALID_OPERATION);
-   if (!bufObj)
-      return;
-
    if (bufObj->Immutable) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferData(immutable)");
+      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(immutable)", func);
       return;
    }
 
@@ -1579,14 +1575,47 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size,
           *   EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, and the store cannot be
           *   mapped to the GPU address space.
           */
-         _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferData()");
+         _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func);
       }
       else {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferData()");
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
       }
    }
 }
 
+void GLAPIENTRY
+_mesa_BufferData(GLenum target, GLsizeiptr size,
+                 const GLvoid *data, GLenum usage)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+
+   bufObj = get_buffer(ctx, "glBufferData", target, GL_INVALID_OPERATION);
+   if (!bufObj)
+      return;
+
+   _mesa_buffer_data(ctx, bufObj, target, size, data, usage,
+                     "glBufferData");
+}
+
+void GLAPIENTRY
+_mesa_NamedBufferData(GLuint buffer, GLsizeiptr size, const GLvoid *data,
+                      GLenum usage)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+
+   bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferData");
+   if (!bufObj)
+      return;
+
+   /* In direct state access, buffer objects have an unspecified target since
+    * they are not required to be bound.
+    */
+   _mesa_buffer_data(ctx, bufObj, GL_NONE, size, data, usage,
+                     "glNamedBufferData");
+}
+
 
 void GLAPIENTRY
 _mesa_BufferSubData(GLenum target, GLintptrARB offset,
index 3c337aa1f24e92d3f6a20b37ce8f7dfd36a496df..ddd240cbd97336f54b3faccad30c9c531c2c556c 100644 (file)
@@ -134,6 +134,11 @@ _mesa_buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj,
                      GLenum target, GLsizeiptr size, const GLvoid *data,
                      GLbitfield flags, const char *func);
 
+extern void
+_mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
+                  GLenum target, GLsizeiptr size, const GLvoid *data,
+                  GLenum usage, const char *func);
+
 extern void
 _mesa_buffer_unmap_all_mappings(struct gl_context *ctx,
                                 struct gl_buffer_object *bufObj);
@@ -172,8 +177,12 @@ _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data,
                          GLbitfield flags);
 
 void GLAPIENTRY
-_mesa_BufferData(GLenum target, GLsizeiptrARB size,
-                 const GLvoid * data, GLenum usage);
+_mesa_BufferData(GLenum target, GLsizeiptr size,
+                 const GLvoid *data, GLenum usage);
+
+void GLAPIENTRY
+_mesa_NamedBufferData(GLuint buffer, GLsizeiptr size,
+                      const GLvoid *data, GLenum usage);
 
 void GLAPIENTRY
 _mesa_BufferSubData(GLenum target, GLintptrARB offset,
index bc920d4e0e08aaa9df7296f85a9d58a7ef540ad1..5047ca9875e9641fa54c7a04b1050e17263337bc 100644 (file)
@@ -955,6 +955,7 @@ const struct function gl_core_functions_possible[] = {
    /* GL_ARB_direct_state_access */
    { "glCreateBuffers", 45, -1 },
    { "glNamedBufferStorage", 45, -1 },
+   { "glNamedBufferData", 45, -1 },
    { "glCreateTextures", 45, -1 },
    { "glTextureStorage1D", 45, -1 },
    { "glTextureStorage2D", 45, -1 },