From f7f5df99542d6492fffd803d77d5f7d2f44d08c9 Mon Sep 17 00:00:00 2001 From: Laura Ekstrand Date: Wed, 14 Jan 2015 14:52:01 -0800 Subject: [PATCH] main: Add entry point for UnmapNamedBuffer. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit v2: review from Ian Romanick - Restore VBO_DEBUG and BOUNDS_CHECK - Remove _mesa from static software fallback unmap_buffer. Reviewed-by: Fredrik Höglund --- .../glapi/gen/ARB_direct_state_access.xml | 5 ++ src/mesa/main/bufferobj.c | 47 ++++++++++++++----- src/mesa/main/bufferobj.h | 7 +++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 557316a27a7..281646d92e8 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -75,6 +75,11 @@ + + + + + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 0d1a69053ec..3b2559fa81f 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -741,15 +741,15 @@ _mesa_buffer_flush_mapped_range( struct gl_context *ctx, /** - * Default callback for \c dd_function_table::MapBuffer(). + * Default callback for \c dd_function_table::UnmapBuffer(). * * The input parameters will have been already tested for errors. * * \sa glUnmapBufferARB, dd_function_table::UnmapBuffer */ static GLboolean -_mesa_buffer_unmap(struct gl_context *ctx, struct gl_buffer_object *bufObj, - gl_map_buffer_index index) +unmap_buffer_fallback(struct gl_context *ctx, struct gl_buffer_object *bufObj, + gl_map_buffer_index index) { (void) ctx; /* XXX we might assert here that bufObj->Pointer is non-null */ @@ -1115,7 +1115,7 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver) driver->BufferData = buffer_data_fallback; driver->BufferSubData = buffer_sub_data_fallback; driver->GetBufferSubData = _mesa_buffer_get_subdata; - driver->UnmapBuffer = _mesa_buffer_unmap; + driver->UnmapBuffer = unmap_buffer_fallback; /* GL_ARB_clear_buffer_object */ driver->ClearBufferSubData = _mesa_ClearBufferSubData_sw; @@ -1828,20 +1828,16 @@ _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat, } -GLboolean GLAPIENTRY -_mesa_UnmapBuffer(GLenum target) +GLboolean +_mesa_unmap_buffer(struct gl_context *ctx, struct gl_buffer_object *bufObj, + const char *func) { - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; GLboolean status = GL_TRUE; ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - bufObj = get_buffer(ctx, "glUnmapBufferARB", target, GL_INVALID_OPERATION); - if (!bufObj) - return GL_FALSE; - if (!_mesa_bufferobj_mapped(bufObj, MAP_USER)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB"); + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(buffer is not mapped)", func); return GL_FALSE; } @@ -1890,6 +1886,31 @@ _mesa_UnmapBuffer(GLenum target) return status; } +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 _mesa_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 _mesa_unmap_buffer(ctx, bufObj, "glUnmapNamedBuffer"); +} void GLAPIENTRY _mesa_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params) diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 6305b5cabed..40bd9fc7dc9 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -177,6 +177,10 @@ _mesa_clear_buffer_sub_data(struct gl_context *ctx, const GLvoid *data, const char *func, bool subdata); +extern GLboolean +_mesa_unmap_buffer(struct gl_context *ctx, struct gl_buffer_object *bufObj, + const char *func); + /* * API functions */ @@ -248,6 +252,9 @@ _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat, GLboolean GLAPIENTRY _mesa_UnmapBuffer(GLenum target); +GLboolean GLAPIENTRY +_mesa_UnmapNamedBuffer(GLuint buffer); + void GLAPIENTRY _mesa_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index bda761ae543..fb077b3d5c5 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -962,6 +962,7 @@ const struct function gl_core_functions_possible[] = { { "glClearNamedBufferSubData", 45, -1 }, { "glMapNamedBuffer", 45, -1 }, { "glMapNamedBufferRange", 45, -1 }, + { "glUnmapNamedBuffer", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, { "glTextureStorage2D", 45, -1 }, -- 2.30.2