diff options
author | Erik Kundiman <erik@megapahit.org> | 2024-01-06 17:30:19 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2024-01-06 17:30:19 +0800 |
commit | c89a6d51dffb99c1c81bcbfee9d99380f286ddeb (patch) | |
tree | 5ddc2620a26f94b3cbc9b050ca42adaf381807a7 /indra | |
parent | 4d1b19e794c3d7b65e1fe6c0e41ced57ec7e3938 (diff) |
VRAM detection implementation using GLX Mesa
/var/log/Xorg.0.log doesn't seem to contain such information any more.
My Debian 12 doesn't even have that file any more, I wonder why.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llwindow/llwindowsdl.cpp | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 68ad988132..8ffce862b8 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -57,6 +57,8 @@ extern "C" { # include <unistd.h> # include <sys/types.h> # include <sys/wait.h> +# define GLX_GLXEXT_PROTOTYPES 1 +# include <GL/glx.h> #endif // LL_LINUX extern BOOL gDebugWindowProc; @@ -303,7 +305,7 @@ static SDL_Surface *Load_BMP_Resource(const char *basename) return SDL_LoadBMP(path_buffer); } -#if LL_X11 +#if 0 // This is an XFree86/XOrg-specific hack for detecting the amount of Video RAM // on this machine. It works by searching /var/log/var/log/Xorg.?.log or // /var/log/XFree86.?.log for a ': (VideoRAM ?|Memory): (%d+) kB' regex, where @@ -668,13 +670,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B } // Detect video memory size. -# if LL_X11 - gGLManager.mVRAM = x11_detect_VRAM_kb() / 1024; - if (gGLManager.mVRAM != 0) - { - LL_INFOS() << "X11 log-parser detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL; - } else -#elif LL_DARWIN +#if LL_DARWIN CGLRendererInfoObj info = 0; GLint vram_megabytes = 0; int num_renderers = 0; @@ -685,21 +681,17 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B CGLDestroyRendererInfo(info); } else vram_megabytes = 256; +#else + PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger; + queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) + glXGetProcAddressARB((const GLubyte *) + "glXQueryCurrentRendererIntegerMESA"); + unsigned int vram_megabytes = 0; + queryInteger(GLX_RENDERER_VIDEO_MEMORY_MESA, &vram_megabytes); +# endif // LL_DARWIN gGLManager.mVRAM = vram_megabytes; - LL_INFOS() << "Detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL; -# endif // LL_X11 - { - /* - // fallback to letting SDL detect VRAM. - // note: I've not seen SDL's detection ever actually find - // VRAM != 0, but if SDL *does* detect it then that's a bonus. - gGLManager.mVRAM = video_info->video_mem / 1024; - if (gGLManager.mVRAM != 0) - { - LL_INFOS() << "SDL detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL; - } - */ - } + if (gGLManager.mVRAM) + LL_INFOS() << "Detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL; // If VRAM is not detected, that is handled later // *TODO: Now would be an appropriate time to check for some |