From bc3142734e321aa64fe6946b79cfdbf9a99ed668 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 2 Dec 2020 15:10:51 -0800 Subject: [PATCH] gallium/osmesa: Fix data race on setting up the ST API. We're going to need it anyway, put it in the same call_once as the ST manager. Closes: #880 Reviewed-by: Adam Jackson Part-of: --- src/gallium/frontends/osmesa/osmesa.c | 29 ++++++++++++--------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/gallium/frontends/osmesa/osmesa.c b/src/gallium/frontends/osmesa/osmesa.c index 19d70784536..5ce5f7b7da6 100644 --- a/src/gallium/frontends/osmesa/osmesa.c +++ b/src/gallium/frontends/osmesa/osmesa.c @@ -131,21 +131,8 @@ osmesa_st_get_param(struct st_manager *smapi, enum st_manager_param param) return 0; } - -/** - * Create/return singleton st_api object. - */ -static struct st_api * -get_st_api(void) -{ - static struct st_api *stapi = NULL; - if (!stapi) { - stapi = st_gl_api_create(); - } - return stapi; -} - static struct st_manager *stmgr = NULL; +static struct st_api *stapi = NULL; static void create_st_manager(void) @@ -156,6 +143,8 @@ create_st_manager(void) stmgr->get_param = osmesa_st_get_param; stmgr->get_egl_image = NULL; } + + stapi = st_gl_api_create(); } /** @@ -171,6 +160,16 @@ get_st_manager(void) return stmgr; } +/** + * Create/return singleton st_api object. + */ +static struct st_api * +get_st_api(void) +{ + get_st_manager(); + return stapi; +} + /* Reads the color or depth buffer from the backing context to either the user storage * (color buffer) or our temporary (z/s) */ @@ -500,8 +499,6 @@ osmesa_create_buffer(enum pipe_format color_format, static void osmesa_destroy_buffer(struct osmesa_buffer *osbuffer) { - struct st_api *stapi = get_st_api(); - /* * Notify the state manager that the associated framebuffer interface * is no longer valid.