summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorLaura Ekstrand <[email protected]>2015-01-13 11:28:17 -0800
committerLaura Ekstrand <[email protected]>2015-03-17 10:18:33 -0700
commit566ccdf11b37363255bf5d20d7ab6639ddaf1b30 (patch)
tree6f202d87db3a4affdacdfaf28bcdfa32d8506b39 /src/mesa/main
parentcb56835f870de01ed9c638d1470af38775bb6f72 (diff)
main: Add entry point for NamedBufferSubData.
v2: review by Ian Romanick - Remove "_mesa" from name of static software fallback buffer_sub_data. - Remove mappedRange from _mesa_buffer_sub_data. - Removed some cosmetic changes to a separate commit. Reviewed-by: Martin Peres <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/bufferobj.c129
-rw-r--r--src/mesa/main/bufferobj.h9
-rw-r--r--src/mesa/main/tests/dispatch_sanity.cpp1
3 files changed, 90 insertions, 49 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 7d90a1f52f1..5153679ea6c 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -232,67 +232,58 @@ bufferobj_range_mapped(const struct gl_buffer_object *obj,
* \c glClearBufferSubData.
*
* \param ctx GL context.
- * \param target Buffer object target on which to operate.
+ * \param bufObj The buffer object.
* \param offset Offset of the first byte of the subdata range.
* \param size Size, in bytes, of the subdata range.
* \param mappedRange If true, checks if an overlapping range is mapped.
* If false, checks if buffer is mapped.
- * \param errorNoBuffer Error code if no buffer is bound to target.
* \param caller Name of calling function for recording errors.
- * \return A pointer to the buffer object bound to \c target in the
- * specified context or \c NULL if any of the parameter or state
- * conditions are invalid.
+ * \return false if error, true otherwise
*
* \sa glBufferSubDataARB, glGetBufferSubDataARB, glClearBufferSubData
*/
-static struct gl_buffer_object *
-buffer_object_subdata_range_good(struct gl_context * ctx, GLenum target,
- GLintptrARB offset, GLsizeiptrARB size,
- bool mappedRange, GLenum errorNoBuffer,
- const char *caller)
+static bool
+buffer_object_subdata_range_good(struct gl_context *ctx,
+ struct gl_buffer_object *bufObj,
+ GLintptr offset, GLsizeiptr size,
+ bool mappedRange, const char *caller)
{
- struct gl_buffer_object *bufObj;
-
if (size < 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(size < 0)", caller);
- return NULL;
+ return false;
}
if (offset < 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(offset < 0)", caller);
- return NULL;
+ return false;
}
- bufObj = get_buffer(ctx, caller, target, errorNoBuffer);
- if (!bufObj)
- return NULL;
-
if (offset + size > bufObj->Size) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(offset %lu + size %lu > buffer size %lu)", caller,
(unsigned long) offset,
(unsigned long) size,
(unsigned long) bufObj->Size);
- return NULL;
+ return false;
}
if (bufObj->Mappings[MAP_USER].AccessFlags & GL_MAP_PERSISTENT_BIT)
- return bufObj;
+ return true;
if (mappedRange) {
if (bufferobj_range_mapped(bufObj, offset, size)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);
- return NULL;
+ return false;
}
}
else {
if (_mesa_bufferobj_mapped(bufObj, MAP_USER)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);
- return NULL;
+ return false;
}
}
- return bufObj;
+ return true;
}
@@ -607,9 +598,9 @@ buffer_data_fallback(struct gl_context *ctx, GLenum target, GLsizeiptr size,
* \sa glBufferSubDataARB, dd_function_table::BufferSubData.
*/
static void
-_mesa_buffer_subdata( struct gl_context *ctx, GLintptrARB offset,
- GLsizeiptrARB size, const GLvoid * data,
- struct gl_buffer_object * bufObj )
+buffer_sub_data_fallback(struct gl_context *ctx, GLintptr offset,
+ GLsizeiptr size, const GLvoid *data,
+ struct gl_buffer_object *bufObj)
{
(void) ctx;
@@ -1118,7 +1109,7 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver)
driver->NewBufferObject = _mesa_new_buffer_object;
driver->DeleteBuffer = _mesa_delete_buffer_object;
driver->BufferData = buffer_data_fallback;
- driver->BufferSubData = _mesa_buffer_subdata;
+ driver->BufferSubData = buffer_sub_data_fallback;
driver->GetBufferSubData = _mesa_buffer_get_subdata;
driver->UnmapBuffer = _mesa_buffer_unmap;
@@ -1617,24 +1608,31 @@ _mesa_NamedBufferData(GLuint buffer, GLsizeiptr size, const GLvoid *data,
}
-void GLAPIENTRY
-_mesa_BufferSubData(GLenum target, GLintptrARB offset,
- GLsizeiptrARB size, const GLvoid * data)
+/**
+ * Implementation for glBufferSubData and glNamedBufferSubData.
+ *
+ * \param ctx GL context.
+ * \param bufObj The buffer object.
+ * \param offset Offset of the first byte of the subdata range.
+ * \param size Size, in bytes, of the subdata range.
+ * \param data The data store.
+ * \param func Name of calling function for recording errors.
+ *
+ */
+void
+_mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
+ GLintptr offset, GLsizeiptr size, const GLvoid *data,
+ const char *func)
{
- GET_CURRENT_CONTEXT(ctx);
- struct gl_buffer_object *bufObj;
-
- bufObj = buffer_object_subdata_range_good( ctx, target, offset, size,
- false, GL_INVALID_OPERATION,
- "glBufferSubDataARB" );
- if (!bufObj) {
+ if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size,
+ false, func)) {
/* error already recorded */
return;
}
if (bufObj->Immutable &&
!(bufObj->StorageFlags & GL_DYNAMIC_STORAGE_BIT)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferSubData");
+ _mesa_error(ctx, GL_INVALID_OPERATION, func);
return;
}
@@ -1647,19 +1645,50 @@ _mesa_BufferSubData(GLenum target, GLintptrARB offset,
ctx->Driver.BufferSubData( ctx, offset, size, data, bufObj );
}
+void GLAPIENTRY
+_mesa_BufferSubData(GLenum target, GLintptr offset,
+ GLsizeiptr size, const GLvoid *data)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *bufObj;
+
+ bufObj = get_buffer(ctx, "glBufferSubData", target, GL_INVALID_OPERATION);
+ if (!bufObj)
+ return;
+
+ _mesa_buffer_sub_data(ctx, bufObj, offset, size, data, "glBufferSubData");
+}
void GLAPIENTRY
-_mesa_GetBufferSubData(GLenum target, GLintptrARB offset,
- GLsizeiptrARB size, void * data)
+_mesa_NamedBufferSubData(GLuint buffer, GLintptr offset,
+ GLsizeiptr size, const GLvoid *data)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
- bufObj = buffer_object_subdata_range_good(ctx, target, offset, size,
- false, GL_INVALID_OPERATION,
- "glGetBufferSubDataARB");
- if (!bufObj) {
- /* error already recorded */
+ bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferSubData");
+ if (!bufObj)
+ return;
+
+ _mesa_buffer_sub_data(ctx, bufObj, offset, size, data,
+ "glNamedBufferSubData");
+}
+
+
+void GLAPIENTRY
+_mesa_GetBufferSubData(GLenum target, GLintptr offset,
+ GLsizeiptr size, GLvoid *data)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *bufObj;
+
+ bufObj = get_buffer(ctx, "glGetBufferSubData", target,
+ GL_INVALID_OPERATION);
+ if (!bufObj)
+ return;
+
+ if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size, false,
+ "glGetBufferSubData")) {
return;
}
@@ -1733,10 +1762,12 @@ _mesa_ClearBufferSubData(GLenum target, GLenum internalformat,
GLubyte clearValue[MAX_PIXEL_BYTES];
GLsizeiptr clearValueSize;
- bufObj = buffer_object_subdata_range_good(ctx, target, offset, size,
- true, GL_INVALID_VALUE,
- "glClearBufferSubData");
- if (!bufObj) {
+ bufObj = get_buffer(ctx, "glClearBufferSubData", target, GL_INVALID_VALUE);
+ if (!bufObj)
+ return;
+
+ if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size,
+ true, "glClearBufferSubData")) {
return;
}
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index ddd240cbd97..889bbb18a20 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -140,6 +140,11 @@ _mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
GLenum usage, const char *func);
extern void
+_mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
+ GLintptr offset, GLsizeiptr size, const GLvoid *data,
+ const char *func);
+
+extern void
_mesa_buffer_unmap_all_mappings(struct gl_context *ctx,
struct gl_buffer_object *bufObj);
@@ -189,6 +194,10 @@ _mesa_BufferSubData(GLenum target, GLintptrARB offset,
GLsizeiptrARB size, const GLvoid * data);
void GLAPIENTRY
+_mesa_NamedBufferSubData(GLuint buffer, GLintptr offset,
+ GLsizeiptr size, const GLvoid *data);
+
+void GLAPIENTRY
_mesa_GetBufferSubData(GLenum target, GLintptrARB offset,
GLsizeiptrARB size, void * data);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 5047ca9875e..9597e0649fd 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -956,6 +956,7 @@ const struct function gl_core_functions_possible[] = {
{ "glCreateBuffers", 45, -1 },
{ "glNamedBufferStorage", 45, -1 },
{ "glNamedBufferData", 45, -1 },
+ { "glNamedBufferSubData", 45, -1 },
{ "glCreateTextures", 45, -1 },
{ "glTextureStorage1D", 45, -1 },
{ "glTextureStorage2D", 45, -1 },