main: Add entry point for CopyNamedBufferSubData.
authorLaura Ekstrand <laura@jlekstrand.net>
Tue, 13 Jan 2015 21:28:08 +0000 (13:28 -0800)
committerLaura Ekstrand <laura@jlekstrand.net>
Tue, 17 Mar 2015 17:18:33 +0000 (10:18 -0700)
v2: remove _mesa in front of static software fallback.

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 6d70b8e3f5385362e1af955e2555996b37005065..042b2a883c96770ebd59c210785dadb91e033196 100644 (file)
       <param name="data" type="const GLvoid *" />
    </function>
 
+   <function name="CopyNamedBufferSubData" offset="assign">
+      <param name="readBuffer" type="GLuint" />
+      <param name="writeBuffer" type="GLuint" />
+      <param name="readOffset" type="GLintptr" />
+      <param name="writeOffset" type="GLintptr" />
+      <param name="size" type="GLsizeiptr" />
+   </function>
+
    <!-- Texture object functions -->
 
    <function name="CreateTextures" offset="assign">
index f6bc333c828350e0a98aebdd7d43a7ddfe08e438..24ba45864a2db2ec95683b53ae6750e0a268eefd 100644 (file)
@@ -766,11 +766,11 @@ _mesa_buffer_unmap(struct gl_context *ctx, struct gl_buffer_object *bufObj,
  * Called via glCopyBufferSubData().
  */
 static void
-_mesa_copy_buffer_subdata(struct gl_context *ctx,
-                          struct gl_buffer_object *src,
-                          struct gl_buffer_object *dst,
-                          GLintptr readOffset, GLintptr writeOffset,
-                          GLsizeiptr size)
+copy_buffer_sub_data_fallback(struct gl_context *ctx,
+                              struct gl_buffer_object *src,
+                              struct gl_buffer_object *dst,
+                              GLintptr readOffset, GLintptr writeOffset,
+                              GLsizeiptr size)
 {
    GLubyte *srcPtr, *dstPtr;
 
@@ -1125,7 +1125,7 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver)
    driver->FlushMappedBufferRange = _mesa_buffer_flush_mapped_range;
 
    /* GL_ARB_copy_buffer */
-   driver->CopyBufferSubData = _mesa_copy_buffer_subdata;
+   driver->CopyBufferSubData = copy_buffer_sub_data_fallback;
 }
 
 
@@ -2130,65 +2130,54 @@ _mesa_GetBufferPointerv(GLenum target, GLenum pname, GLvoid **params)
 }
 
 
-void GLAPIENTRY
-_mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
-                        GLintptr readOffset, GLintptr writeOffset,
-                        GLsizeiptr size)
+void
+_mesa_copy_buffer_sub_data(struct gl_context *ctx,
+                           struct gl_buffer_object *src,
+                           struct gl_buffer_object *dst,
+                           GLintptr readOffset, GLintptr writeOffset,
+                           GLsizeiptr size, const char *func)
 {
-   GET_CURRENT_CONTEXT(ctx);
-   struct gl_buffer_object *src, *dst;
-
-   src = get_buffer(ctx, "glCopyBufferSubData", readTarget,
-                    GL_INVALID_OPERATION);
-   if (!src)
-      return;
-
-   dst = get_buffer(ctx, "glCopyBufferSubData", writeTarget,
-                    GL_INVALID_OPERATION);
-   if (!dst)
-      return;
-
    if (_mesa_check_disallowed_mapping(src)) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glCopyBufferSubData(readBuffer is mapped)");
+                  "%s(readBuffer is mapped)", func);
       return;
    }
 
    if (_mesa_check_disallowed_mapping(dst)) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glCopyBufferSubData(writeBuffer is mapped)");
+                  "%s(writeBuffer is mapped)", func);
       return;
    }
 
    if (readOffset < 0) {
       _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glCopyBufferSubData(readOffset = %d)", (int) readOffset);
+                  "%s(readOffset %d < 0)", func, (int) readOffset);
       return;
    }
 
    if (writeOffset < 0) {
       _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glCopyBufferSubData(writeOffset = %d)", (int) writeOffset);
+                  "%s(writeOffset %d < 0)", func, (int) writeOffset);
       return;
    }
 
    if (size < 0) {
       _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glCopyBufferSubData(writeOffset = %d)", (int) size);
+                  "%s(size %d < 0)", func, (int) size);
       return;
    }
 
    if (readOffset + size > src->Size) {
       _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glCopyBufferSubData(readOffset + size = %d)",
-                  (int) (readOffset + size));
+                  "%s(readOffset %d + size %d > src_buffer_size %d)", func,
+                  (int) readOffset, (int) size, (int) src->Size);
       return;
    }
 
    if (writeOffset + size > dst->Size) {
       _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glCopyBufferSubData(writeOffset + size = %d)",
-                  (int) (writeOffset + size));
+                  "%s(writeOffset %d + size %d > dst_buffer_size %d)", func,
+                  (int) writeOffset, (int) size, (int) dst->Size);
       return;
    }
 
