llvmpipe: init renderer string once to avoid races.

In a multithreads clover run the get_name call would race against
itself and sometimes an empty device name would occur.

Just init it once.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12285>
This commit is contained in:
Dave Airlie 2021-08-09 14:06:12 +10:00 committed by Marge Bot
parent ff99270923
commit 9e6f414766
2 changed files with 8 additions and 4 deletions

View File

@ -109,10 +109,8 @@ llvmpipe_get_vendor(struct pipe_screen *screen)
static const char *
llvmpipe_get_name(struct pipe_screen *screen)
{
static char buf[100];
snprintf(buf, sizeof(buf), "llvmpipe (LLVM " MESA_LLVM_VERSION_STRING ", %u bits)",
lp_native_vector_width );
return buf;
struct llvmpipe_screen *lscreen = llvmpipe_screen(screen);
return lscreen->renderer_string;
}
@ -1037,6 +1035,10 @@ llvmpipe_create_screen(struct sw_winsys *winsys)
screen->num_threads = debug_get_num_option("LP_NUM_THREADS", screen->num_threads);
screen->num_threads = MIN2(screen->num_threads, LP_MAX_THREADS);
lp_build_init(); /* get lp_native_vector_width initialised */
snprintf(screen->renderer_string, sizeof(screen->renderer_string), "llvmpipe (LLVM " MESA_LLVM_VERSION_STRING ", %u bits)", lp_native_vector_width );
(void) mtx_init(&screen->cs_mutex, mtx_plain);
(void) mtx_init(&screen->rast_mutex, mtx_plain);

View File

@ -67,6 +67,8 @@ struct llvmpipe_screen
mtx_t late_mutex;
bool late_init_done;
char renderer_string[100];
struct disk_cache *disk_shader_cache;
unsigned num_disk_shader_cache_hits;
unsigned num_disk_shader_cache_misses;