mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-28 03:40:54 +00:00
Changed: Detect available video memory with OpenGL extensions
This commit is contained in:
parent
d7f7523bdf
commit
654583807c
2 changed files with 98 additions and 0 deletions
|
@ -1474,6 +1474,22 @@ static bool setupPackedDepthStencil(const char *glext)
|
|||
return true;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
static bool setupNVXGPUMemoryInfo(const char *glext)
|
||||
{
|
||||
H_AUTO_OGL(setupNVXGPUMemoryInfo);
|
||||
CHECK_EXT("GL_NVX_gpu_memory_info");
|
||||
return true;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
static bool setupATIMeminfo(const char *glext)
|
||||
{
|
||||
H_AUTO_OGL(setupATIMeminfo);
|
||||
CHECK_EXT("GL_ATI_meminfo");
|
||||
return true;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Extension Check.
|
||||
void registerGlExtensions(CGlExtensions &ext)
|
||||
|
@ -1689,6 +1705,35 @@ void registerGlExtensions(CGlExtensions &ext)
|
|||
ext.ATIMapObjectBuffer = false;
|
||||
ext.ATIVertexAttribArrayObject = false;
|
||||
}
|
||||
|
||||
#ifndef USE_OPENGLES
|
||||
ext.NVXGPUMemoryInfo = setupNVXGPUMemoryInfo(glext);
|
||||
|
||||
if (ext.NVXGPUMemoryInfo)
|
||||
{
|
||||
// GPU_MEMORY_INFO_EVICTION_COUNT_NVX;
|
||||
// GPU_MEMORY_INFO_EVICTED_MEMORY_NVX;
|
||||
|
||||
GLint nDedicatedMemoryInKB = 0;
|
||||
glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &nDedicatedMemoryInKB);
|
||||
|
||||
GLint nTotalMemoryInKB = 0;
|
||||
glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &nTotalMemoryInKB);
|
||||
|
||||
GLint nCurAvailMemoryInKB = 0;
|
||||
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &nCurAvailMemoryInKB);
|
||||
|
||||
nlinfo("Memory: total: %d available: %d dedicated: %d", nTotalMemoryInKB, nCurAvailMemoryInKB, nDedicatedMemoryInKB);
|
||||
}
|
||||
|
||||
ext.ATIMeminfo = setupATIMeminfo(glext);
|
||||
|
||||
if (ext.ATIMeminfo)
|
||||
{
|
||||
GLint nCurAvailMemoryInKB = 0;
|
||||
glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, &nCurAvailMemoryInKB);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -1708,6 +1753,27 @@ static bool setupWGLEXTSwapControl(const char *glext)
|
|||
return true;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
static bool setupWGLAMDGPUAssociation(const char *glext)
|
||||
{
|
||||
H_AUTO_OGL(setupWGLAMDGPUAssociation);
|
||||
CHECK_EXT("WGL_AMD_gpu_association");
|
||||
|
||||
#if !defined(USE_OPENGLES) && defined(NL_OS_WINDOWS)
|
||||
CHECK_ADDRESS(PFNWGLGETGPUIDSAMDPROC, wglGetGPUIDsAMD);
|
||||
CHECK_ADDRESS(PFNWGLGETGPUINFOAMDPROC, wglGetGPUInfoAMD);
|
||||
CHECK_ADDRESS(PFNWGLGETCONTEXTGPUIDAMDPROC, wglGetContextGPUIDAMD);
|
||||
CHECK_ADDRESS(PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC, wglCreateAssociatedContextAMD);
|
||||
CHECK_ADDRESS(PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC, wglCreateAssociatedContextAttribsAMD);
|
||||
CHECK_ADDRESS(PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC, wglDeleteAssociatedContextAMD);
|
||||
CHECK_ADDRESS(PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC, wglMakeAssociatedContextCurrentAMD);
|
||||
CHECK_ADDRESS(PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC, wglGetCurrentAssociatedContextAMD);
|
||||
CHECK_ADDRESS(PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC, wglBlitContextFramebufferAMD);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// *********************************
|
||||
static bool setupGLXEXTSwapControl(const char *glext)
|
||||
{
|
||||
|
@ -1820,6 +1886,20 @@ bool registerWGlExtensions(CGlExtensions &ext, HDC hDC)
|
|||
// Check for swap control
|
||||
ext.WGLEXTSwapControl= setupWGLEXTSwapControl(glext);
|
||||
|
||||
ext.WGLAMDGPUAssociation = setupWGLAMDGPUAssociation(glext);
|
||||
|
||||
if (ext.WGLAMDGPUAssociation)
|
||||
{
|
||||
GLuint uNoOfGPUs = nwglGetGPUIDsAMD(0, 0);
|
||||
GLuint *uGPUIDs = new GLuint[uNoOfGPUs];
|
||||
nwglGetGPUIDsAMD(uNoOfGPUs, uGPUIDs);
|
||||
|
||||
GLuint uTotalMemoryInMB = 0;
|
||||
nwglGetGPUInfoAMD(uGPUIDs[0], WGL_GPU_RAM_AMD, GL_UNSIGNED_INT, sizeof(GLuint), &uTotalMemoryInMB);
|
||||
|
||||
delete [] uGPUIDs;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#elif defined(NL_OS_MAC)
|
||||
|
|
|
@ -109,6 +109,17 @@ struct CGlExtensions
|
|||
bool OESDrawTexture;
|
||||
bool OESMapBuffer;
|
||||
|
||||
// extensions to get memory info
|
||||
|
||||
// GL_NVX_gpu_memory_info
|
||||
bool NVXGPUMemoryInfo;
|
||||
|
||||
// GL_ATI_meminfo
|
||||
bool ATIMeminfo;
|
||||
|
||||
// WGL_AMD_gpu_association
|
||||
bool WGLAMDGPUAssociation;
|
||||
|
||||
public:
|
||||
|
||||
/// \name Disable Hardware feature. False by default. setuped by IDriver
|
||||
|
@ -175,6 +186,10 @@ public:
|
|||
OESDrawTexture = false;
|
||||
OESMapBuffer = false;
|
||||
|
||||
NVXGPUMemoryInfo = false;
|
||||
ATIMeminfo = false;
|
||||
WGLAMDGPUAssociation = false;
|
||||
|
||||
/// \name Disable Hardware feature. False by default. setuped by IDriver
|
||||
DisableHardwareVertexProgram= false;
|
||||
DisableHardwarePixelProgram= false;
|
||||
|
@ -224,12 +239,15 @@ public:
|
|||
result += NVOcclusionQuery ? "NVOcclusionQuery " : "";
|
||||
result += NVStateVARWithoutFlush ? "NVStateVARWithoutFlush " : "";
|
||||
result += ARBMultisample ? "ARBMultisample " : "";
|
||||
result += NVXGPUMemoryInfo ? "NVXGPUMemoryInfo " : "";
|
||||
result += ATIMeminfo ? "ATIMeminfo " : "";
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
result += "\n WindowsGL: ";
|
||||
result += WGLARBPBuffer ? "WGLARBPBuffer " : "";
|
||||
result += WGLARBPixelFormat ? "WGLARBPixelFormat " : "";
|
||||
result += WGLEXTSwapControl ? "WGLEXTSwapControl " : "";
|
||||
result += WGLAMDGPUAssociation ? "WGLAMDGPUAssociation " : "";
|
||||
#elif defined(NL_OS_MAC)
|
||||
#elif defined(NL_OS_UNIX)
|
||||
result += "\n GLX: ";
|
||||
|
|
Loading…
Reference in a new issue