Core/HardwareInfo: Added GetTotalMemory
Former-commit-id: 71289723115161dd253ccb65c1c91af65344c678
This commit is contained in:
parent
c3e5a7defc
commit
90e4a1ca52
|
|
@ -196,8 +196,7 @@ return {
|
|||
{
|
||||
Title = "Récupération d'informations sur le hardware",
|
||||
Description = "Classe permettant, si la plateforme le supporte, de récupérer des informations utiles sur le matériel: nom et fabricant du processeur, nombre de coeurs, support d'un set d'extension (exemple: SSE), quantité de mémoire vive, exécution de l'instruction CPUID.",
|
||||
Note = "Il manque de quoi récupérer la quantité de mémoire vive",
|
||||
Progress = 90,
|
||||
Progress = 100,
|
||||
Portability = Feature.Windows + Feature.POSIX
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class NAZARA_API NzHardwareInfo
|
|||
static unsigned int GetProcessorCount();
|
||||
static nzProcessorVendor GetProcessorVendor();
|
||||
static NzString GetProcessorVendorName();
|
||||
static nzUInt64 GetTotalMemory();
|
||||
|
||||
static bool HasCapability(nzProcessorCap capability);
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue