1 
2 //          Copyright 2018 - 2021 Michael D. Parker
3 // Distributed under the Boost Software License, Version 1.0.
4 //    (See accompanying file LICENSE_1_0.txt or copy at
5 //          http://www.boost.org/LICENSE_1_0.txt)
6 
7 module bindbc.sdl.bind.sdlcpuinfo;
8 
9 import bindbc.sdl.config;
10 import bindbc.sdl.bind.sdlstdinc : SDL_bool;
11 
12 enum  SDL_CACHELINE_SIZE = 128;
13 
14 static if(staticBinding) {
15     extern(C) @nogc nothrow {
16         int SDL_GetCPUCount();
17         int SDL_GetCPUCacheLineSize();
18         SDL_bool SDL_HasRDTSC();
19         SDL_bool SDL_HasAltiVec();
20         SDL_bool SDL_HasMMX();
21         SDL_bool SDL_Has3DNow();
22         SDL_bool SDL_HasSSE();
23         SDL_bool SDL_HasSSE2();
24         SDL_bool SDL_HasSSE3();
25         SDL_bool SDL_HasSSE41();
26         SDL_bool SDL_HasSSE42();
27 
28         static if(sdlSupport >= SDLSupport.sdl201) {
29             int SDL_GetSystemRAM();
30         }
31         static if(sdlSupport >= SDLSupport.sdl202) {
32             SDL_bool SDL_HasAVX();
33         }
34         static if(sdlSupport >= SDLSupport.sdl204) {
35             SDL_bool SDL_HasAVX2();
36         }
37         static if(sdlSupport >= SDLSupport.sdl206) {
38             SDL_bool SDL_HasNEON();
39         }
40         static if(sdlSupport >= SDLSupport.sdl209) {
41             SDL_bool SDL_HasAVX512F();
42         }
43         static if(sdlSupport >= SDLSupport.sdl2010) {
44             size_t SDL_SIMDGetAlignment();
45             void* SDL_SIMDAlloc(const(size_t) len);
46             void SDL_SIMDFree(void*);
47         }
48         static if(sdlSupport >= SDLSupport.sdl2012) {
49             SDL_bool SDL_HasARMSIMD();
50         }
51         static if(sdlSupport >= SDLSupport.sdl2014) {
52             void* SDL_SIMDRealloc(void* mem, const(size_t) len);
53         }
54     }
55 }
56 else {
57     extern(C) @nogc nothrow {
58         alias pSDL_GetCPUCount = int function();
59         alias pSDL_GetCPUCacheLineSize = int function();
60         alias pSDL_HasRDTSC = SDL_bool function();
61         alias pSDL_HasAltiVec = SDL_bool function();
62         alias pSDL_HasMMX = SDL_bool function();
63         alias pSDL_Has3DNow = SDL_bool function();
64         alias pSDL_HasSSE = SDL_bool function();
65         alias pSDL_HasSSE2 = SDL_bool function();
66         alias pSDL_HasSSE3 = SDL_bool function();
67         alias pSDL_HasSSE41 = SDL_bool function();
68         alias pSDL_HasSSE42 = SDL_bool function();
69     }
70 
71     __gshared {
72         pSDL_GetCPUCount SDL_GetCPUCount;
73         pSDL_GetCPUCacheLineSize SDL_GetCPUCacheLineSize;
74         pSDL_HasRDTSC SDL_HasRDTSC;
75         pSDL_HasAltiVec SDL_HasAltiVec;
76         pSDL_HasMMX SDL_HasMMX;
77         pSDL_Has3DNow SDL_Has3DNow;
78         pSDL_HasSSE SDL_HasSSE;
79         pSDL_HasSSE2 SDL_HasSSE2;
80         pSDL_HasSSE3 SDL_HasSSE3;
81         pSDL_HasSSE41 SDL_HasSSE41;
82         pSDL_HasSSE42 SDL_HasSSE42;
83     }
84     static if(sdlSupport >= SDLSupport.sdl201) {
85         extern(C) @nogc nothrow {
86             alias pSDL_GetSystemRAM = int function();
87         }
88         __gshared {
89             pSDL_GetSystemRAM SDL_GetSystemRAM;
90         }
91     }
92     static if(sdlSupport >= SDLSupport.sdl202) {
93         extern(C) @nogc nothrow {
94             alias pSDL_HasAVX = SDL_bool function();
95         }
96         __gshared {
97             pSDL_HasAVX SDL_HasAVX;
98         }
99     }
100     static if(sdlSupport >= SDLSupport.sdl204) {
101         extern(C) @nogc nothrow {
102             alias pSDL_HasAVX2 = SDL_bool function();
103         }
104         __gshared {
105             pSDL_HasAVX2 SDL_HasAVX2;
106         }
107     }
108     static if(sdlSupport >= SDLSupport.sdl206) {
109         extern(C) @nogc nothrow {
110             alias pSDL_HasNEON = SDL_bool function();
111         }
112         __gshared {
113             pSDL_HasNEON SDL_HasNEON;
114         }
115     }
116     static if(sdlSupport >= SDLSupport.sdl209) {
117         extern(C) @nogc nothrow {
118             alias pSDL_HasAVX512F = SDL_bool function();
119         }
120         __gshared {
121             pSDL_HasAVX512F SDL_HasAVX512F;
122         }
123     }
124     static if(sdlSupport >= SDLSupport.sdl2010) {
125         extern(C) @nogc nothrow {
126             alias pSDL_SIMDGetAlignment = size_t function();
127             alias pSDL_SIMDAlloc = void* function(const(size_t) len);
128             alias pSDL_SIMDFree = void function(void* ptr);
129         }
130         __gshared {
131             pSDL_SIMDGetAlignment SDL_SIMDGetAlignment;
132             pSDL_SIMDAlloc SDL_SIMDAlloc;
133             pSDL_SIMDFree SDL_SIMDFree;
134         }
135     }
136     static if(sdlSupport >= SDLSupport.sdl2012) {
137         extern(C) @nogc nothrow {
138             alias pSDL_HasARMSIMD = SDL_bool function();
139         }
140         __gshared {
141             pSDL_HasARMSIMD SDL_HasARMSIMD;
142         }
143 
144     }
145     static if(sdlSupport >= SDLSupport.sdl2014) {
146         extern(C) @nogc nothrow {
147             alias pSDL_SIMDRealloc = void* function(void* mem, const(size_t) len);
148         }
149         __gshared {
150             pSDL_SIMDRealloc SDL_SIMDRealloc;
151         }
152     }
153 }