[Mesa-dev] [PATCH 17/21] main: Add entry point for FlushMappedNamedBufferRange.
Laura Ekstrand
laura at jlekstrand.net
Wed Jan 21 17:40:30 PST 2015
---
src/mapi/glapi/gen/ARB_direct_state_access.xml | 6 ++
src/mesa/main/bufferobj.c | 76 +++++++++++++++++---------
src/mesa/main/bufferobj.h | 10 ++++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
4 files changed, 67 insertions(+), 26 deletions(-)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index f2b17c8..1e6b9c4 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -80,6 +80,12 @@
<param name="buffer" type="GLuint" />
</function>
+ <function name="FlushMappedNamedBufferRange" offset="assign">
+ <param name="buffer" type="GLuint" />
+ <param name="offset" type="GLintptr" />
+ <param name="length" type="GLsizeiptr" />
+ </function>
+
<!-- Texture object functions -->
<function name="CreateTextures" offset="assign">
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 087d31e..e446f39 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -718,10 +718,10 @@ _mesa_MapBufferRange_sw(struct gl_context *ctx, GLintptr offset,
* Called via glFlushMappedBufferRange().
*/
static void
-_mesa_buffer_flush_mapped_range( struct gl_context *ctx,
- GLintptr offset, GLsizeiptr length,
- struct gl_buffer_object *obj,
- gl_map_buffer_index index)
+_mesa_FlushMappedBufferRange_sw(struct gl_context *ctx,
+ GLintptr offset, GLsizeiptr length,
+ struct gl_buffer_object *obj,
+ gl_map_buffer_index index)
{
(void) ctx;
(void) offset;
@@ -1113,7 +1113,7 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver)
/* GL_ARB_map_buffer_range */
driver->MapBufferRange = _mesa_MapBufferRange_sw;
- driver->FlushMappedBufferRange = _mesa_buffer_flush_mapped_range;
+ driver->FlushMappedBufferRange = _mesa_FlushMappedBufferRange_sw;
/* GL_ARB_copy_buffer */
driver->CopyBufferSubData = _mesa_CopyBufferSubData_sw;
@@ -2359,57 +2359,49 @@ _mesa_MapNamedBuffer(GLuint buffer, GLenum access)
}
-/**
- * See GL_ARB_map_buffer_range spec
- */
-void GLAPIENTRY
-_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
+void
+_mesa_flush_mapped_buffer_range(struct gl_context *ctx,
+ struct gl_buffer_object *bufObj,
+ GLintptr offset, GLsizeiptr length,
+ const char *func)
{
- GET_CURRENT_CONTEXT(ctx);
- struct gl_buffer_object *bufObj;
-
if (!ctx->Extensions.ARB_map_buffer_range) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glFlushMappedBufferRange(extension not supported)");
+ "%s(ARB_map_buffer_range not supported)", func);
return;
}
if (offset < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glFlushMappedBufferRange(offset = %ld)", (long)offset);
+ "%s(offset %ld < 0)", func, (long) offset);
return;
}
if (length < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glFlushMappedBufferRange(length = %ld)", (long)length);
+ "%s(length %ld < 0)", func, (long) length);
return;
}
- bufObj = get_buffer(ctx, "glFlushMappedBufferRange", target,
- GL_INVALID_OPERATION);
- if (!bufObj)
- return;
-
if (!_mesa_bufferobj_mapped(bufObj, MAP_USER)) {
/* buffer is not mapped */
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glFlushMappedBufferRange(buffer is not mapped)");
+ "%s(buffer is not mapped)", func);
return;
}
if ((bufObj->Mappings[MAP_USER].AccessFlags &
GL_MAP_FLUSH_EXPLICIT_BIT) == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glFlushMappedBufferRange(GL_MAP_FLUSH_EXPLICIT_BIT not set)");
+ "%s(GL_MAP_FLUSH_EXPLICIT_BIT not set)", func);
return;
}
if (offset + length > bufObj->Mappings[MAP_USER].Length) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glFlushMappedBufferRange(offset %ld + length %ld > mapped length %ld)",
- (long)offset, (long)length,
- (long)bufObj->Mappings[MAP_USER].Length);
+ "%s(offset %ld + length %ld > mapped length %ld)", func,
+ (long) offset, (long) length,
+ (long) bufObj->Mappings[MAP_USER].Length);
return;
}
@@ -2420,6 +2412,38 @@ _mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
MAP_USER);
}
+void GLAPIENTRY
+_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset,
+ GLsizeiptr length)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *bufObj;
+
+ bufObj = get_buffer(ctx, "glFlushMappedBufferRange", target,
+ GL_INVALID_OPERATION);
+ if (!bufObj)
+ return;
+
+ _mesa_flush_mapped_buffer_range(ctx, bufObj, offset, length,
+ "glFlushMappedBufferRange");
+}
+
+void GLAPIENTRY
+_mesa_FlushMappedNamedBufferRange(GLuint buffer, GLintptr offset,
+ GLsizeiptr length)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *bufObj;
+
+ bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
+ "glFlushMappedNamedBufferRange");
+ if (!bufObj)
+ return;
+
+ _mesa_flush_mapped_buffer_range(ctx, bufObj, offset, length,
+ "glFlushMappedNamedBufferRange");
+}
+
static GLenum
buffer_object_purgeable(struct gl_context *ctx, GLuint name, GLenum option)
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index 864c4be..764f87a 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -162,6 +162,12 @@ _mesa_map_buffer_range(struct gl_context *ctx,
GLbitfield access, const char *func);
extern void
+_mesa_flush_mapped_buffer_range(struct gl_context *ctx,
+ struct gl_buffer_object *bufObj,
+ GLintptr offset, GLsizeiptr length,
+ const char *func);
+
+extern void
_mesa_ClearBufferSubData_sw(struct gl_context *ctx,
GLintptr offset, GLsizeiptr size,
const GLvoid *clearValue,
@@ -293,6 +299,10 @@ void GLAPIENTRY
_mesa_FlushMappedBufferRange(GLenum target,
GLintptr offset, GLsizeiptr length);
+void GLAPIENTRY
+_mesa_FlushMappedNamedBufferRange(GLuint buffer, GLintptr offset,
+ GLsizeiptr length);
+
GLenum GLAPIENTRY
_mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 05f6d07..ce4dd30 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -965,6 +965,7 @@ const struct function gl_core_functions_possible[] = {
{ "glMapNamedBuffer", 45, -1 },
{ "glMapNamedBufferRange", 45, -1 },
{ "glUnmapNamedBuffer", 45, -1 },
+ { "glFlushMappedNamedBufferRange", 45, -1 },
{ "glCreateTextures", 45, -1 },
{ "glTextureStorage1D", 45, -1 },
{ "glTextureStorage2D", 45, -1 },
--
2.1.0
More information about the mesa-dev
mailing list