glthread: handle buffer unbinding via glDeleteBuffers
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4124>
This commit is contained in:
@@ -5078,7 +5078,8 @@
|
|||||||
<glx ignore="true"/>
|
<glx ignore="true"/>
|
||||||
</function>
|
</function>
|
||||||
|
|
||||||
<function name="DeleteBuffers" es1="1.1" es2="2.0" no_error="true">
|
<function name="DeleteBuffers" es1="1.1" es2="2.0" no_error="true"
|
||||||
|
marshal_call_after="if (COMPAT) _mesa_glthread_DeleteBuffers(ctx, n, buffer);">
|
||||||
<param name="n" type="GLsizei" counter="true"/>
|
<param name="n" type="GLsizei" counter="true"/>
|
||||||
<param name="buffer" type="const GLuint *" count="n"/>
|
<param name="buffer" type="const GLuint *" count="n"/>
|
||||||
<glx ignore="true"/>
|
<glx ignore="true"/>
|
||||||
|
@@ -54,7 +54,7 @@ struct _mesa_HashTable;
|
|||||||
struct glthread_vao {
|
struct glthread_vao {
|
||||||
GLuint Name;
|
GLuint Name;
|
||||||
bool HasUserPointer;
|
bool HasUserPointer;
|
||||||
bool IndexBufferIsUserPointer;
|
GLuint CurrentElementBufferName;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A single batch of commands queued up for execution. */
|
/** A single batch of commands queued up for execution. */
|
||||||
@@ -104,17 +104,9 @@ struct glthread_state
|
|||||||
struct glthread_vao *LastLookedUpVAO;
|
struct glthread_vao *LastLookedUpVAO;
|
||||||
struct glthread_vao DefaultVAO;
|
struct glthread_vao DefaultVAO;
|
||||||
|
|
||||||
/**
|
/** Currently-bound buffer object IDs. */
|
||||||
* Tracks on the main thread side whether the current vertex array binding
|
GLuint CurrentArrayBufferName;
|
||||||
* is in a VBO.
|
GLuint CurrentDrawIndirectBufferName;
|
||||||
*/
|
|
||||||
bool vertex_array_is_vbo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tracks on the main thread side whether the current element array (index
|
|
||||||
* buffer) binding is in a VBO.
|
|
||||||
*/
|
|
||||||
bool draw_indirect_buffer_is_vbo;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void _mesa_glthread_init(struct gl_context *ctx);
|
void _mesa_glthread_init(struct gl_context *ctx);
|
||||||
@@ -126,6 +118,11 @@ void _mesa_glthread_flush_batch(struct gl_context *ctx);
|
|||||||
void _mesa_glthread_finish(struct gl_context *ctx);
|
void _mesa_glthread_finish(struct gl_context *ctx);
|
||||||
void _mesa_glthread_finish_before(struct gl_context *ctx, const char *func);
|
void _mesa_glthread_finish_before(struct gl_context *ctx, const char *func);
|
||||||
|
|
||||||
|
void _mesa_glthread_BindBuffer(struct gl_context *ctx, GLenum target,
|
||||||
|
GLuint buffer);
|
||||||
|
void _mesa_glthread_DeleteBuffers(struct gl_context *ctx, GLsizei n,
|
||||||
|
const GLuint *buffers);
|
||||||
|
|
||||||
void _mesa_glthread_BindVertexArray(struct gl_context *ctx, GLuint id);
|
void _mesa_glthread_BindVertexArray(struct gl_context *ctx, GLuint id);
|
||||||
void _mesa_glthread_DeleteVertexArrays(struct gl_context *ctx,
|
void _mesa_glthread_DeleteVertexArrays(struct gl_context *ctx,
|
||||||
GLsizei n, const GLuint *ids);
|
GLsizei n, const GLuint *ids);
|
||||||
|
@@ -54,21 +54,41 @@ _mesa_glthread_BindBuffer(struct gl_context *ctx, GLenum target, GLuint buffer)
|
|||||||
|
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case GL_ARRAY_BUFFER:
|
case GL_ARRAY_BUFFER:
|
||||||
glthread->vertex_array_is_vbo = (buffer != 0);
|
glthread->CurrentArrayBufferName = buffer;
|
||||||
break;
|
break;
|
||||||
case GL_ELEMENT_ARRAY_BUFFER:
|
case GL_ELEMENT_ARRAY_BUFFER:
|
||||||
/* The current element array buffer binding is actually tracked in the
|
/* The current element array buffer binding is actually tracked in the
|
||||||
* vertex array object instead of the context, so this would need to
|
* vertex array object instead of the context, so this would need to
|
||||||
* change on vertex array object updates.
|
* change on vertex array object updates.
|
||||||
*/
|
*/
|
||||||
glthread->CurrentVAO->IndexBufferIsUserPointer = buffer != 0;
|
glthread->CurrentVAO->CurrentElementBufferName = buffer;
|
||||||
break;
|
break;
|
||||||
case GL_DRAW_INDIRECT_BUFFER:
|
case GL_DRAW_INDIRECT_BUFFER:
|
||||||
glthread->draw_indirect_buffer_is_vbo = buffer != 0;
|
glthread->CurrentDrawIndirectBufferName = buffer;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_mesa_glthread_DeleteBuffers(struct gl_context *ctx, GLsizei n,
|
||||||
|
const GLuint *buffers)
|
||||||
|
{
|
||||||
|
struct glthread_state *glthread = &ctx->GLThread;
|
||||||
|
|
||||||
|
if (!buffers)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < n; i++) {
|
||||||
|
GLuint id = buffers[i];
|
||||||
|
|
||||||
|
if (id == glthread->CurrentArrayBufferName)
|
||||||
|
_mesa_glthread_BindBuffer(ctx, GL_ARRAY_BUFFER, 0);
|
||||||
|
if (id == glthread->CurrentVAO->CurrentElementBufferName)
|
||||||
|
_mesa_glthread_BindBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
if (id == glthread->CurrentDrawIndirectBufferName)
|
||||||
|
_mesa_glthread_BindBuffer(ctx, GL_DRAW_INDIRECT_BUFFER, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* BufferData: marshalled asynchronously */
|
/* BufferData: marshalled asynchronously */
|
||||||
struct marshal_cmd_BufferData
|
struct marshal_cmd_BufferData
|
||||||
|
@@ -81,10 +81,10 @@ static inline bool
|
|||||||
_mesa_glthread_is_non_vbo_draw_elements(const struct gl_context *ctx)
|
_mesa_glthread_is_non_vbo_draw_elements(const struct gl_context *ctx)
|
||||||
{
|
{
|
||||||
const struct glthread_state *glthread = &ctx->GLThread;
|
const struct glthread_state *glthread = &ctx->GLThread;
|
||||||
|
struct glthread_vao *vao = glthread->CurrentVAO;
|
||||||
|
|
||||||
return ctx->API != API_OPENGL_CORE &&
|
return ctx->API != API_OPENGL_CORE &&
|
||||||
(glthread->CurrentVAO->IndexBufferIsUserPointer ||
|
(vao->CurrentElementBufferName == 0 || vao->HasUserPointer);
|
||||||
glthread->CurrentVAO->HasUserPointer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
@@ -101,28 +101,25 @@ _mesa_glthread_is_non_vbo_draw_arrays_indirect(const struct gl_context *ctx)
|
|||||||
const struct glthread_state *glthread = &ctx->GLThread;
|
const struct glthread_state *glthread = &ctx->GLThread;
|
||||||
|
|
||||||
return ctx->API != API_OPENGL_CORE &&
|
return ctx->API != API_OPENGL_CORE &&
|
||||||
(!glthread->draw_indirect_buffer_is_vbo ||
|
(glthread->CurrentDrawIndirectBufferName == 0 ||
|
||||||
glthread->CurrentVAO->HasUserPointer );
|
glthread->CurrentVAO->HasUserPointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
_mesa_glthread_is_non_vbo_draw_elements_indirect(const struct gl_context *ctx)
|
_mesa_glthread_is_non_vbo_draw_elements_indirect(const struct gl_context *ctx)
|
||||||
{
|
{
|
||||||
const struct glthread_state *glthread = &ctx->GLThread;
|
const struct glthread_state *glthread = &ctx->GLThread;
|
||||||
|
struct glthread_vao *vao = glthread->CurrentVAO;
|
||||||
|
|
||||||
return ctx->API != API_OPENGL_CORE &&
|
return ctx->API != API_OPENGL_CORE &&
|
||||||
(!glthread->draw_indirect_buffer_is_vbo ||
|
(glthread->CurrentDrawIndirectBufferName == 0 ||
|
||||||
glthread->CurrentVAO->IndexBufferIsUserPointer ||
|
vao->CurrentElementBufferName == 0 || vao->HasUserPointer);
|
||||||
glthread->CurrentVAO->HasUserPointer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct _glapi_table *
|
struct _glapi_table *
|
||||||
_mesa_create_marshal_table(const struct gl_context *ctx);
|
_mesa_create_marshal_table(const struct gl_context *ctx);
|
||||||
|
|
||||||
void
|
|
||||||
_mesa_glthread_BindBuffer(struct gl_context *ctx, GLenum target, GLuint buffer);
|
|
||||||
|
|
||||||
static inline unsigned
|
static inline unsigned
|
||||||
_mesa_buffer_enum_to_count(GLenum buffer)
|
_mesa_buffer_enum_to_count(GLenum buffer)
|
||||||
{
|
{
|
||||||
|
@@ -124,12 +124,11 @@ _mesa_glthread_GenVertexArrays(struct gl_context *ctx,
|
|||||||
GLuint id = arrays[i];
|
GLuint id = arrays[i];
|
||||||
struct glthread_vao *vao;
|
struct glthread_vao *vao;
|
||||||
|
|
||||||
vao = malloc(sizeof(*vao));
|
vao = calloc(1, sizeof(*vao));
|
||||||
if (!vao)
|
if (!vao)
|
||||||
continue; /* Is that all we can do? */
|
continue; /* Is that all we can do? */
|
||||||
|
|
||||||
vao->Name = id;
|
vao->Name = id;
|
||||||
vao->HasUserPointer = false;
|
|
||||||
_mesa_HashInsertLocked(glthread->VAOs, id, vao);
|
_mesa_HashInsertLocked(glthread->VAOs, id, vao);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,6 +138,6 @@ _mesa_glthread_AttribPointer(struct gl_context *ctx)
|
|||||||
{
|
{
|
||||||
struct glthread_state *glthread = &ctx->GLThread;
|
struct glthread_state *glthread = &ctx->GLThread;
|
||||||
|
|
||||||
if (!glthread->vertex_array_is_vbo)
|
if (glthread->CurrentArrayBufferName == 0)
|
||||||
glthread->CurrentVAO->HasUserPointer = true;
|
glthread->CurrentVAO->HasUserPointer = true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user