util: Handling GALLIUM_NOSSE in u_cpu_detect.c

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17803>
This commit is contained in:
Yonggang Luo
2022-08-07 15:31:33 +08:00
committed by Marge Bot
parent e8ac138c83
commit d80c5a7c71
6 changed files with 9 additions and 105 deletions

View File

@@ -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',

View File

@@ -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

View File

@@ -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_ */

View File

@@ -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);

View File

@@ -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;

View File

@@ -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)