~melchizedek6809/WolkenWelten

ref: e910bd82e598d6f560b8899dd1d88fb3ed554cd3 WolkenWelten/common/src/asm/asm.c -rw-r--r-- 2.1 KiB
e910bd82Ben (X13/Arch) Updated contact info 11 months ago
                                                                                
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include "asm.h"

int asmRoutineSupport = 0;

#if defined(__arm__) || defined(__aarch64__)
	#define ASM_USE_NEON
#endif

#if defined(__x86_64__)
	#define ASM_USE_SSE
	#define ASM_USE_AVX
#endif

/* MacOS has issues because it doesn't include GAS, and Haiku doesn't work with ASMfor now */
#if defined(__APPLE__) || defined(__HAIKU__)
	#undef ASM_USE_SSE
	#undef ASM_USE_AVX
#endif

void asmDetermineSupport(){
	asmRoutineSupport = 1;
#ifdef ASM_USE_SSE
	if(__builtin_cpu_supports ("sse")){asmRoutineSupport = 2;}
#endif
#ifdef ASM_USE_AVX
	if(__builtin_cpu_supports ("avx")){asmRoutineSupport = 3;}
#endif
#ifdef ASM_USE_NEON
	/* Current ARM chips without Neon will have trouble running the game anyways */
	asmRoutineSupport = 4;
#endif
}

#ifdef ASM_USE_NEON
	void      rainPosUpdateNEON();
	void  particlePosUpdateNEON();
	void sparticlePosUpdateNEON();
#endif

#ifdef ASM_USE_SSE
	void      rainPosUpdateSSE();
	void  particlePosUpdateSSE();
	void sparticlePosUpdateSSE();
#endif

#ifdef ASM_USE_AVX
	void      rainPosUpdateAVX();
	void  particlePosUpdateAVX();
	void sparticlePosUpdateAVX();
#endif

void particlePosUpdate(){
	switch(asmRoutineSupport){
	case 0:
	case 1:
	default:
		particlePosUpdatePortable();
		break;
#ifdef ASM_USE_SSE
	case 2:
		particlePosUpdateSSE();
		break;
#endif
#ifdef ASM_USE_AVX
	case 3:
		particlePosUpdateAVX();
		break;
#endif
#ifdef ASM_USE_NEON
	case 4:
		particlePosUpdateNEON();
		break;
#endif
	}
}

void sparticlePosUpdate(){
	switch(asmRoutineSupport){
	case 0:
	case 1:
	default:
		sparticlePosUpdatePortable();
		break;
#ifdef ASM_USE_SSE
	case 2:
		sparticlePosUpdateSSE();
		break;
#endif
#ifdef ASM_USE_AVX
	case 3:
		sparticlePosUpdateAVX();
		break;
#endif
#ifdef ASM_USE_NEON
	case 4:
		sparticlePosUpdateNEON();
		break;
#endif
	}
}

void rainPosUpdate(){
	switch(asmRoutineSupport){
	case 0:
	case 1:
	default:
		rainPosUpdatePortable();
		break;
#ifdef ASM_USE_SSE
	case 2:
		rainPosUpdateSSE();
		break;
#endif
#ifdef ASM_USE_AVX
	case 3:
		rainPosUpdateAVX();
		break;
#endif
#ifdef ASM_USE_NEON
	case 4:
		rainPosUpdateNEON();
		break;
#endif
	}
}