aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/bufferobj.c
diff options
context:
space:
mode:
authorLaura Ekstrand <[email protected]>2015-01-13 13:28:08 -0800
committerLaura Ekstrand <[email protected]>2015-03-17 10:18:33 -0700
commit4adaad5fcc7fc959f24f807e783b6be2903e08a3 (patch)
tree0d61b9a5330266ea39791ad0c8b56a52099730ea /src/mesa/main/bufferobj.c
parent9cb732b8e9fad4a603f38ce896cd84300e2743a3 (diff)
main: Add entry point for CopyNamedBufferSubData.
v2: remove _mesa in front of static software fallback. Reviewed-by: Martin Peres <[email protected]>
Diffstat (limited to 'src/mesa/main/bufferobj.c')
-rw-r--r--src/mesa/main/bufferobj.c99
1 files changed, 66 insertions, 33 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index f6bc333c828..24ba45864a2 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -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