forked from card-io/card.io-dmz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
processor_support.h
68 lines (60 loc) · 2.18 KB
/
processor_support.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// See the file "LICENSE.md" for the full license governing this code.
#ifndef PROCESSOR_SUPPORT_H
#define PROCESSOR_SUPPORT_H
#include "mz.h"
#include "dmz_macros.h"
//
// Wraps client-specific processor support checks
//
// To check for compiletime support, use #if DMZ_HAS_NEON_COMPILETIME.
// To check for runtime support (presence of actual coprocessor), use dmz_has_neon_runtime().
// A normal pattern for NEON usage is:
//
// if(dmz_has_neon_runtime()) {
// #if DMZ_HAS_NEON_COMPILETIME
// // NEON implementation
// #endif
// } else {
// // Scalar implementation
// }
//
// Enable simple compiletime checks for NEON support
#if IOS_DMZ
// ********************************* arm64 NOTE *********************************
// Currently DMZ_HAS_NEON_COMPILETIME is disabled for the arm64 architecture.
// To avoid compiler warnings, the `-mfloat-abi=softfp -mfpu=neon` compiler flags
// have been removed from our arm64 builds for libCardIO (in Build Settings).
// So if you enable DMZ_HAS_NEON_COMPILETIME for arm64 builds, then you will
// also need to restore those compiler flags for arm64.
// ********************************* arm64 NOTE *********************************
#ifdef _ARM_ARCH_7
#define DMZ_HAS_NEON_COMPILETIME 1
#else
#define DMZ_HAS_NEON_COMPILETIME 0
#endif
#elif CYTHON_DMZ
#define DMZ_HAS_NEON_COMPILETIME 0
#elif ANDROID_DMZ
#if ANDROID_HAS_NEON
#define DMZ_HAS_NEON_COMPILETIME 1
#else
#define DMZ_HAS_NEON_COMPILETIME 0
#endif
#ifndef ANDROID_USE_GLES_WARP
#define ANDROID_USE_GLES_WARP 0
#endif
#else
#error "Encountered unknown dmz client. Make sure the right *_DMZ preprocessor macro is set."
#endif
/* For Android ARMv7a architectures:
* gcc -mfpu=neon <=> DMZ_HAS_NEON_COMPILETME
* else:
* gcc -mfpu=vfpv3-d16 <=> limit to 16 VFP registers (normally 32)
*/
extern int dmz_has_neon_runtime(void);
extern int dmz_use_vfp3_16(void);
// Should we use OpenGL ES to do perspective (un)warping?
extern int dmz_use_gles_warp(void);
// Used to set fallback - Set to 0 if a GL error occurs or if the OS knows that OpenGL is not supported.
extern void dmz_set_gles_warp(int newstate);
#endif // PROCESSOR_SUPPORT_H