Changed: Support for GLX_MESA_query_renderer to detect video memory

--HG--
branch : develop
This commit is contained in:
kervala 2015-12-26 17:51:36 +01:00
parent 57859636cd
commit ba7c4ae4d4
3 changed files with 37 additions and 0 deletions

View file

@ -1293,6 +1293,17 @@ sint CDriverGL::getTotalVideoMemory() const
{
nlerror("3D: Unable to get current renderer ID (%s)", CGLErrorString(error));
}
#else
if (_Extensions.GLXMESAQueryRenderer)
{
uint32 memoryInMiB = 0;
if (nglXQueryCurrentRendererIntegerMESA(GLX_RENDERER_VIDEO_MEMORY_MESA, &memoryInMiB))
{
nlinfo("3D: GLX_RENDERER_VIDEO_MEMORY_MESA returned %u MiB", memoryInMiB);
return memoryInMiB * 1024;
}
}
#endif
return -1;

View file

@ -541,6 +541,9 @@ PFNGLXSWAPINTERVALSGIPROC nglXSwapIntervalSGI;
PFNGLXSWAPINTERVALMESAPROC nglXSwapIntervalMESA;
PFNGLXGETSWAPINTERVALMESAPROC nglXGetSwapIntervalMESA;
// GLX_MESA_query_renderer
// =======================
PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC nglXQueryCurrentRendererIntegerMESA;
#endif
#endif // USE_OPENGLES
@ -1888,6 +1891,19 @@ static bool setupGLXMESASwapControl(const char *glext)
return true;
}
// *********************************
static bool setupGLXMESAQueryRenderer(const char *glext)
{
H_AUTO_OGL(setupGLXMESAQueryRenderer);
CHECK_EXT("GLX_MESA_query_renderer");
#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
CHECK_ADDRESS(PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC, glXQueryCurrentRendererIntegerMESA);
#endif
return true;
}
#ifdef USE_OPENGLES
// ***************************************************************************
bool registerEGlExtensions(CGlExtensions &ext, EGLDisplay dpy)
@ -2030,6 +2046,9 @@ bool registerGlXExtensions(CGlExtensions &ext, Display *dpy, sint screen)
ext.GLXSGISwapControl= setupGLXSGISwapControl(glext);
ext.GLXMESASwapControl= setupGLXMESASwapControl(glext);
// check for renderer information
ext.GLXMESAQueryRenderer= setupGLXMESAQueryRenderer(glext);
return true;
}
#endif // USE_OPENGLES

View file

@ -87,6 +87,7 @@ struct CGlExtensions
bool GLXEXTSwapControl;
bool GLXSGISwapControl;
bool GLXMESASwapControl;
bool GLXMESAQueryRenderer;
// ATI Extensions.
bool ATIVertexArrayObject;
@ -164,6 +165,7 @@ public:
GLXEXTSwapControl= false;
GLXSGISwapControl= false;
GLXMESASwapControl= false;
GLXMESAQueryRenderer= false;
EXTBlendColor= false;
ATIVertexArrayObject= false;
ATIEnvMapBumpMap = false;
@ -264,6 +266,7 @@ public:
result += GLXEXTSwapControl ? "GLXEXTSwapControl " : "";
result += GLXSGISwapControl ? "GLXSGISwapControl " : "";
result += GLXMESASwapControl ? "GLXMESASwapControl " : "";
result += GLXMESAQueryRenderer ? "GLXMESAQueryRenderer " : "";
#endif
result += "\n Array/VBO: ";
@ -816,6 +819,10 @@ extern PFNGLXSWAPINTERVALSGIPROC nglXSwapIntervalSGI;
extern PFNGLXSWAPINTERVALMESAPROC nglXSwapIntervalMESA;
extern PFNGLXGETSWAPINTERVALMESAPROC nglXGetSwapIntervalMESA;
// GLX_MESA_query_renderer
// =======================
extern PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC nglXQueryCurrentRendererIntegerMESA;
#endif
// GL_EXT_framebuffer_object