[Mesa-dev] [PATCH 04/21] main: Add entry point for NamedBufferStorage.
Laura Ekstrand
laura at jlekstrand.net
Wed Jan 21 17:40:17 PST 2015
---
src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 +++
src/mesa/main/bufferobj.c | 63 +++++++++++++++++++-------
src/mesa/main/bufferobj.h | 9 ++++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
4 files changed, 64 insertions(+), 16 deletions(-)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 6c9d0e8..ff81c21 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -14,6 +14,13 @@
<param name="buffers" type="GLuint *" />
</function>
+ <function name="NamedBufferStorage" offset="assign">
+ <param name="buffer" type="GLuint" />
+ <param name="size" type="GLsizeiptr" />
+ <param name="data" type="const GLvoid *" />
+ <param name="flags" type="GLbitfield" />
+ </function>
+
<!-- Texture object functions -->
<function name="CreateTextures" offset="assign">
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 8653500..0977459 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1386,15 +1386,13 @@ _mesa_IsBuffer(GLuint id)
}
-void GLAPIENTRY
-_mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data,
- GLbitfield flags)
+void
+_mesa_buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj,
+ GLenum target, GLsizeiptr size, const GLvoid *data,
+ GLbitfield flags, const char *func)
{
- GET_CURRENT_CONTEXT(ctx);
- struct gl_buffer_object *bufObj;
-
if (size <= 0) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glBufferStorage(size <= 0)");
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(size <= 0)", func);
return;
}
@@ -1404,27 +1402,25 @@ _mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data,
GL_MAP_COHERENT_BIT |
GL_DYNAMIC_STORAGE_BIT |
GL_CLIENT_STORAGE_BIT)) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glBufferStorage(flags)");
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(invalid flag bits set)", func);
return;
}
if (flags & GL_MAP_PERSISTENT_BIT &&
!(flags & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT))) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glBufferStorage(flags!=READ/WRITE)");
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(PERSISTENT and flags!=READ/WRITE)", func);
return;
}
if (flags & GL_MAP_COHERENT_BIT && !(flags & GL_MAP_PERSISTENT_BIT)) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glBufferStorage(flags!=PERSISTENT)");
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(COHERENT and flags!=PERSISTENT)", func);
return;
}
- bufObj = get_buffer(ctx, "glBufferStorage", target, GL_INVALID_OPERATION);
- if (!bufObj)
- return;
-
if (bufObj->Immutable) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferStorage(immutable)");
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(immutable)", func);
return;
}
@@ -1439,10 +1435,45 @@ _mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data,
ASSERT(ctx->Driver.BufferData);
if (!ctx->Driver.BufferData(ctx, target, size, data, GL_DYNAMIC_DRAW,
flags, bufObj)) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferStorage()");
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s()", func);
}
}
+void GLAPIENTRY
+_mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data,
+ GLbitfield flags)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *bufObj;
+
+ bufObj = get_buffer(ctx, "glBufferStorage", target, GL_INVALID_OPERATION);
+ if (!bufObj)
+ return;
+
+ _mesa_buffer_storage(ctx, bufObj, target, size, data, flags,
+ "glBufferStorage");
+}
+
+void GLAPIENTRY
+_mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data,
+ GLbitfield flags)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *bufObj;
+
+ bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferStorage");
+ if (!bufObj)
+ return;
+
+ /*
+ * In direct state access, buffer objects have an unspecified target since
+ * they are not required to be bound.
+ */
+ _mesa_buffer_storage(ctx, bufObj, GL_NONE, size, data, flags,
+ "glNamedBufferStorage");
+}
+
+
void GLAPIENTRY
_mesa_BufferData(GLenum target, GLsizeiptrARB size,
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index 665d843..0537bd4 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -130,6 +130,11 @@ extern void
_mesa_init_buffer_object_functions(struct dd_function_table *driver);
extern void
+_mesa_buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj,
+ GLenum target, GLsizeiptr size, const GLvoid *data,
+ GLbitfield flags, const char *func);
+
+extern void
_mesa_buffer_unmap_all_mappings(struct gl_context *ctx,
struct gl_buffer_object *bufObj);
@@ -163,6 +168,10 @@ _mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data,
GLbitfield flags);
void GLAPIENTRY
+_mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data,
+ GLbitfield flags);
+
+void GLAPIENTRY
_mesa_BufferData(GLenum target, GLsizeiptrARB size,
const GLvoid * data, GLenum usage);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index af9054a..131d15e 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[] = {
/* GL_ARB_direct_state_access */
{ "glCreateBuffers", 45, -1 },
+ { "glNamedBufferStorage", 45, -1 },
{ "glCreateTextures", 45, -1 },
{ "glTextureStorage1D", 45, -1 },
{ "glTextureStorage2D", 45, -1 },
--
2.1.0
More information about the mesa-dev
mailing list