[Mesa-dev] [PATCH 1/2] gallium/rtasm: properly detect SSE and SSE2
Jose Fonseca
jfonseca at vmware.com
Fri Feb 24 10:42:27 PST 2012
This one looks good to me.
Jose
----- Original Message -----
> This should fix crashes on ancient processors.
> ---
> src/gallium/auxiliary/rtasm/rtasm_cpu.c | 48
> +++++++++++++++---------------
> 1 files changed, 24 insertions(+), 24 deletions(-)
>
> diff --git a/src/gallium/auxiliary/rtasm/rtasm_cpu.c
> b/src/gallium/auxiliary/rtasm/rtasm_cpu.c
> index 0461c81..7afcf14 100644
> --- a/src/gallium/auxiliary/rtasm/rtasm_cpu.c
> +++ b/src/gallium/auxiliary/rtasm/rtasm_cpu.c
> @@ -25,43 +25,43 @@
> *
> **************************************************************************/
>
> +#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 "rtasm_cpu.h"
> +#include "util/u_cpu_detect.h"
>
> +DEBUG_GET_ONCE_BOOL_OPTION(nosse, "GALLIUM_NOSSE", FALSE);
>
> -#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
> -static boolean rtasm_sse_enabled(void)
> +static struct util_cpu_caps *get_cpu_caps(void)
> {
> - static boolean firsttime = 1;
> - static boolean enabled;
> -
> - /* This gets called quite often at the moment:
> - */
> - if (firsttime) {
> - enabled = !debug_get_bool_option("GALLIUM_NOSSE", FALSE);
> - firsttime = FALSE;
> - }
> - return enabled;
> + util_cpu_detect();
> + return &util_cpu_caps;
> }
> -#endif
>
> int rtasm_cpu_has_sse(void)
> {
> - /* FIXME: actually detect this at run-time */
> -#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
> - return rtasm_sse_enabled();
> -#else
> - return 0;
> -#endif
> + return !debug_get_option_nosse() && get_cpu_caps()->has_sse;
> }
>
> int rtasm_cpu_has_sse2(void)
> {
> - /* FIXME: actually detect this at run-time */
> -#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
> - return rtasm_sse_enabled();
> + return !debug_get_option_nosse() && get_cpu_caps()->has_sse2;
> +}
> +
> +
> #else
> +
> +int rtasm_cpu_has_sse(void)
> +{
> return 0;
> -#endif
> }
> +
> +int rtasm_cpu_has_sse2(void)
> +{
> + return 0;
> +}
> +
> +#endif
> --
> 1.7.5.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
More information about the mesa-dev
mailing list