From d80c5a7c7134859adf87579e7139e86c9e83c1b0 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Sun, 7 Aug 2022 15:31:33 +0800 Subject: [PATCH] util: Handling GALLIUM_NOSSE in u_cpu_detect.c Signed-off-by: Yonggang Luo Reviewed-by: Alyssa Rosenzweig Reviewed-by: Jose Fonseca Part-of: --- src/gallium/auxiliary/meson.build | 2 - src/gallium/auxiliary/rtasm/rtasm_cpu.c | 55 ------------------- src/gallium/auxiliary/rtasm/rtasm_cpu.h | 40 -------------- .../auxiliary/translate/translate_sse.c | 5 +- src/gallium/tests/unit/translate_test.c | 9 ++- src/util/u_cpu_detect.c | 3 + 6 files changed, 9 insertions(+), 105 deletions(-) delete mode 100644 src/gallium/auxiliary/rtasm/rtasm_cpu.c delete mode 100644 src/gallium/auxiliary/rtasm/rtasm_cpu.h diff --git a/src/gallium/auxiliary/meson.build b/src/gallium/auxiliary/meson.build index 184e1c87f34..437b98e6b2c 100644 --- a/src/gallium/auxiliary/meson.build +++ b/src/gallium/auxiliary/meson.build @@ -166,8 +166,6 @@ files_libgallium = files( 'rbug/rbug_shader.h', 'rbug/rbug_texture.c', 'rbug/rbug_texture.h', - 'rtasm/rtasm_cpu.c', - 'rtasm/rtasm_cpu.h', 'rtasm/rtasm_execmem.c', 'rtasm/rtasm_execmem.h', 'rtasm/rtasm_x86sse.c', diff --git a/src/gallium/auxiliary/rtasm/rtasm_cpu.c b/src/gallium/auxiliary/rtasm/rtasm_cpu.c deleted file mode 100644 index d1af30f06ad..00000000000 --- a/src/gallium/auxiliary/rtasm/rtasm_cpu.c +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "pipe/p_config.h" -#include "rtasm_cpu.h" - -#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) - -#include "util/u_debug.h" -#include "util/u_cpu_detect.h" - -DEBUG_GET_ONCE_BOOL_OPTION(nosse, "GALLIUM_NOSSE", false); - -static const struct util_cpu_caps_t *get_cpu_caps(void) -{ - return util_get_cpu_caps(); -} - -int rtasm_cpu_has_sse(void) -{ - return !debug_get_option_nosse() && get_cpu_caps()->has_sse; -} - -#else - -int rtasm_cpu_has_sse(void) -{ - return 0; -} - -#endif diff --git a/src/gallium/auxiliary/rtasm/rtasm_cpu.h b/src/gallium/auxiliary/rtasm/rtasm_cpu.h deleted file mode 100644 index cfce8f7d45d..00000000000 --- a/src/gallium/auxiliary/rtasm/rtasm_cpu.h +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/** - * @file - * Runtime detection of CPU capabilities. - */ - -#ifndef _RTASM_CPU_H_ -#define _RTASM_CPU_H_ - - -int rtasm_cpu_has_sse(void); - - -#endif /* _RTASM_CPU_H_ */ diff --git a/src/gallium/auxiliary/translate/translate_sse.c b/src/gallium/auxiliary/translate/translate_sse.c index 0ab79e4a361..582bce16178 100644 --- a/src/gallium/auxiliary/translate/translate_sse.c +++ b/src/gallium/auxiliary/translate/translate_sse.c @@ -29,6 +29,7 @@ #include "pipe/p_config.h" #include "pipe/p_compiler.h" #include "util/u_memory.h" +#include "util/u_cpu_detect.h" #include "util/u_math.h" #include "util/format/u_format.h" @@ -37,7 +38,6 @@ #if (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)) && !defined(EMBEDDED_DEVICE) -#include "rtasm/rtasm_cpu.h" #include "rtasm/rtasm_x86sse.h" @@ -1509,8 +1509,7 @@ translate_sse2_create(const struct translate_key *key) struct translate_sse *p = NULL; unsigned i; - /* this is misnamed, it actually refers to whether rtasm is enabled or not */ - if (!rtasm_cpu_has_sse()) + if (!util_get_cpu_caps()->has_sse) goto fail; p = os_malloc_aligned(sizeof(struct translate_sse), 16); diff --git a/src/gallium/tests/unit/translate_test.c b/src/gallium/tests/unit/translate_test.c index 215136b423e..8b320efbdb6 100644 --- a/src/gallium/tests/unit/translate_test.c +++ b/src/gallium/tests/unit/translate_test.c @@ -29,7 +29,6 @@ #include "util/format/u_format.h" #include "util/half_float.h" #include "util/u_cpu_detect.h" -#include "rtasm/rtasm_cpu.h" /* don't use this for serious use */ static double rand_double() @@ -86,7 +85,7 @@ int main(int argc, char** argv) } else if (!strcmp(argv[1], "sse")) { - if(!util_get_cpu_caps()->has_sse || !rtasm_cpu_has_sse()) + if(!util_get_cpu_caps()->has_sse) { printf("Error: CPU doesn't support SSE (test with qemu)\n"); return 2; @@ -98,7 +97,7 @@ int main(int argc, char** argv) } else if (!strcmp(argv[1], "sse2")) { - if(!util_get_cpu_caps()->has_sse2 || !rtasm_cpu_has_sse()) + if(!util_get_cpu_caps()->has_sse2) { printf("Error: CPU doesn't support SSE2 (test with qemu)\n"); return 2; @@ -109,7 +108,7 @@ int main(int argc, char** argv) } else if (!strcmp(argv[1], "sse3")) { - if(!util_get_cpu_caps()->has_sse3 || !rtasm_cpu_has_sse()) + if(!util_get_cpu_caps()->has_sse3) { printf("Error: CPU doesn't support SSE3 (test with qemu)\n"); return 2; @@ -119,7 +118,7 @@ int main(int argc, char** argv) } else if (!strcmp(argv[1], "sse4.1")) { - if(!util_get_cpu_caps()->has_sse4_1 || !rtasm_cpu_has_sse()) + if(!util_get_cpu_caps()->has_sse4_1) { printf("Error: CPU doesn't support SSE4.1 (test with qemu)\n"); return 2; diff --git a/src/util/u_cpu_detect.c b/src/util/u_cpu_detect.c index 9e6ac9d0a59..1bd78bace1d 100644 --- a/src/util/u_cpu_detect.c +++ b/src/util/u_cpu_detect.c @@ -794,6 +794,9 @@ util_cpu_detect_once(void) util_cpu_caps.cacheline = cacheline; } } + if (debug_get_bool_option("GALLIUM_NOSSE", false)) { + util_cpu_caps.has_sse = 0; + } #endif /* PIPE_ARCH_X86 || PIPE_ARCH_X86_64 */ #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)