From 485a3461988287ee372fb356bd40132e2981f848 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Sat, 20 Jun 2020 19:44:13 +0100 Subject: [PATCH] Add memory total for NVIDIA cards in the logs (#4315) * Add memory total for NVIDIA cards in the logs * define the GL request ID --- src/graphics/central_settings.cpp | 16 +++++++++++++--- src/graphics/central_settings.hpp | 2 +- src/graphics/gl_headers.hpp | 4 ++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/graphics/central_settings.cpp b/src/graphics/central_settings.cpp index 100bb956e..14a0770ec 100644 --- a/src/graphics/central_settings.cpp +++ b/src/graphics/central_settings.cpp @@ -33,6 +33,7 @@ void CentralVideoSettings::init() { m_gl_major_version = 2; m_gl_minor_version = 1; + m_gl_mem = 0; // Parse extensions hasBufferStorage = false; @@ -64,10 +65,19 @@ void CentralVideoSettings::init() { glGetIntegerv(GL_MAJOR_VERSION, &m_gl_major_version); glGetIntegerv(GL_MINOR_VERSION, &m_gl_minor_version); + const char *vendor = (const char *)glGetString(GL_VENDOR); + const char *renderer = (const char *)glGetString(GL_RENDERER); + const char *version = (const char *)glGetString(GL_VERSION); Log::info("IrrDriver", "OpenGL version: %d.%d", m_gl_major_version, m_gl_minor_version); - Log::info("IrrDriver", "OpenGL vendor: %s", glGetString(GL_VENDOR)); - Log::info("IrrDriver", "OpenGL renderer: %s", glGetString(GL_RENDERER)); - Log::info("IrrDriver", "OpenGL version string: %s", glGetString(GL_VERSION)); + Log::info("IrrDriver", "OpenGL vendor: %s", vendor); + Log::info("IrrDriver", "OpenGL renderer: %s", renderer); + Log::info("IrrDriver", "OpenGL version string: %s", version); + + if (strstr(vendor, "NVIDIA")) + glGetIntegerv(GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX, &m_gl_mem); + + if (m_gl_mem > 0) + Log::info("IrrDriver", "OpenGL total memory: %d", m_gl_mem/1024); } #if !defined(USE_GLES2) m_glsl = (m_gl_major_version > 3 || (m_gl_major_version == 3 && m_gl_minor_version >= 1)) diff --git a/src/graphics/central_settings.hpp b/src/graphics/central_settings.hpp index d4ca9a5b3..f90581407 100644 --- a/src/graphics/central_settings.hpp +++ b/src/graphics/central_settings.hpp @@ -26,7 +26,7 @@ private: /** Supports GLSL */ bool m_glsl; - int m_gl_major_version, m_gl_minor_version; + int m_gl_major_version, m_gl_minor_version, m_gl_mem; bool hasBufferStorage; bool hasComputeShaders; bool hasArraysOfArrays; diff --git a/src/graphics/gl_headers.hpp b/src/graphics/gl_headers.hpp index 06b7206cb..485967885 100644 --- a/src/graphics/gl_headers.hpp +++ b/src/graphics/gl_headers.hpp @@ -91,5 +91,9 @@ extern "C" { #endif // server only +#ifndef GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX +#define GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX 0x9048 +#endif + #endif