mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Implement more extensions to get graphics card memory for OpenGL on windows and Linux.
(cherry picked from commit da942cdb79a87b76e629b36415c83067e3620a70)
This commit is contained in:
parent
794707edbe
commit
a458c97217
2 changed files with 49 additions and 5 deletions
|
|
@ -51,6 +51,10 @@
|
||||||
#include "shaderGen/shaderGen.h"
|
#include "shaderGen/shaderGen.h"
|
||||||
#include "gfxGLUtils.h"
|
#include "gfxGLUtils.h"
|
||||||
|
|
||||||
|
#if defined(TORQUE_OS_WIN)
|
||||||
|
#include "gfx/gl/tGL/tWGL.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
GFXAdapter::CreateDeviceInstanceDelegate GFXGLDevice::mCreateDeviceInstance(GFXGLDevice::createInstance);
|
GFXAdapter::CreateDeviceInstanceDelegate GFXGLDevice::mCreateDeviceInstance(GFXGLDevice::createInstance);
|
||||||
|
|
||||||
GFXDevice *GFXGLDevice::createInstance( U32 adapterIndex )
|
GFXDevice *GFXGLDevice::createInstance( U32 adapterIndex )
|
||||||
|
|
@ -1073,8 +1077,36 @@ U32 GFXGLDevice::getTotalVideoMemory_GL_EXT()
|
||||||
return mem / 1024;
|
return mem / 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO OPENGL, add supprt for INTEL cards.
|
|
||||||
|
#if defined(TORQUE_OS_WIN)
|
||||||
|
else if( (gglHasWExtension(AMD_gpu_association)) )
|
||||||
|
{
|
||||||
|
// Just assume 1 AMD gpu. Who uses crossfire anyways now? And, crossfire doesn't double
|
||||||
|
// vram anyways, so does it really matter?
|
||||||
|
UINT id;
|
||||||
|
if (wglGetGPUIDsAMD(1, &id) != 0)
|
||||||
|
{
|
||||||
|
S32 memorySize;
|
||||||
|
if (wglGetGPUInfoAMD(id, WGL_GPU_RAM_AMD, GL_INT, 1, &memorySize) != -1)
|
||||||
|
{
|
||||||
|
// memory size is returned in MB
|
||||||
|
return memorySize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TORQUE_OS_LINUX)
|
||||||
|
else if ( (gglHasXExtension(MESA_query_renderer)) )
|
||||||
|
{
|
||||||
|
// memory size is in mb
|
||||||
|
S32 memorySize;
|
||||||
|
glXQueryCurrentRendererIntegerMESA(GLX_RENDERER_VIDEO_MEMORY_MESA, &memorySize);
|
||||||
|
return memorySize;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// No other way, sad. Probably windows Intel.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,10 @@
|
||||||
#include "core/strings/stringFunctions.h"
|
#include "core/strings/stringFunctions.h"
|
||||||
#include "console/console.h"
|
#include "console/console.h"
|
||||||
|
|
||||||
#ifdef TORQUE_OS_WIN
|
#if defined(TORQUE_OS_WIN)
|
||||||
#include "tWGL.h"
|
#include "tWGL.h"
|
||||||
|
#elif defined(TORQUE_OS_LINUX)
|
||||||
|
#include "tXGL.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace GL
|
namespace GL
|
||||||
|
|
@ -41,7 +43,17 @@ namespace GL
|
||||||
|
|
||||||
void gglPerformExtensionBinds(void *context)
|
void gglPerformExtensionBinds(void *context)
|
||||||
{
|
{
|
||||||
|
#if defined(TORQUE_OS_WIN)
|
||||||
|
if (!gladLoadWGL((HDC)context))
|
||||||
|
{
|
||||||
|
AssertFatal(false, "Unable to load WGL in GLAD. Make sure your OpenGL drivers are up to date!");
|
||||||
|
}
|
||||||
|
#elif defined(TORQUE_OS_LINUX)
|
||||||
|
if (!gladLoadGLX())
|
||||||
|
{
|
||||||
|
AssertFatal(false, "Unable to load GLX in GLAD. Make sure your OpenGL drivers are up to date!");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue