From 4a26f57103088fc151b74d1b0bfc77201a632fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 22 Oct 2021 15:15:35 -0400 Subject: [PATCH] mesa: fix locking when destroying/overwriting/adding display lists We need to hold the lock when calling destroy_list and doing _mesa_HashInsertLocked in EndList. So move the locking out of destroy_list. Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/mesa/main/dlist.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 611c4c3d001..895e01367d9 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -1453,7 +1453,7 @@ destroy_list(struct gl_context *ctx, GLuint list) if (list == 0) return; - dlist = _mesa_lookup_list(ctx, list, false); + dlist = _mesa_lookup_list(ctx, list, true); if (!dlist) return; @@ -1467,10 +1467,8 @@ destroy_list(struct gl_context *ctx, GLuint list) check_atlas_for_deleted_list, &list); } - _mesa_HashLockMutex(ctx->Shared->DisplayList); _mesa_delete_list(ctx, dlist); _mesa_HashRemoveLocked(ctx->Shared->DisplayList, list); - _mesa_HashUnlockMutex(ctx->Shared->DisplayList); } @@ -13487,9 +13485,11 @@ _mesa_DeleteLists(GLuint list, GLsizei range) } } + _mesa_HashLockMutex(ctx->Shared->DisplayList); for (i = list; i < list + range; i++) { destroy_list(ctx, i); } + _mesa_HashUnlockMutex(ctx->Shared->DisplayList); } @@ -13798,8 +13798,6 @@ _mesa_EndList(void) list->CurrentList->begins_with_a_nop = false; } - _mesa_HashUnlockMutex(ctx->Shared->DisplayList); - /* Destroy old list, if any */ destroy_list(ctx, ctx->ListState.CurrentList->Name); @@ -13808,10 +13806,11 @@ _mesa_EndList(void) ctx->ListState.CurrentList->Name, ctx->ListState.CurrentList, true); - if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) mesa_print_display_list(ctx->ListState.CurrentList->Name); + _mesa_HashUnlockMutex(ctx->Shared->DisplayList); + ctx->ListState.CurrentList = NULL; ctx->ListState.CurrentBlock = NULL; ctx->ListState.CurrentPos = 0;