[Mesa-dev] [PATCH v2 03/25] mesa: implement sparse storage buffer allocation
Nicolai Hähnle
nhaehnle at gmail.com
Tue Mar 28 09:11:53 UTC 2017
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
v2:
- spec quote and style (Ian)
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
---
src/mesa/main/bufferobj.c | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index cbd9228..a4ccf8c 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1529,30 +1529,47 @@ _mesa_IsBuffer(GLuint id)
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)
{
if (size <= 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(size <= 0)", func);
return;
}
- if (flags & ~(GL_MAP_READ_BIT |
- GL_MAP_WRITE_BIT |
- GL_MAP_PERSISTENT_BIT |
- GL_MAP_COHERENT_BIT |
- GL_DYNAMIC_STORAGE_BIT |
- GL_CLIENT_STORAGE_BIT)) {
+ GLbitfield valid_flags = GL_MAP_READ_BIT |
+ GL_MAP_WRITE_BIT |
+ GL_MAP_PERSISTENT_BIT |
+ GL_MAP_COHERENT_BIT |
+ GL_DYNAMIC_STORAGE_BIT |
+ GL_CLIENT_STORAGE_BIT;
+
+ if (ctx->Extensions.ARB_sparse_buffer)
+ valid_flags |= GL_SPARSE_STORAGE_BIT_ARB;
+
+ if (flags & ~valid_flags) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(invalid flag bits set)", func);
return;
}
+ /* The Errors section of the GL_ARB_sparse_buffer spec says:
+ *
+ * "INVALID_VALUE is generated by BufferStorage if <flags> contains
+ * SPARSE_STORAGE_BIT_ARB and <flags> also contains any combination of
+ * MAP_READ_BIT or MAP_WRITE_BIT."
+ */
+ if (flags & GL_SPARSE_STORAGE_BIT_ARB &&
+ flags & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(SPARSE_STORAGE and READ/WRITE)", func);
+ return;
+ }
+
if (flags & GL_MAP_PERSISTENT_BIT &&
!(flags & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT))) {
_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,
"%s(COHERENT and flags!=PERSISTENT)", func);
--
2.9.3
More information about the mesa-dev
mailing list