summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/bufferobj.c
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-05-12 16:31:01 +1000
committerTimothy Arceri <[email protected]>2017-05-17 10:12:03 +1000
commit09687c228243cda6d53e75e3d02b679e7dcd0062 (patch)
treefa5f1a94d2ec246a5a5fb756dd5a59af3afc8613 /src/mesa/main/bufferobj.c
parent70d4d1164e4c465cbbf502992076ec408dc5fef0 (diff)
mesa: add inlined_buffer_storage() helper
This will allow us to share code between the dsa, non-dsa and no_error variants. Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa/main/bufferobj.c')
-rw-r--r--src/mesa/main/bufferobj.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 0f93b0fbbe5..4afa2ee6779 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1591,40 +1591,47 @@ buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj,
}
}
-void GLAPIENTRY
-_mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data,
- GLbitfield flags)
+
+static ALWAYS_INLINE void
+inlined_buffer_storage(GLenum target, GLuint buffer, GLsizeiptr size,
+ const GLvoid *data, GLbitfield flags, bool dsa,
+ const char *func)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
- const char *func = "glBufferStorage";
- bufObj = get_buffer(ctx, func, target, GL_INVALID_OPERATION);
- if (!bufObj)
- return;
+ if (dsa) {
+ bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, func);
+ if (!bufObj)
+ return;
+ } else {
+ bufObj = get_buffer(ctx, func, target, GL_INVALID_OPERATION);
+ if (!bufObj)
+ return;
+ }
if (validate_buffer_storage(ctx, bufObj, size, flags, func))
buffer_storage(ctx, bufObj, target, size, data, flags, func);
}
+
+void GLAPIENTRY
+_mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data,
+ GLbitfield flags)
+{
+ inlined_buffer_storage(target, 0, size, data, flags, false,
+ "glBufferStorage");
+}
+
void GLAPIENTRY
_mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data,
GLbitfield flags)
{
- GET_CURRENT_CONTEXT(ctx);
- struct gl_buffer_object *bufObj;
- const char *func = "glNamedBufferStorage";
-
- bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, func);
- if (!bufObj)
- return;
-
- /*
- * In direct state access, buffer objects have an unspecified target since
- * they are not required to be bound.
+ /* In direct state access, buffer objects have an unspecified target
+ * since they are not required to be bound.
*/
- if (validate_buffer_storage(ctx, bufObj, size, flags, func))
- buffer_storage(ctx, bufObj, GL_NONE, size, data, flags, func);
+ inlined_buffer_storage(GL_NONE, buffer, size, data, flags, true,
+ "glNamedBufferStorage");
}