mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-09-19 13:30:02 +00:00
Add an option to disable F16C
And add a compile time check for the presence of this CPU feature.
This commit is contained in:
parent
38c6fe2ce4
commit
9d81c129fc
@ -279,3 +279,5 @@
|
||||
|
||||
/* Define if tracker3 is available */
|
||||
#mesondefine HAVE_TRACKER3
|
||||
|
||||
#mesondefine HAVE_F16C
|
||||
|
@ -221,7 +221,6 @@ libgsk = static_library('gsk',
|
||||
'-DGTK_COMPILATION',
|
||||
'-DG_LOG_DOMAIN="Gsk"',
|
||||
'-DG_LOG_STRUCTURED=1',
|
||||
'-mf16c'
|
||||
] + common_cflags,
|
||||
link_with: libgdk,
|
||||
)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* ninesliceprivate.h
|
||||
/* fp16private.h
|
||||
*
|
||||
* Copyright 2021 Red Hat, Inc.
|
||||
*
|
||||
@ -21,10 +21,11 @@
|
||||
#ifndef __FP16_PRIVATE_H__
|
||||
#define __FP16_PRIVATE_H__
|
||||
|
||||
#include <config.h>
|
||||
#include <glib.h>
|
||||
#include <graphene.h>
|
||||
|
||||
#ifdef GRAPHENE_USE_SSE
|
||||
#ifdef HAVE_F16C
|
||||
#include <immintrin.h>
|
||||
#endif
|
||||
|
||||
@ -34,7 +35,7 @@ G_BEGIN_DECLS
|
||||
#define FP16_ONE ((guint16)15360)
|
||||
#define FP16_MINUS_ONE ((guint16)48128)
|
||||
|
||||
#ifdef GRAPHENE_USE_SSE
|
||||
#ifdef HAVE_F16C
|
||||
|
||||
static inline void
|
||||
float_to_half4 (const float f[4],
|
||||
@ -54,7 +55,7 @@ half_to_float4 (const guint16 h[4],
|
||||
_mm_store_ps (f, s);
|
||||
}
|
||||
|
||||
#else /* GRAPHENE_USE_SSE */
|
||||
#else /* GTK_HAS_F16C */
|
||||
|
||||
static inline guint
|
||||
as_uint (const float x)
|
||||
@ -108,7 +109,7 @@ half_to_float4 (const guint16 h[4],
|
||||
f[3] = half_to_float (h[3]);
|
||||
}
|
||||
|
||||
#endif /* GRAPHENE_USE_SSE */
|
||||
#endif /* HAVE_F16C */
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
36
meson.build
36
meson.build
@ -685,6 +685,42 @@ if graphene_has_sse2 or graphene_has_gcc
|
||||
endif
|
||||
endif
|
||||
|
||||
f16c_cflags = []
|
||||
if get_option('f16c').enabled()
|
||||
f16c_prog = '''
|
||||
#if defined(__GNUC__)
|
||||
# if !defined(__amd64__) && !defined(__x86_64__)
|
||||
# error "F16C intrinsics are only available on x86_64"
|
||||
# endif
|
||||
#elif defined (_MSC_VER) && !defined (_M_X64) && !defined (_M_AMD64)
|
||||
# error "F16C intrinsics not supported on x86 MSVC builds"
|
||||
#endif
|
||||
#if defined(__SSE__) || (_M_X64 > 0)
|
||||
# include <immintrin.h>
|
||||
#else
|
||||
# error "No F16C intrinsics available"
|
||||
#endif
|
||||
int main () {
|
||||
float f[4] = { 0, };
|
||||
unsigned short h[4] = { 0, };
|
||||
__m128 s = _mm_loadu_ps (f);
|
||||
__m128i i = _mm_cvtps_ph (s, 0);
|
||||
_mm_storel_epi64 ((__m128i*)h, i);
|
||||
return 0;
|
||||
}'''
|
||||
if cc.get_id() != 'msvc'
|
||||
test_f16c_cflags = [ '-mf16c' ]
|
||||
else
|
||||
test_f16c_cflags = []
|
||||
endif
|
||||
|
||||
if cc.compiles(f16c_prog, args: test_f16c_cflags, name: 'F16C intrinsics')
|
||||
cdata.set('HAVE_F16C', 1)
|
||||
f16c_cflags = test_f16c_cflags
|
||||
common_cflags += test_f16c_cflags
|
||||
endif
|
||||
endif
|
||||
|
||||
subdir('gtk/css')
|
||||
subdir('gdk')
|
||||
subdir('gsk')
|
||||
|
@ -86,6 +86,11 @@ option('sassc',
|
||||
value: 'auto',
|
||||
description: 'Rebuild themes using sassc')
|
||||
|
||||
option('f16c',
|
||||
type: 'feature',
|
||||
value: 'enabled',
|
||||
description: 'Enable F16C fast paths (requires F16C)')
|
||||
|
||||
# Documentation and introspection
|
||||
|
||||
option('gtk_doc',
|
||||
|
Loading…
Reference in New Issue
Block a user