-
Notifications
You must be signed in to change notification settings - Fork 1
/
SystemInfo.h
260 lines (184 loc) · 8.97 KB
/
SystemInfo.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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#ifndef SYSTEMINFO_H
#define SYSTEMINFO_H
#include "Globals.h"
#include "glew/include/GL/glew.h"
#include <codecvt> //To convert wstring to string (For GPU info)
#include "SDL_opengl.h"
#include "SDL/include/SDL_version.h"
#include "SDL/include/SDL_cpuinfo.h"
#include "psapi.h"
#include "mmgr/mmgr.h"
#include "lib/gpudetect/DeviceId.h"
#define BTOGB (1073741824.0f)
#define KBTOMB 1024.0f //To GB: (1048576.0f)
#define BTOMB (1048576.0f)
namespace Engine {
class SoftwareInfo
{
private:
//Don't use this, they are just class variables, use the getters instead
mutable std::string mSoftware_CppVersion;
mutable std::string mSoftware_WindowsVersion;
mutable std::string mSoftware_SDLVersion;
private:
//Methods to check the versions for different software -- DON'T USE THEM!
const std::string ExtractCppVersion(long int cppValue);
const std::string ExtractWindowsVersion();
const std::string ExtractSDLVersion();
public:
void DetectSystemProperties(); //DON'T USE THIS FUNCTION, IS JUST FOR CLASS PURPOSES!!!
//Methods to return the different values for software versions... Ready to print -- Use them :)
const std::string GetWindowsVersion() const { return mSoftware_WindowsVersion; }
const std::string OsFoundString() const { return (__STDC_HOSTED__ ? "OS Found" : "OS NOT FOUND!"); }
const std::string GetSDLVersion() const { return mSoftware_SDLVersion; }
/*const auto GetOGLVersion() const { return glGetString(GL_VERSION); }
const auto GetOGLShadingVersion() const { return glGetString(GL_SHADING_LANGUAGE_VERSION); }*/
///__cplusplus returning values:
///199711L (C++98 or C++03)
///201103L (C++11)
///201402L (C++14)
///201703L (C++17)
const std::string GetCppVersionImplementedByCompiler() const { return mSoftware_CppVersion; }
const std::string GetCPPNumericalVersion() const { return std::to_string(__cplusplus); }
const std::string GetCppCompilerVersion();
const std::string GetVSCompilerVersion() const { return (std::to_string(_MSC_VER)); }
const std::string MultithreadedSpecified() const { return std::string((_MT ? "" : "Not ")) + " Multithreaded Specified"; }
const std::string GetCompilationDate() const { return __DATE__; }
const std::string GetCompilationTime() const { return __TIME__; }
};
//______________________________________________________________________________________
class MemoryHardware
{
private:
mutable MEMORYSTATUSEX m_MemoryInfo;
mutable PROCESS_MEMORY_COUNTERS m_ProcessMemCounters;
mutable SIZE_T mProcess_vMemUsed;
mutable SIZE_T mProcess_physMemUsed;
void ExtractMemoryInfo() const;
public:
void DetectSystemProperties(); //DON'T USE THIS FUNCTION, IS JUST FOR CLASS PURPOSES!!!
//void RecalculateRAMParameters() { ExtractMemoryInfo(); m_MemoryInfo_StatsFromMMRG = m_getMemoryStatistics(); }
void RecalculateRAMParameters();
const float GetRAMSizeFromSDL() const { return (float)SDL_GetSystemRAM() / KBTOMB; } //In GB
//Getting Stats of Memory from MEMORYSTATUSEX
const uint32 GetRAMSize() const { return (uint32)m_MemoryInfo.dwLength; } //In GB
const uint32 GetPercentageOfMemoryLoad() const { return (uint32)m_MemoryInfo.dwMemoryLoad; } //In %
const uint64 GetPhysicalMemory() const { return (uint64)m_MemoryInfo.ullTotalPhys / BTOGB; } //In GB
const uint64 GetFreePhysicalMemory() const { return (uint64)m_MemoryInfo.ullAvailPhys / BTOGB; } //In GB
const uint64 GetUsedPhysicalMemory() const { return (uint64)((m_MemoryInfo.ullTotalPhys - m_MemoryInfo.ullAvailPhys) / BTOGB); } //In GB
const uint64 GetVirtualMemory() const { return (uint64)m_MemoryInfo.ullTotalVirtual / BTOGB; } //In GB
const uint64 GetFreeVirtualMemory() const { return (uint64)m_MemoryInfo.ullAvailVirtual / BTOGB; } //In GB
const uint64 GetFreeExtendedMemory() const { return (uint64)m_MemoryInfo.ullAvailExtendedVirtual / BTOMB; } //In MB
const uint64 GetPageFileMemory() const { return (uint64)m_MemoryInfo.ullTotalPageFile / BTOGB; } //In GB
const uint64 GetFreePageFileMemory() const { return (uint64)m_MemoryInfo.ullAvailPageFile / BTOGB; } //In GB
const uint GetVirtualMemoryUsedByProcess() const { return(uint)mProcess_vMemUsed / BTOMB; } //In MB
const uint GetPhysMemoryUsedByProcess() const { return(uint)mProcess_physMemUsed / BTOMB; } //In MB
//Getting Stats of Memory from MMRG
const uint GetMemStatsFromMMGR_TotalReportedMemory() const;
const uint GetMemStatsFromMMGR_TotalActualMemory() const;
const uint GetMemStatsFromMMGR_PeakReportedMemory() const;
const uint GetMemStatsFromMMGR_PeakActualMemory() const;
const uint GetMemStatsFromMMGR_AccumulatedReportedMemory() const;
const uint GetMemStatsFromMMGR_AccumulatedActualMemory() const;
const uint GetMemStatsFromMMGR_AccumulatedAllocUnitCount() const;
const uint GetMemStatsFromMMGR_TotalAllocUnitCount() const;
const uint GetMemStatsFromMMGR_PeakAllocUnitCount() const;
};
//______________________________________________________________________________________
class GPUHardware
{
private:
struct GPUPrimaryInfo_IntelGPUDetect
{
std::string m_GPUBrand;
uint m_GPUID = 0;
uint m_GPUVendor = 0;
//'PI' is for "Primary Info", 'GPUDet' is for "GPUDetect", the code we use to get this info
//Info in Bytes
uint64 mPI_GPUDet_TotalVRAM_Bytes = 0;
uint64 mPI_GPUDet_VRAMUsage_Bytes = 0;
uint64 mPI_GPUDet_CurrentVRAM_Bytes = 0;
uint64 mPI_GPUDet_VRAMReserved_Bytes = 0;
//Info in MB (Just change the division of BTOMB in the GPUDetect_ExtractGPUInfo() function
//by the BTOGB one to get the GB). And change this variables name!! (_MB change it by _GB!!!)
float mPI_GPUDet_TotalVRAM_MB = 0.0f;
float mPI_GPUDet_VRAMUsage_MB = 0.0f;
float mPI_GPUDet_CurrentVRAM_MB = 0.0f;
float mPI_GPUDet_VRAMReserved_MB = 0.0f;
};
mutable GPUPrimaryInfo_IntelGPUDetect m_PI_GPUDet_GPUInfo; //This is the Info for the current GPU in use
//For OPENGL GPU "Getter"
int m_GPUTotalVRAM = 0;
int m_GPUCurrentVRAM = 0;
private:
void GPUDetect_ExtractGPUInfo() const;
public:
void DetectSystemProperties(); //DON'T USE THIS FUNCTION, IS JUST FOR CLASS PURPOSES!!!
void RecalculateGPUParameters() const { GPUDetect_ExtractGPUInfo(); }
const auto GetGPUBenchmark() const { return glGetString(GL_VENDOR); }
/*const auto GetGPUModel();*/
const auto GetGPUModel() {
//const GLubyte* a = glGetString(GL_RENDERER);
return m_PI_GPUDet_GPUInfo.m_GPUBrand;
}
const int GetGPUTotalVRAM(); // In MB... Only for NVIDIA GPUs, otherwise returns 0
const int GetGPUCurrentVRAM(); // In MB... Only for NVIDIA GPUs, otherwise returns 0
const GPUPrimaryInfo_IntelGPUDetect GetGPUInfo_GPUDet() const { return m_PI_GPUDet_GPUInfo; }
};
//______________________________________________________________________________________
class ProcessorHardware
{
private:
SYSTEM_INFO m_CpuSysInfo;
std::string m_CPUBrand;
std::string m_CPUVendor;
std::string m_CpuArchitecture;
struct InstructionsSet
{
bool Available_3DNow = false;
bool RDTSC_Available = false;
bool AltiVec_Available = false;
bool AVX_Available = false;
bool AVX2_Available = false;
bool MMX_Available = false;
bool SSE_Available = false;
bool SSE2_Available = false;
bool SSE3_Available = false;
bool SSE41_Available = false;
bool SSE42_Available = false;
};
InstructionsSet m_CPUInstructionSet;
private:
void GetCPUSystemInfo();
const std::string ExtractCPUArchitecture(SYSTEM_INFO& SystemInfo);
void CheckForCPUInstructionsSet();
public:
void DetectSystemProperties(); //DON'T USE THIS FUNCTION, IS JUST FOR CLASS PURPOSES!!!
const uint GetCPUCores() const { return SDL_GetCPUCount(); }
const uint GetCPUCacheLine1Size() const { return SDL_GetCPUCacheLineSize(); } //In bytes
const std::string GetCPUArchitecture() const { return m_CpuArchitecture; }
const std::string GetNumberOfProcessors() const { return std::to_string(m_CpuSysInfo.dwNumberOfProcessors); }
const std::string GetProcessorRevision() const { return std::to_string(m_CpuSysInfo.wProcessorRevision); }
const InstructionsSet GetCPUInstructionsSet() const { return m_CPUInstructionSet; }
const std::string GetCPUInstructionSet() const;
const std::string GetCPUBrand() const { return m_CPUBrand; }
const std::string GetCPUVendor() const { return m_CPUVendor; }
};
//______________________________________________________________________________________
class SystemInfo
{
private:
SoftwareInfo mSoftware_Info;
MemoryHardware mHardware_MemoryInfo;
GPUHardware mHardware_GPUInfo;
ProcessorHardware mHardware_CPUInfo;
public:
SystemInfo();
~SystemInfo() {}
const SoftwareInfo GetSoftwareInfo() const { return mSoftware_Info; }
const MemoryHardware GetMemoryHardwareInfo() const { return mHardware_MemoryInfo; }
const ProcessorHardware GetCPUHardwareInfo() const { return mHardware_CPUInfo; }
const GPUHardware GetGPUHardwareInfo() const { return mHardware_GPUInfo; }
};
}
#endif