little tidbit for systems like mine with more than 4gb of system memory.
in win_shared.cpp put this at the top ->
/* functions for the below */
typedef BOOL( WINAPI *PGetPhysicallyInstalledSystemMemory )( PULONGLONG TotalMemoryInKilobytes );
#define GPA( module, func ) ( PGetPhysicallyInstalledSystemMemory ) GetProcAddress( GetModuleHandle( module ), func )
/*
================
Sys_GetSystemMemory
description:
retrieves installed physical memory from bios
================
*/
static uint64_t Sys_GetSystemMemory( void )
{
/* This code only works on XP or older */
#if ( _WIN32_WINNT <= 0x501 )
MEMORYSTATUSEX statex;
statex.dwLength = sizeof( statex );
GlobalMemoryStatusEx( &statex );
uint64_t mem = static_cast<uint64_t>( statex.ullTotalPhys ) / 1024.0; /* else it would return bytes */
return mem;
#else
/* this works on vista and up */
ULONGLONG mem; /* physical memory installed (kb) */
PGetPhysicallyInstalledSystemMemory pFGetPhysicallyInstalledSystemMemory = GPA("kernel32.dll", "GetPhysicallyInstalledSystemMemory");
/* Uh oh... */
if ( !pFGetPhysicallyInstalledSystemMemory || !pFGetPhysicallyInstalledSystemMemory( &mem ) )
{
return 0;
}
/* Couldnt get system ram */
if ( !mem )
{
return 0;
}
return static_cast<uint64_t>( mem );
#endif
}
and replace Sys_GetSystemRam with this ->
uint64_t Sys_GetSystemRam( void )
{
uint64_t physRam = Sys_GetSystemMemory() / 1024.0;
physRam = ( physRam + 8 ) & ~15;
return physRam;
}
remember to change it in the header as well since the original used int as a return value.
code will now correctly report your system ram on newer windows versions, the old code could only report 4 GB max.
and get rid of the video ram detection code it no longer works correctly and also suffers from the same limit,
you can only get videoram on modern gfx cards by using card specific codepaths like this ->
void idVertexCache::Show( void )
{
GLint mem[4];
if ( GLEW_NVX_gpu_memory_info && ( glConfig.vendor == glvNVIDIA ) )
{
common->Printf( "\nNvidia specific memory info:\n" );
common->Printf( "\n" );
glGetIntegerv( GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX , mem );
common->Printf( "dedicated video memory %i MB\n", mem[0] >> 10 );
glGetIntegerv( GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX , mem );
common->Printf( "total available memory %i MB\n", mem[0] >> 10 );
glGetIntegerv( GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX , mem );
common->Printf( "currently unused GPU memory %i MB\n", mem[0] >> 10 );
glGetIntegerv( GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX , mem );
common->Printf( "count of total evictions seen by system %i MB\n", mem[0] >> 10 );
glGetIntegerv( GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX , mem );
common->Printf( "total video memory evicted %i MB\n", mem[0] >> 10 );
}
else if ( GLEW_ATI_meminfo && ( glConfig.vendor == glvAMD ) )
{
common->Printf( "\nATI/AMD specific memory info:\n" );
common->Printf( "\n" );
glGetIntegerv( GL_VBO_FREE_MEMORY_ATI, mem );
common->Printf( "VBO: total memory free in the pool %i MB\n", mem[0] >> 10 );
common->Printf( "VBO: largest available free block in the pool %i MB\n", mem[1] >> 10 );
common->Printf( "VBO: total auxiliary memory free %i MB\n", mem[2] >> 10 );
common->Printf( "VBO: largest auxiliary free block %i MB\n", mem[3] >> 10 );
glGetIntegerv( GL_TEXTURE_FREE_MEMORY_ATI, mem );
common->Printf( "Texture: total memory free in the pool %i MB\n", mem[0] >> 10 );
common->Printf( "Texture: largest available free block in the pool %i MB\n", mem[1] >> 10 );
common->Printf( "Texture: total auxiliary memory free %i MB\n", mem[2] >> 10 );
common->Printf( "Texture: largest auxiliary free block %i MB\n", mem[3] >> 10 );
glGetIntegerv( GL_RENDERBUFFER_FREE_MEMORY_ATI, mem );
common->Printf( "RenderBuffer: total memory free in the pool %i MB\n", mem[0] >> 10 );
common->Printf( "RenderBuffer: largest available free block in the pool %i MB\n", mem[1] >> 10 );
common->Printf( "RenderBuffer: total auxiliary memory free %i MB\n", mem[2] >> 10 );
common->Printf( "RenderBuffer: largest auxiliary free block %i MB\n", mem[3] >> 10 );
}
else
{
common->Printf( "MemInfo not availabled for your video card or driver!\n" );
}
}
and sadly this only works on nvidia and AMD.