[Mesa-dev] [PATCH 06/17] mesa: add buffer_sub_data() helper
Timothy Arceri
tarceri at itsqueeze.com
Mon May 15 06:19:15 UTC 2017
This will allow us to share code between the dsa, non-dsa and
no_error variants.
---
src/mesa/main/bufferobj.c | 41 ++++++++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 97e4df9..e53adb3 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1847,50 +1847,57 @@ _mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
return;
bufObj->NumSubDataCalls++;
bufObj->Written = GL_TRUE;
bufObj->MinMaxCacheDirty = true;
assert(ctx->Driver.BufferSubData);
ctx->Driver.BufferSubData(ctx, offset, size, data, bufObj);
}
-void GLAPIENTRY
-_mesa_BufferSubData(GLenum target, GLintptr offset,
- GLsizeiptr size, const GLvoid *data)
+
+static ALWAYS_INLINE void
+buffer_sub_data(GLenum target, GLuint buffer, GLintptr offset,
+ GLsizeiptr size, const GLvoid *data,
+ bool dsa, const char *func)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
- const char *func = "glBufferSubData";
- 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_sub_data(ctx, bufObj, offset, size, func))
_mesa_buffer_sub_data(ctx, bufObj, offset, size, data);
}
+
+void GLAPIENTRY
+_mesa_BufferSubData(GLenum target, GLintptr offset,
+ GLsizeiptr size, const GLvoid *data)
+{
+ buffer_sub_data(target, 0, offset, size, data, false, "glBufferSubData");
+}
+
void GLAPIENTRY
_mesa_NamedBufferSubData(GLuint buffer, GLintptr offset,
GLsizeiptr size, const GLvoid *data)
{
- GET_CURRENT_CONTEXT(ctx);
- struct gl_buffer_object *bufObj;
- const char *func = "glNamedBufferSubData";
-
- bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, func);
- if (!bufObj)
- return;
-
- if (validate_buffer_sub_data(ctx, bufObj, offset, size, func))
- _mesa_buffer_sub_data(ctx, bufObj, offset, size, data);
+ buffer_sub_data(0, buffer, offset, size, data, true,
+ "glNamedBufferSubData");
}
void GLAPIENTRY
_mesa_GetBufferSubData(GLenum target, GLintptr offset,
GLsizeiptr size, GLvoid *data)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
--
2.9.3
More information about the mesa-dev
mailing list