mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
cogl/cpu-caps: Build cpuid and xgetbv only for x86_64
This also adds the cpuid functionality inline and checks for GCC ASM
flag output support.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3226
Fixes: 3bf6de60b
("cogl: Add CPU capability detection helper")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3488>
This commit is contained in:
parent
7f1b890df1
commit
985e93f9fa
@ -39,10 +39,11 @@
|
||||
|
||||
CoglCpuCaps cogl_cpu_caps;
|
||||
|
||||
#ifdef __x86_64
|
||||
static inline uint64_t
|
||||
xgetbv (void)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
#ifdef __GCC_ASM_FLAG_OUTPUTS__
|
||||
uint32_t eax, edx;
|
||||
|
||||
__asm __volatile (
|
||||
@ -58,10 +59,32 @@ xgetbv (void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void
|
||||
cpuid (uint32_t ax,
|
||||
uint32_t *p)
|
||||
{
|
||||
#ifdef __GCC_ASM_FLAG_OUTPUTS__
|
||||
__asm __volatile (
|
||||
"cpuid\n\t"
|
||||
: "=a" (p[0]),
|
||||
"=b" (p[1]),
|
||||
"=c" (p[2]),
|
||||
"=d" (p[3])
|
||||
: "0" (ax)
|
||||
);
|
||||
#else
|
||||
p[0] = 0;
|
||||
p[1] = 0;
|
||||
p[2] = 0;
|
||||
p[3] = 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
cogl_init_cpu_caps (void)
|
||||
{
|
||||
#ifdef HAVE_CPUID
|
||||
#ifdef __x86_64
|
||||
uint32_t regs[4];
|
||||
|
||||
cpuid (0x00000000, regs);
|
||||
@ -77,7 +100,7 @@ cogl_init_cpu_caps (void)
|
||||
((regs2[2] >> 27) & 1) && /* OSXSAVE */
|
||||
((xgetbv () & 6) == 6)); /* XMM & YMM */
|
||||
if (((regs2[2] >> 29) & 1) && has_avx)
|
||||
cpu_caps |= COGL_CPU_CAP_F16C;
|
||||
cogl_cpu_caps |= COGL_CPU_CAP_F16C;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user