Core/HardwareInfo: Added GetTotalMemory
Former-commit-id: 71289723115161dd253ccb65c1c91af65344c678
This commit is contained in:
@@ -116,6 +116,13 @@ NzString NzHardwareInfo::GetProcessorVendorName()
|
||||
return vendorNames[s_vendorEnum+1];
|
||||
}
|
||||
|
||||
nzUInt64 NzHardwareInfo::GetTotalMemory()
|
||||
{
|
||||
///DOC: Ne nécessite pas l'initialisation de HardwareInfo pour fonctionner
|
||||
static nzUInt64 totalMemory = NzHardwareInfoImpl::GetTotalMemory();
|
||||
return totalMemory;
|
||||
}
|
||||
|
||||
bool NzHardwareInfo::HasCapability(nzProcessorCap capability)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
|
||||
@@ -24,6 +24,14 @@ unsigned int NzHardwareInfoImpl::GetProcessorCount()
|
||||
return sysconf(_SC_NPROCESSORS_CONF);
|
||||
}
|
||||
|
||||
nzUInt64 NzHardwareInfoImpl::GetTotalMemory()
|
||||
{
|
||||
nzUInt64 pages = sysconf(_SC_PHYS_PAGES);
|
||||
nzUInt64 page_size = sysconf(_SC_PAGE_SIZE);
|
||||
|
||||
return pages * page_size;
|
||||
}
|
||||
|
||||
bool NzHardwareInfoImpl::IsCpuidSupported()
|
||||
{
|
||||
#ifdef NAZARA_PLATFORM_x64
|
||||
|
||||
@@ -15,6 +15,7 @@ class NzHardwareInfoImpl
|
||||
public:
|
||||
static void Cpuid(nzUInt32 functionId, nzUInt32 subFunctionId, nzUInt32 registers[4]);
|
||||
static unsigned int GetProcessorCount();
|
||||
static nzUInt64 GetTotalMemory();
|
||||
static bool IsCpuidSupported();
|
||||
};
|
||||
|
||||
|
||||
@@ -38,6 +38,15 @@ unsigned int NzHardwareInfoImpl::GetProcessorCount()
|
||||
return infos.dwNumberOfProcessors;
|
||||
}
|
||||
|
||||
nzUInt64 NzHardwareInfoImpl::GetTotalMemory()
|
||||
{
|
||||
MEMORYSTATUSEX memStatus;
|
||||
memStatus.dwLength = sizeof(memStatus);
|
||||
GlobalMemoryStatusEx(&memStatus);
|
||||
|
||||
return memStatus.ullTotalPhys;
|
||||
}
|
||||
|
||||
bool NzHardwareInfoImpl::IsCpuidSupported()
|
||||
{
|
||||
#ifdef NAZARA_PLATFORM_x64
|
||||
|
||||
@@ -14,6 +14,7 @@ class NzHardwareInfoImpl
|
||||
public:
|
||||
static void Cpuid(nzUInt32 functionId, nzUInt32 subFunctionId, nzUInt32 registers[4]);
|
||||
static unsigned int GetProcessorCount();
|
||||
static nzUInt64 GetTotalMemory();
|
||||
static bool IsCpuidSupported();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user