diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/swr/swr_loader.cpp | 84 |
1 files changed, 49 insertions, 35 deletions
diff --git a/src/gallium/drivers/swr/swr_loader.cpp b/src/gallium/drivers/swr/swr_loader.cpp index 9d6f918e349..7f28bdb5366 100644 --- a/src/gallium/drivers/swr/swr_loader.cpp +++ b/src/gallium/drivers/swr/swr_loader.cpp @@ -28,81 +28,95 @@ #include <stdio.h> +// Helper function to resolve the backend filename based on architecture +inline void get_swr_arch_filename(const char arch[], char filename[]) +{ +#ifdef HAVE_SWR_BUILTIN + strcpy(filename , "builtin"); +#else + sprintf(filename, "%sswr%s%s", UTIL_DL_PREFIX, arch, UTIL_DL_EXT); +#endif +} + struct pipe_screen * swr_create_screen(struct sw_winsys *winsys) { char filename[256] = { 0 }; - fprintf(stderr, "SWR detected "); - - util_dl_library *pLibrary = nullptr; + bool found = false; + bool is_knl = false; + PFNSwrGetInterface pfnSwrGetInterface = nullptr; util_cpu_detect(); - bool is_knl = false; - - if (!strlen(filename) && - util_cpu_caps.has_avx512f && util_cpu_caps.has_avx512er) { -#if HAVE_SWR_KNL - fprintf(stderr, "KNL "); - sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrKNL", UTIL_DL_EXT); - is_knl = true; + if (!found && util_cpu_caps.has_avx512f && util_cpu_caps.has_avx512er) { + fprintf(stderr, "SWR detected KNL instruction support "); +#ifndef HAVE_SWR_KNL + fprintf(stderr, "(skipping not built).\n"); #else - fprintf(stderr, "KNL (not built) "); + get_swr_arch_filename("KNL", filename); + found = true; + is_knl = true; #endif } - if (!strlen(filename) && - util_cpu_caps.has_avx512f && util_cpu_caps.has_avx512bw) { -#if HAVE_SWR_SKX - fprintf(stderr, "SKX "); - sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrSKX", UTIL_DL_EXT); + if (!found && util_cpu_caps.has_avx512f && util_cpu_caps.has_avx512bw) { + fprintf(stderr, "SWR detected SKX instruction support "); +#ifndef HAVE_SWR_SKX + fprintf(stderr, "(skipping not built).\n"); #else - fprintf(stderr, "SKX (not built) "); + get_swr_arch_filename("SKX", filename); + found = true; #endif } - if (!strlen(filename) && util_cpu_caps.has_avx2) { -#if HAVE_SWR_AVX2 - fprintf(stderr, "AVX2 "); - sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX2", UTIL_DL_EXT); + if (!found && util_cpu_caps.has_avx2) { + fprintf(stderr, "SWR detected AVX2 instruction support "); +#ifndef HAVE_SWR_AVX2 + fprintf(stderr, "(skipping not built).\n"); #else - fprintf(stderr, "AVX2 (not built) "); + get_swr_arch_filename("AVX2", filename); + found = true; #endif } - if (!strlen(filename) && util_cpu_caps.has_avx) { -#if HAVE_SWR_AVX - fprintf(stderr, "AVX "); - sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX", UTIL_DL_EXT); + if (!found && util_cpu_caps.has_avx) { + fprintf(stderr, "SWR detected AVX instruction support "); +#ifndef HAVE_SWR_AVX + fprintf(stderr, "(skipping not built).\n"); #else - fprintf(stderr, "AVX (not built) "); + get_swr_arch_filename("AVX", filename); + found = true; #endif } - if (!strlen(filename)) { - fprintf(stderr, "- no appropriate swr architecture library. Aborting!\n"); + if (!found) { + fprintf(stderr, "SWR could not detect a supported CPU architecture.\n"); exit(-1); - } else { - fprintf(stderr, "\n"); } - pLibrary = util_dl_open(filename); + fprintf(stderr, "(using %s).\n", filename); +#ifdef HAVE_SWR_BUILTIN + pfnSwrGetInterface = SwrGetInterface; +#else + util_dl_library *pLibrary = util_dl_open(filename); if (!pLibrary) { fprintf(stderr, "SWR library load failure: %s\n", util_dl_error()); exit(-1); } util_dl_proc pApiProc = util_dl_get_proc_address(pLibrary, "SwrGetInterface"); - if (!pApiProc) { fprintf(stderr, "SWR library search failure: %s\n", util_dl_error()); exit(-1); } + pfnSwrGetInterface = (PFNSwrGetInterface)pApiProc; +#endif + struct pipe_screen *screen = swr_create_screen_internal(winsys); - swr_screen(screen)->pfnSwrGetInterface = (PFNSwrGetInterface)pApiProc; swr_screen(screen)->is_knl = is_knl; + swr_screen(screen)->pfnSwrGetInterface = pfnSwrGetInterface; return screen; } |