[Mesa-dev] [PATCH 10/23] main: Add entry point for CopyNamedBufferSubData.
Laura Ekstrand
laura at jlekstrand.net
Wed Feb 11 18:05:48 PST 2015
v2: remove _mesa in front of static software fallback.
---
src/mapi/glapi/gen/ARB_direct_state_access.xml | 8 +++
src/mesa/main/bufferobj.c | 99 +++++++++++++++++---------
src/mesa/main/bufferobj.h | 12 ++++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
4 files changed, 87 insertions(+), 33 deletions(-)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 6d70b8e..042b2a8 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -35,6 +35,14 @@
<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">
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index fc01d02..7225b64 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -761,11 +761,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;
@@ -1120,7 +1120,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;
}
@@ -2101,65 +2101,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;
}
@@ -2173,7 +2162,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;
}
}
@@ -2181,6 +2170,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
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index d15ad00..7db5c98 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -149,6 +149,13 @@ _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,
const GLvoid *clearValue,
@@ -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);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 898a2b9..aa8e352 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -959,6 +959,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 },
--
2.1.0
More information about the mesa-dev
mailing list