mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-29 15:00:38 +02:00
mesa: lock Shared->TexMutex only once for a glthread batch
This removes a lot of locking from the driver thread. Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7053>
This commit is contained in:
parent
8e7270de55
commit
9edfbd6296
4 changed files with 14 additions and 4 deletions
|
|
@ -54,6 +54,8 @@ glthread_unmarshal_batch(void *job, int thread_index)
|
|||
|
||||
_mesa_HashLockMutex(ctx->Shared->BufferObjects);
|
||||
ctx->BufferObjectsLocked = true;
|
||||
mtx_lock(&ctx->Shared->TexMutex);
|
||||
ctx->TexturesLocked = true;
|
||||
|
||||
while (pos < used) {
|
||||
const struct marshal_cmd_base *cmd =
|
||||
|
|
@ -63,6 +65,8 @@ glthread_unmarshal_batch(void *job, int thread_index)
|
|||
pos += cmd->cmd_size;
|
||||
}
|
||||
|
||||
ctx->TexturesLocked = false;
|
||||
mtx_unlock(&ctx->Shared->TexMutex);
|
||||
ctx->BufferObjectsLocked = false;
|
||||
_mesa_HashUnlockMutex(ctx->Shared->BufferObjects);
|
||||
|
||||
|
|
|
|||
|
|
@ -4928,6 +4928,8 @@ struct gl_context
|
|||
|
||||
/** Whether Shared->BufferObjects has already been locked for this context. */
|
||||
bool BufferObjectsLocked;
|
||||
/** Whether Shared->TexMutex has already been locked for this context. */
|
||||
bool TexturesLocked;
|
||||
|
||||
/** \name API function pointer tables */
|
||||
/*@{*/
|
||||
|
|
|
|||
|
|
@ -2193,7 +2193,8 @@ _mesa_IsTexture( GLuint texture )
|
|||
void
|
||||
_mesa_lock_context_textures( struct gl_context *ctx )
|
||||
{
|
||||
mtx_lock(&ctx->Shared->TexMutex);
|
||||
if (!ctx->TexturesLocked)
|
||||
mtx_lock(&ctx->Shared->TexMutex);
|
||||
|
||||
if (ctx->Shared->TextureStateStamp != ctx->TextureStateTimestamp) {
|
||||
ctx->NewState |= _NEW_TEXTURE_OBJECT;
|
||||
|
|
@ -2206,7 +2207,8 @@ void
|
|||
_mesa_unlock_context_textures( struct gl_context *ctx )
|
||||
{
|
||||
assert(ctx->Shared->TextureStateStamp == ctx->TextureStateTimestamp);
|
||||
mtx_unlock(&ctx->Shared->TexMutex);
|
||||
if (!ctx->TexturesLocked)
|
||||
mtx_unlock(&ctx->Shared->TexMutex);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,8 @@ _mesa_reference_texobj(struct gl_texture_object **ptr,
|
|||
static inline void
|
||||
_mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
|
||||
{
|
||||
mtx_lock(&ctx->Shared->TexMutex);
|
||||
if (!ctx->TexturesLocked)
|
||||
mtx_lock(&ctx->Shared->TexMutex);
|
||||
ctx->Shared->TextureStateStamp++;
|
||||
(void) texObj;
|
||||
}
|
||||
|
|
@ -115,7 +116,8 @@ static inline void
|
|||
_mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
|
||||
{
|
||||
(void) texObj;
|
||||
mtx_unlock(&ctx->Shared->TexMutex);
|
||||
if (!ctx->TexturesLocked)
|
||||
mtx_unlock(&ctx->Shared->TexMutex);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue