llvmpipe: init renderer string once to avoid races.
authorDave Airlie <airlied@redhat.com>
Mon, 9 Aug 2021 04:06:12 +0000 (14:06 +1000)
committerMarge Bot <eric+marge@anholt.net>
Mon, 16 Aug 2021 23:20:00 +0000 (23:20 +0000)
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>

src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_screen.h

index 98b93e4..9a406d1 100644 (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);
 
index dad886c..c72bf83 100644 (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;