1 2 // Copyright Michael D. Parker 2018. 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)); 46 void SDL_SIMDFree(void*); 47 } 48 static if(sdlSupport >= SDLSupport.sdl2012) { 49 SDL_bool SDL_HasARMSIMD(); 50 } 51 } 52 } 53 else { 54 extern(C) @nogc nothrow { 55 alias pSDL_GetCPUCount = int function(); 56 alias pSDL_GetCPUCacheLineSize = int function(); 57 alias pSDL_HasRDTSC = SDL_bool function(); 58 alias pSDL_HasAltiVec = SDL_bool function(); 59 alias pSDL_HasMMX = SDL_bool function(); 60 alias pSDL_Has3DNow = SDL_bool function(); 61 alias pSDL_HasSSE = SDL_bool function(); 62 alias pSDL_HasSSE2 = SDL_bool function(); 63 alias pSDL_HasSSE3 = SDL_bool function(); 64 alias pSDL_HasSSE41 = SDL_bool function(); 65 alias pSDL_HasSSE42 = SDL_bool function(); 66 } 67 68 __gshared { 69 pSDL_GetCPUCount SDL_GetCPUCount; 70 pSDL_GetCPUCacheLineSize SDL_GetCPUCacheLineSize; 71 pSDL_HasRDTSC SDL_HasRDTSC; 72 pSDL_HasAltiVec SDL_HasAltiVec; 73 pSDL_HasMMX SDL_HasMMX; 74 pSDL_Has3DNow SDL_Has3DNow; 75 pSDL_HasSSE SDL_HasSSE; 76 pSDL_HasSSE2 SDL_HasSSE2; 77 pSDL_HasSSE3 SDL_HasSSE3; 78 pSDL_HasSSE41 SDL_HasSSE41; 79 pSDL_HasSSE42 SDL_HasSSE42; 80 } 81 static if(sdlSupport >= SDLSupport.sdl201) { 82 extern(C) @nogc nothrow { 83 alias pSDL_GetSystemRAM = int function(); 84 } 85 __gshared { 86 pSDL_GetSystemRAM SDL_GetSystemRAM; 87 } 88 } 89 static if(sdlSupport >= SDLSupport.sdl202) { 90 extern(C) @nogc nothrow { 91 alias pSDL_HasAVX = SDL_bool function(); 92 } 93 __gshared { 94 pSDL_HasAVX SDL_HasAVX; 95 } 96 } 97 static if(sdlSupport >= SDLSupport.sdl204) { 98 extern(C) @nogc nothrow { 99 alias pSDL_HasAVX2 = SDL_bool function(); 100 } 101 __gshared { 102 pSDL_HasAVX2 SDL_HasAVX2; 103 } 104 } 105 static if(sdlSupport >= SDLSupport.sdl206) { 106 extern(C) @nogc nothrow { 107 alias pSDL_HasNEON = SDL_bool function(); 108 } 109 __gshared { 110 pSDL_HasNEON SDL_HasNEON; 111 } 112 } 113 static if(sdlSupport >= SDLSupport.sdl209) { 114 extern(C) @nogc nothrow { 115 alias pSDL_HasAVX512F = SDL_bool function(); 116 } 117 __gshared { 118 pSDL_HasAVX512F SDL_HasAVX512F; 119 } 120 } 121 static if(sdlSupport >= SDLSupport.sdl2010) { 122 extern(C) @nogc nothrow { 123 alias pSDL_SIMDGetAlignment = size_t function(); 124 alias pSDL_SIMDAlloc = void* function(const(size_t)); 125 alias pSDL_SIMDFree = void function(void*); 126 } 127 __gshared { 128 pSDL_SIMDGetAlignment SDL_SIMDGetAlignment; 129 pSDL_SIMDAlloc SDL_SIMDAlloc; 130 pSDL_SIMDFree SDL_SIMDFree; 131 } 132 } 133 static if(sdlSupport >= SDLSupport.sdl2012) { 134 extern(C) @nogc nothrow { 135 alias pSDL_HasARMSIMD = SDL_bool function(); 136 } 137 __gshared { 138 pSDL_HasARMSIMD SDL_HasARMSIMD; 139 } 140 141 } 142 }