gallivm: break out native vector width calc for reuse
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 21 Apr 2023 14:56:44 +0000 (10:56 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 25 Apr 2023 00:04:08 +0000 (00:04 +0000)
breaks dependency on lp_build_init()

cc: mesa-stable

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22600>

src/gallium/auxiliary/gallivm/lp_bld_init.c
src/gallium/auxiliary/gallivm/lp_bld_init.h
src/gallium/drivers/llvmpipe/lp_screen.c

index dc39165..7f61662 100644 (file)
@@ -420,6 +420,15 @@ fail:
    return FALSE;
 }
 
+unsigned
+lp_build_get_native_width(void)
+{
+   // Default to 256 until we're confident llvmpipe with 512 is as correct and not slower than 256
+   unsigned vector_width = MIN2(util_get_cpu_caps()->max_vector_bits, 256);
+
+   vector_width = debug_get_num_option("LP_NATIVE_VECTOR_WIDTH", vector_width);
+   return vector_width;
+}
 
 boolean
 lp_build_init(void)
@@ -440,11 +449,7 @@ lp_build_init(void)
 
    lp_set_target_options();
 
-   // Default to 256 until we're confident llvmpipe with 512 is as correct and not slower than 256
-   lp_native_vector_width = MIN2(util_get_cpu_caps()->max_vector_bits, 256);
-
-   lp_native_vector_width = debug_get_num_option("LP_NATIVE_VECTOR_WIDTH",
-                                                 lp_native_vector_width);
+   lp_native_vector_width = lp_build_get_native_width();
 
 #if DETECT_ARCH_PPC_64
    /* Set the NJ bit in VSCR to 0 so denormalized values are handled as
index ca267a3..d462c8c 100644 (file)
@@ -68,6 +68,8 @@ struct gallivm_state
    LLVMValueRef get_time_hook;
 };
 
+unsigned
+lp_build_get_native_width(void);
 
 boolean
 lp_build_init(void);
index 7d5e5c7..2ab33d9 100644 (file)
@@ -1113,7 +1113,7 @@ llvmpipe_create_screen(struct sw_winsys *winsys)
 
    snprintf(screen->renderer_string, sizeof(screen->renderer_string),
             "llvmpipe (LLVM " MESA_LLVM_VERSION_STRING ", %u bits)",
-            lp_native_vector_width );
+            lp_build_get_native_width() );
 
    list_inithead(&screen->ctx_list);
    (void) mtx_init(&screen->ctx_mutex, mtx_plain);