Mesa (main): llvmpipe: init renderer string once to avoid races.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 16 23:48:51 UTC 2021


Module: Mesa
Branch: main
Commit: 9e6f414766b7af5652718d85dc28b28b4ea61926
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9e6f414766b7af5652718d85dc28b28b4ea61926

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Aug  9 14:06:12 2021 +1000

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 at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12285>

---

 src/gallium/drivers/llvmpipe/lp_screen.c | 10 ++++++----
 src/gallium/drivers/llvmpipe/lp_screen.h |  2 ++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
index 98b93e458bc..9a406d19bd5 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -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);
 
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.h b/src/gallium/drivers/llvmpipe/lp_screen.h
index dad886c8aea..c72bf838acb 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.h
+++ b/src/gallium/drivers/llvmpipe/lp_screen.h
@@ -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;



More information about the mesa-commit mailing list