gallium/swr: Disable showing detected arch message.
authorKrzysztof Raszkowski <krzysztof.raszkowski@intel.com>
Fri, 17 Jan 2020 15:43:33 +0000 (16:43 +0100)
committerKrzysztof Raszkowski <krzysztof.raszkowski@intel.com>
Fri, 17 Jan 2020 16:41:53 +0000 (16:41 +0000)
When swr driver is in use it print detected architecture
message to std::err. It can be harmfull when swr is using
in multinodes environments.
It can be enabled setting env var SWR_PRINT_INFO to 1.

Reviewed-by: Jan Zielinski <jan.zielinski@intel.com>
src/gallium/drivers/swr/swr_loader.cpp
src/gallium/drivers/swr/swr_screen.cpp
src/gallium/drivers/swr/swr_screen.h

index f597b5015e46c14ee4fb84ccf93055e5c02c7567..d9211315e5826265a15a8389ca4020e572a9d5e2 100644 (file)
@@ -38,7 +38,7 @@ swr_initialize_screen_interface(struct swr_screen *screen, const char arch[])
    screen->pfnSwrGetInterface = SwrGetInterface;
    screen->pfnSwrGetInterface = SwrGetTileInterface;
    InitTilesTable();
-   fprintf(stderr, "(using: builtin).\n");
+   swr_print_info("(using: builtin).\n");
 #else
    char filename[256] = { 0 };
    sprintf(filename, "%sswr%s%s", UTIL_DL_PREFIX, arch, UTIL_DL_EXT);
@@ -71,8 +71,9 @@ swr_initialize_screen_interface(struct swr_screen *screen, const char arch[])
 
    pInitFunc();
 
-   fprintf(stderr, "(using: %s).\n", filename);
+   swr_print_info("(using: %s).\n", filename);
 #endif
+
    return true;
 }
 
@@ -91,9 +92,9 @@ swr_create_screen(struct sw_winsys *winsys)
    util_cpu_detect();
 
    if (util_cpu_caps.has_avx512f && util_cpu_caps.has_avx512er) {
-      fprintf(stderr, "SWR detected KNL instruction support ");
+      swr_print_info("SWR detected KNL instruction support ");
 #ifndef HAVE_SWR_KNL
-      fprintf(stderr, "(skipping: not built).\n");
+      swr_print_info("(skipping: not built).\n");
 #else
       if (swr_initialize_screen_interface(screen, "KNL")) {
          screen->is_knl = true;
@@ -103,9 +104,9 @@ swr_create_screen(struct sw_winsys *winsys)
    }
 
    if (util_cpu_caps.has_avx512f && util_cpu_caps.has_avx512bw) {
-      fprintf(stderr, "SWR detected SKX instruction support ");
+      swr_print_info("SWR detected SKX instruction support ");
 #ifndef HAVE_SWR_SKX
-      fprintf(stderr, "(skipping not built).\n");
+      swr_print_info("(skipping not built).\n");
 #else
       if (swr_initialize_screen_interface(screen, "SKX"))
          return p_screen;
@@ -113,9 +114,9 @@ swr_create_screen(struct sw_winsys *winsys)
    }
 
    if (util_cpu_caps.has_avx2) {
-      fprintf(stderr, "SWR detected AVX2 instruction support ");
+      swr_print_info("SWR detected AVX2 instruction support ");
 #ifndef HAVE_SWR_AVX2
-      fprintf(stderr, "(skipping not built).\n");
+      swr_print_info("(skipping not built).\n");
 #else
       if (swr_initialize_screen_interface(screen, "AVX2"))
          return p_screen;
@@ -123,9 +124,9 @@ swr_create_screen(struct sw_winsys *winsys)
    }
 
    if (util_cpu_caps.has_avx) {
-      fprintf(stderr, "SWR detected AVX instruction support ");
+      swr_print_info("SWR detected AVX instruction support ");
 #ifndef HAVE_SWR_AVX
-      fprintf(stderr, "(skipping not built).\n");
+      swr_print_info("(skipping not built).\n");
 #else
       if (swr_initialize_screen_interface(screen, "AVX"))
          return p_screen;
index b2e3132b2a7298c4b3acb027696d2e9a3b8cb712..a27462f1a45f0b609174a43d386342dc1b933cb2 100644 (file)
@@ -783,7 +783,7 @@ swr_texture_layout(struct swr_screen *screen,
        * surface sample count. */
       if (screen->msaa_force_enable) {
          res->swr.numSamples = screen->msaa_max_count;
-         fprintf(stderr,"swr_texture_layout: forcing sample count: %d\n",
+         swr_print_info("swr_texture_layout: forcing sample count: %d\n",
                  res->swr.numSamples);
       }
    } else {
@@ -1123,7 +1123,7 @@ swr_destroy_screen(struct pipe_screen *p_screen)
    struct swr_screen *screen = swr_screen(p_screen);
    struct sw_winsys *winsys = screen->winsys;
 
-   fprintf(stderr, "SWR destroy screen!\n");
+   swr_print_info("SWR destroy screen!\n");
 
    if (winsys->destroy)
       winsys->destroy(winsys);
@@ -1157,12 +1157,11 @@ swr_validate_env_options(struct swr_screen *screen)
          fprintf(stderr, "must be power of 2 between 1 and %d" \
                          " (or 1 to disable msaa)\n",
                SWR_MAX_NUM_MULTISAMPLES);
+         fprintf(stderr, "(msaa disabled)\n");
          msaa_max_count = 1;
       }
 
-      fprintf(stderr, "SWR_MSAA_MAX_COUNT: %d\n", msaa_max_count);
-      if (msaa_max_count == 1)
-         fprintf(stderr, "(msaa disabled)\n");
+      swr_print_info("SWR_MSAA_MAX_COUNT: %d\n", msaa_max_count);
 
       screen->msaa_max_count = msaa_max_count;
    }
@@ -1170,7 +1169,7 @@ swr_validate_env_options(struct swr_screen *screen)
    screen->msaa_force_enable = debug_get_bool_option(
          "SWR_MSAA_FORCE_ENABLE", false);
    if (screen->msaa_force_enable)
-      fprintf(stderr, "SWR_MSAA_FORCE_ENABLE: true\n");
+      swr_print_info("SWR_MSAA_FORCE_ENABLE: true\n");
 }
 
 
index fac2a5ea8c7d7c210a44a35c2c382fc40323d18f..8c79acfea4cb019c384e63cc3ec0d3309a6741bd 100644 (file)
@@ -34,6 +34,8 @@
 
 #include "memory/TilingFunctions.h"
 #include "memory/InitMemory.h"
+#include <stdio.h>
+#include <stdarg.h>
 
 struct sw_winsys;
 
@@ -70,4 +72,15 @@ swr_screen(struct pipe_screen *pipe)
 SWR_FORMAT
 mesa_to_swr_format(enum pipe_format format);
 
+static void swr_print_info(const char *format, ...)
+{
+   static bool print_info = debug_get_bool_option("SWR_PRINT_INFO", false);
+   if(print_info) {
+      va_list args;
+      va_start(args, format);
+      vfprintf(stderr, format, args);
+      va_end(args);
+   }
+}
+
 #endif