[Mesa-dev] [PATCH 05/18] mesa: split unmap_buffer() in two
Timothy Arceri
tarceri at itsqueeze.com
Thu May 4 07:41:30 UTC 2017
This will allow us to implement KHR_no_error support for unmap
functions.
---
src/mesa/main/bufferobj.c | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index f6822c7..0fdb623 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1995,26 +1995,37 @@ _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat,
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glClearNamedBufferSubData");
if (!bufObj)
return;
_mesa_clear_buffer_sub_data(ctx, bufObj, internalformat, offset, size,
format, type, data,
"glClearNamedBufferSubData", true);
}
+static GLboolean
+unmap_buffer(struct gl_context *ctx, struct gl_buffer_object *bufObj)
+{
+ GLboolean status = ctx->Driver.UnmapBuffer(ctx, bufObj, MAP_USER);
+ bufObj->Mappings[MAP_USER].AccessFlags = 0;
+ assert(bufObj->Mappings[MAP_USER].Pointer == NULL);
+ assert(bufObj->Mappings[MAP_USER].Offset == 0);
+ assert(bufObj->Mappings[MAP_USER].Length == 0);
+
+ return status;
+}
static GLboolean
-unmap_buffer(struct gl_context *ctx, struct gl_buffer_object *bufObj,
- const char *func)
+validate_and_unmap_buffer(struct gl_context *ctx,
+ struct gl_buffer_object *bufObj,
+ const char *func)
{
- GLboolean status = GL_TRUE;
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
if (!_mesa_bufferobj_mapped(bufObj, MAP_USER)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(buffer is not mapped)", func);
return GL_FALSE;
}
#ifdef BOUNDS_CHECK
if (bufObj->Access != GL_READ_ONLY_ARB) {
@@ -2045,53 +2056,47 @@ unmap_buffer(struct gl_context *ctx, struct gl_buffer_object *bufObj,
pos = i;
}
}
if (unchanged) {
printf("glUnmapBufferARB(%u): %u of %ld unchanged, starting at %d\n",
bufObj->Name, unchanged, bufObj->Size, pos);
}
}
#endif
- status = ctx->Driver.UnmapBuffer(ctx, bufObj, MAP_USER);
- bufObj->Mappings[MAP_USER].AccessFlags = 0;
- assert(bufObj->Mappings[MAP_USER].Pointer == NULL);
- assert(bufObj->Mappings[MAP_USER].Offset == 0);
- assert(bufObj->Mappings[MAP_USER].Length == 0);
-
- return status;
+ return unmap_buffer(ctx, bufObj);
}
GLboolean GLAPIENTRY
_mesa_UnmapBuffer(GLenum target)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
bufObj = get_buffer(ctx, "glUnmapBuffer", target, GL_INVALID_OPERATION);
if (!bufObj)
return GL_FALSE;
- return unmap_buffer(ctx, bufObj, "glUnmapBuffer");
+ return validate_and_unmap_buffer(ctx, bufObj, "glUnmapBuffer");
}
GLboolean GLAPIENTRY
_mesa_UnmapNamedBuffer(GLuint buffer)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glUnmapNamedBuffer");
if (!bufObj)
return GL_FALSE;
- return unmap_buffer(ctx, bufObj, "glUnmapNamedBuffer");
+ return validate_and_unmap_buffer(ctx, bufObj, "glUnmapNamedBuffer");
}
static bool
get_buffer_parameter(struct gl_context *ctx,
struct gl_buffer_object *bufObj, GLenum pname,
GLint64 *params, const char *func)
{
switch (pname) {
case GL_BUFFER_SIZE_ARB:
--
2.9.3
More information about the mesa-dev
mailing list