@@ -2202,7 +2191,7 @@ _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
       else {
          /* overlapping src/dst is illegal */
          _mesa_error(ctx, GL_INVALID_VALUE,
-                     "glCopyBufferSubData(overlapping src/dst)");
+                     "%s(overlapping src/dst)", func);
          return;
       }
    }
@@ -2210,6 +2199,50 @@ _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
    ctx->Driver.CopyBufferSubData(ctx, src, dst, readOffset, writeOffset, size);
 }
 
+void GLAPIENTRY
+_mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
+                        GLintptr readOffset, GLintptr writeOffset,
+                        GLsizeiptr size)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *src, *dst;
+
+   src = get_buffer(ctx, "glCopyBufferSubData", readTarget,
+                    GL_INVALID_OPERATION);
+   if (!src)
+      return;
+
+   dst = get_buffer(ctx, "glCopyBufferSubData", writeTarget,
+                    GL_INVALID_OPERATION);
+   if (!dst)
+      return;
+
+   _mesa_copy_buffer_sub_data(ctx, src, dst, readOffset, writeOffset, size,
+                              "glCopyBufferSubData");
+}
+
+void GLAPIENTRY
+_mesa_CopyNamedBufferSubData(GLuint readBuffer, GLuint writeBuffer,
+                             GLintptr readOffset, GLintptr writeOffset,
+                             GLsizeiptr size)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *src, *dst;
+
+   src = _mesa_lookup_bufferobj_err(ctx, readBuffer,
+                                    "glCopyNamedBufferSubData");
+   if (!src)
+      return;
+
+   dst = _mesa_lookup_bufferobj_err(ctx, writeBuffer,
+                                    "glCopyNamedBufferSubData");
+   if (!dst)
+      return;
+
+   _mesa_copy_buffer_sub_data(ctx, src, dst, readOffset, writeOffset, size,
+                              "glCopyNamedBufferSubData");
+}
+
 
 /**
  * See GL_ARB_map_buffer_range spec
index d15ad004e589d5c6bb6a2c42d74411f1c7f56f54..7db5c98061149ea8e612e1d6ddc8562361fe3900 100644 (file)
@@ -148,6 +148,13 @@ extern void
 _mesa_buffer_unmap_all_mappings(struct gl_context *ctx,
                                 struct gl_buffer_object *bufObj);
 
+extern void
+_mesa_copy_buffer_sub_data(struct gl_context *ctx,
+                           struct gl_buffer_object *src,
+                           struct gl_buffer_object *dst,
+                           GLintptr readOffset, GLintptr writeOffset,
+                           GLsizeiptr size, const char *func);
+
 extern void
 _mesa_buffer_clear_subdata(struct gl_context *ctx,
                            GLintptr offset, GLsizeiptr size,
@@ -232,6 +239,11 @@ _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
                         GLintptr readOffset, GLintptr writeOffset,
                         GLsizeiptr size);
 
+void GLAPIENTRY
+_mesa_CopyNamedBufferSubData(GLuint readBuffer, GLuint writeBuffer,
+                             GLintptr readOffset, GLintptr writeOffset,
+                             GLsizeiptr size);
+
 void * GLAPIENTRY
 _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
                      GLbitfield access);
index 9597e0649fd6b1b952695df10680ddf9cd460439..63b9dcfa385bc7c964df3e4c4bd4acce4b90287a 100644 (file)
@@ -957,6 +957,7 @@ const struct function gl_core_functions_possible[] = {
    { "glNamedBufferStorage", 45, -1 },
    { "glNamedBufferData", 45, -1 },
    { "glNamedBufferSubData", 45, -1 },
+   { "glCopyNamedBufferSubData", 45, -1 },
    { "glCreateTextures", 45, -1 },
    { "glTextureStorage1D", 45, -1 },
    { "glTextureStorage2D", 45, -1 },