[Mesa-dev] [PATCH 2/2] swr: suppress debug output from loader unless LIBGL_DEBUG is set.
Eric Engestrom
eric.engestrom at imgtec.com
Tue Jan 16 18:09:27 UTC 2018
On Tuesday, 2018-01-16 10:36:50 -0500, Chuck Atkins wrote:
> Signed-off-by: Chuck Atkins <chuck.atkins at kitware.com>
> CC: Tim Rowley <timothy.o.rowley at intel.com>
> CC: Bruce Cherniak <bruce.cherniak at intel.com>
> ---
> src/gallium/drivers/swr/swr_loader.cpp | 41 +++++++++++++++++++++-------------
> 1 file changed, 25 insertions(+), 16 deletions(-)
>
> diff --git a/src/gallium/drivers/swr/swr_loader.cpp b/src/gallium/drivers/swr/swr_loader.cpp
> index 40324904d9..f9bf6f4944 100644
> --- a/src/gallium/drivers/swr/swr_loader.cpp
> +++ b/src/gallium/drivers/swr/swr_loader.cpp
> @@ -36,24 +36,31 @@ swr_create_screen(struct sw_winsys *winsys)
> bool found = false;
> bool is_knl = false;
>
> +#ifdef DEBUG
> + bool mesa_debug = true;
> +#else
> + bool mesa_debug = getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG");
> +#endif
> +
> #ifndef HAVE_SWR_BUILTIN
> char filename[256] = { 0 };
> #endif
>
> +#define debug_printf(...) if(mesa_debug) { fprintf(stderr, __VA_ARGS__); }
`do {} while(0)`
>
> util_cpu_detect();
>
> if (!found && util_cpu_caps.has_avx512f && util_cpu_caps.has_avx512er) {
> - fprintf(stderr, "SWR detected KNL instruction support ");
> + debug_printf("SWR detected KNL instruction support ");
> #ifndef HAVE_SWR_KNL
> - fprintf(stderr, "(skipping; not built).\n");
> + debug_printf("(skipping; not built).\n");
> #else
> #ifdef HAVE_SWR_BUILTIN
> swr_screen(screen)->pfnSwrGetInterface = SwrGetInterface;
> - fprintf(stderr, "(using; builtin).\n");
> + debug_printf("(using; builtin).\n");
> #else
> sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrKNL", UTIL_DL_EXT);
> - fprintf(stderr, "(using; %s).\n", filename);
> + debug_printf("(using; %s).\n", filename);
> #endif
> found = true;
> is_knl = true;
> @@ -61,53 +68,55 @@ swr_create_screen(struct sw_winsys *winsys)
> }
>
> if (!found && util_cpu_caps.has_avx512f && util_cpu_caps.has_avx512bw) {
> - fprintf(stderr, "SWR detected SKX instruction support ");
> + debug_printf("SWR detected SKX instruction support ");
> #ifndef HAVE_SWR_SKX
> - fprintf(stderr, "(skipping; not built).\n");
> + debug_printf("(skipping; not built).\n");
> #else
> #ifdef HAVE_SWR_BUILTIN
> swr_screen(screen)->pfnSwrGetInterface = SwrGetInterface;
> - fprintf(stderr, "(using; builtin).\n");
> + debug_printf("(using; builtin).\n");
> #else
> sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrSKX", UTIL_DL_EXT);
> - fprintf(stderr, "(using; %s).\n", filename);
> + debug_printf("(using; %s).\n", filename);
> #endif
> found = true;
> #endif
> }
>
> if (!found && util_cpu_caps.has_avx2) {
> - fprintf(stderr, "SWR detected AVX2 instruction support ");
> + debug_printf("SWR detected AVX2 instruction support ");
> #ifndef HAVE_SWR_AVX2
> - fprintf(stderr, "(skipping; not built).\n");
> + debug_printf("(skipping; not built).\n");
> #else
> #ifdef HAVE_SWR_BUILTIN
> swr_screen(screen)->pfnSwrGetInterface = SwrGetInterface;
> - fprintf(stderr, "(using; builtin).\n");
> + debug_printf("(using; builtin).\n");
> #else
> sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX2", UTIL_DL_EXT);
> - fprintf(stderr, "(using; %s).\n", filename);
> + debug_printf("(using; %s).\n", filename);
> #endif
> found = true;
> #endif
> }
>
> if (!found && util_cpu_caps.has_avx) {
> - fprintf(stderr, "SWR detected AVX instruction support ");
> + debug_printf("SWR detected AVX instruction support ");
> #ifndef HAVE_SWR_AVX
> - fprintf(stderr, "(skipping; not built).\n");
> + debug_printf("(skipping; not built).\n");
> #else
> #ifdef HAVE_SWR_BUILTIN
> swr_screen(screen)->pfnSwrGetInterface = SwrGetInterface;
> - fprintf(stderr, "(using; builtin).\n");
> + debug_printf("(using; builtin).\n");
> #else
> sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX", UTIL_DL_EXT);
> - fprintf(stderr, "(using; %s).\n", filename);
> + debug_printf("(using; %s).\n", filename);
> #endif
> found = true;
> #endif
> }
>
> +#undef debug_printf
Why only replace some of the printfs?
> +
> if (!found) {
> fprintf(stderr, "SWR could not detect a supported CPU architecture.\n");
> exit(-1);
> --
> 2.14.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list