From c98fd69703403036b4bcf4cde4b1a7a3719e6cb7 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 26 Dec 2015 17:51:36 +0100 Subject: [PATCH] Changed: Support for GLX_MESA_query_renderer to detect video memory --- .../src/3d/driver/opengl/driver_opengl.cpp | 11 +++++++++++ .../driver/opengl/driver_opengl_extension.cpp | 19 +++++++++++++++++++ .../driver/opengl/driver_opengl_extension.h | 7 +++++++ 3 files changed, 37 insertions(+) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index b01f58ba3..fa2894229 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -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; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp index 37099eab6..59ca38a57 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp @@ -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 diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.h b/code/nel/src/3d/driver/opengl/driver_opengl_extension.h index d5556ef64..5338ff999 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.h @@ -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