summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/bufferobj.c99
-rw-r--r--src/mesa/main/bufferobj.h12
-rw-r--r--src/mesa/main/tests/dispatch_sanity.cpp1
3 files changed, 79 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
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index d15ad004e58..7db5c980611 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 9597e0649fd..63b9dcfa385 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -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 },