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 version(BindSDL_Static) { 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 } 44 } 45 else { 46 extern(C) @nogc nothrow { 47 alias pSDL_GetCPUCount = int function(); 48 alias pSDL_GetCPUCacheLineSize = int function(); 49 alias pSDL_HasRDTSC = SDL_bool function(); 50 alias pSDL_HasAltiVec = SDL_bool function(); 51 alias pSDL_HasMMX = SDL_bool function(); 52 alias pSDL_Has3DNow = SDL_bool function(); 53 alias pSDL_HasSSE = SDL_bool function(); 54 alias pSDL_HasSSE2 = SDL_bool function(); 55 alias pSDL_HasSSE3 = SDL_bool function(); 56 alias pSDL_HasSSE41 = SDL_bool function(); 57 alias pSDL_HasSSE42 = SDL_bool function(); 58 } 59 60 __gshared { 61 pSDL_GetCPUCount SDL_GetCPUCount; 62 pSDL_GetCPUCacheLineSize SDL_GetCPUCacheLineSize; 63 pSDL_HasRDTSC SDL_HasRDTSC; 64 pSDL_HasAltiVec SDL_HasAltiVec; 65 pSDL_HasMMX SDL_HasMMX; 66 pSDL_Has3DNow SDL_Has3DNow; 67 pSDL_HasSSE SDL_HasSSE; 68 pSDL_HasSSE2 SDL_HasSSE2; 69 pSDL_HasSSE3 SDL_HasSSE3; 70 pSDL_HasSSE41 SDL_HasSSE41; 71 pSDL_HasSSE42 SDL_HasSSE42; 72 } 73 74 static if(sdlSupport >= SDLSupport.sdl201) { 75 extern(C) @nogc nothrow { 76 alias pSDL_GetSystemRAM = int function(); 77 } 78 79 __gshared { 80 pSDL_GetSystemRAM SDL_GetSystemRAM; 81 } 82 } 83 84 static if(sdlSupport >= SDLSupport.sdl202) { 85 extern(C) @nogc nothrow { 86 alias pSDL_HasAVX = SDL_bool function(); 87 } 88 89 __gshared { 90 pSDL_HasAVX SDL_HasAVX; 91 } 92 } 93 94 static if(sdlSupport >= SDLSupport.sdl204) { 95 extern(C) @nogc nothrow { 96 alias pSDL_HasAVX2 = SDL_bool function(); 97 } 98 99 __gshared { 100 pSDL_HasAVX2 SDL_HasAVX2; 101 } 102 } 103 104 static if(sdlSupport >= SDLSupport.sdl206) { 105 extern(C) @nogc nothrow { 106 alias pSDL_HasAVX512F = SDL_bool function(); 107 } 108 109 __gshared { 110 pSDL_HasAVX512F SDL_HasAVX512F; 111 } 112 } 113 114 static if(sdlSupport >= SDLSupport.sdl209) { 115 extern(C) @nogc nothrow { 116 alias pSDL_HasAVX512F = SDL_bool function(); 117 } 118 119 __gshared { 120 pSDL_HasAVX512F SDL_HasAVX512F; 121 } 122 } 123 }