[Mesa-dev] Mesa (master): mesa/x86: Support SSE 4.1 detection on x86-64.

Jose Fonseca jfonseca at vmware.com
Thu May 22 14:39:18 PDT 2014



----- Original Message -----
> On Thu, May 22, 2014 at 12:30 PM, Jose Fonseca <jfonseca at vmware.com> wrote:
> >
> >
> > ----- Original Message -----
> >> Module: Mesa
> >> Branch: master
> >> Commit: 8b9302f2b4b0536abb91cb73682ec13640fe9eaf
> >> URL:
> >> https://urldefense.proofpoint.com/v1/url?u=http://cgit.freedesktop.org/mesa/mesa/commit/?id%3D8b9302f2b4b0536abb91cb73682ec13640fe9eaf&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=NMr9uy2iTjWVixC0wOcYCWEIYhfo80qKwRgdodpoDzA%3D%0A&m=AHdyjIRaIN8X%2FncnNP4l%2F2q0EVpdwrRXXlwYLuND8t0%3D%0A&s=ea1ec7f75f3ac94752601b896023c1f6f1d82af5cda565f7be3ea404c9b70866
> >>
> >> Author: Matt Turner <mattst88 at gmail.com>
> >> Date:   Fri May  2 12:10:17 2014 -0700
> >>
> >> mesa/x86: Support SSE 4.1 detection on x86-64.
> >>
> >> Uses the cpuid.h header provided by gcc and clang. Other platforms are
> >> encouraged to switch.
> >>
> >> ---
> >>
> >>  src/mesa/main/cpuinfo.c   |    2 +-
> >>  src/mesa/main/cpuinfo.h   |    2 +-
> >>  src/mesa/x86/common_x86.c |   11 +++++++++++
> >>  3 files changed, 13 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/src/mesa/main/cpuinfo.c b/src/mesa/main/cpuinfo.c
> >> index 8d482a6..73e295c 100644
> >> --- a/src/mesa/main/cpuinfo.c
> >> +++ b/src/mesa/main/cpuinfo.c
> >> @@ -34,7 +34,7 @@
> >>  void
> >>  _mesa_get_cpu_features(void)
> >>  {
> >> -#ifdef USE_X86_ASM
> >> +#if defined USE_X86_ASM || (defined __x86_64__ && !defined _MSC_VER)
> >>     _mesa_get_x86_features();
> >>  #endif
> >
> > This broke several build types because it assumes that assembly is always
> > used on 64 bits except MSVC, which is not true.  Windows builds are not
> > using assembly neither.
> >
> > I think that `(defined __x86_64__ && !defined _MSC_VER)` should be replaced
> > with `defined USE_X86_64_ASM` . After all that's why we have the USE_*_ASM
> > defines -- so that C code doesn't need to guess (and miserably) if/when
> > assembly is being used.
> >
> > I'll draft a patch.
> >
> > Jose
> 
> Interesting. I was worried about breaking MSVC, since I don't think it
> has a compatible cpuid.h header. We might consider renaming the
> USE_*_ASM macros. The code I was enabling here is written using _mm_*
> intrinsics, available on all x86 compilers as far as I'm aware, and
> not assembly.

> The CPU feature detection code doesn't need any assembly
> in Mesa either

Right.  We have *.s and intrisics. *.s is gcc only. But x86 instrinsics are more portable.  And we might indeed want to make USE_*_ASM more fine grained, but ATM it is enough.

jose


More information about the mesa-dev mailing list