From 174b934a13e665413ddacea025675804eeb8062b Mon Sep 17 00:00:00 2001 From: Beq Date: Tue, 18 Jun 2024 01:11:28 +0100 Subject: [PATCH] Revised VRAM override for cross-platform relocated for x-platform (tested on Win and Linux, Mac TBC) --- indra/llrender/llgl.cpp | 1 + indra/llrender/llgl.h | 2 +- indra/newview/llappviewer.cpp | 22 ++++++++++++++++++- indra/newview/llappviewer.h | 1 + indra/newview/llappviewerwin32.cpp | 14 +----------- .../newview/skins/default/xui/en/strings.xml | 1 + 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index bf5f9da01c..6ff0d22ae9 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -1014,6 +1014,7 @@ LLGLManager::LLGLManager() : mGLSLVersionMajor(0), mGLSLVersionMinor(0), mVRAM(0), + mVRAMDetected(0), // add override support mGLMaxVertexRange(0), mGLMaxIndexRange(0) { diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index cb46740037..11ed5df230 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -133,7 +133,7 @@ public: std::string mGLVersionString; S32 mVRAM; // VRAM in MB - + S32 mVRAMDetected; // The amount detected/reported by the OS/Drivers. If different to mVRAM there is an override in place. void getPixelFormat(); // Get the best pixel format std::string getGLInfoString(); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 28197796f6..5bb33ce481 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1131,6 +1131,12 @@ bool LLAppViewer::init() gGLActive = TRUE; initWindow(); LL_INFOS("InitInfo") << "Window is initialized." << LL_ENDL ; + // allow detected hardware to be overridden. + gGLManager.mVRAMDetected = gGLManager.mVRAM; + LL_INFOS("AppInit") << "VRAM detected: " << gGLManager.mVRAMDetected << LL_ENDL; + overrideDetectedHardware(); + // + // writeSystemInfo can be called after window is initialized (gViewerWindow non-null) writeSystemInfo(); @@ -1491,6 +1497,20 @@ bool LLAppViewer::init() return true; } +// allow detected hardware to be overridden. +void LLAppViewer::overrideDetectedHardware() +{ + // Override the VRAM Detection if FSOverrideVRAMDetection is set. + if ( gSavedSettings.getBOOL("FSOverrideVRAMDetection") ) + { + S32 forced_video_memory = gSavedSettings.getS32("FSForcedVideoMemory"); + // Note: 0 is allowed here, some systems detect VRAM as zero so override should support emulating them. + LL_INFOS("AppInit") << "Overriding VRAM to " << forced_video_memory*1024 << " MB" << LL_ENDL; + gGLManager.mVRAM = forced_video_memory*1024; + } +} +// + void LLAppViewer::initMaxHeapSize() { //set the max heap size. @@ -3937,7 +3957,7 @@ LLSD LLAppViewer::getViewerInfo() const info["GRAPHICS_CARD_VENDOR"] = ll_safe_string((const char*)(glGetString(GL_VENDOR))); info["GRAPHICS_CARD"] = ll_safe_string((const char*)(glGetString(GL_RENDERER))); info["GRAPHICS_CARD_MEMORY"] = gGLManager.mVRAM; - + info["GRAPHICS_CARD_MEMORY_DETECTED"] = gGLManager.mVRAMDetected; // allow detected hardware to be overridden. #if LL_WINDOWS std::string drvinfo; diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 5ca5a11f85..6bc6118775 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -244,6 +244,7 @@ protected: virtual void initLoggingAndGetLastDuration(); // Initialize log files, logging system virtual void initConsole() {}; // Initialize OS level debugging console. virtual bool initHardwareTest() { return true; } // A false result indicates the app should quit. + virtual void overrideDetectedHardware(); // Override VRAM (and others in future?) consistently. virtual bool initSLURLHandler(); virtual bool sendURLToOtherInstance(const std::string& url); diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index 8430a17973..a969da77be 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -1027,22 +1027,10 @@ bool LLAppViewerWin32::initHardwareTest() if (gGLManager.mVRAM == 0) { - // Allow the user to override the VRAM detection - if ( gSavedSettings.getBOOL("FSOverrideVRAMDetection") ) - { - S32 forced_video_memory = gSavedSettings.getS32("FSForcedVideoMemory"); - if ( forced_video_memory > 0 ) - { - LL_INFOS("AppInit") << "Forcing VRAM to " << forced_video_memory*1024 << " MB" << LL_ENDL; - gGLManager.mVRAM = forced_video_memory*1024; - } - } - else - // gGLManager.mVRAM = gDXHardware.getVRAM(); } - LL_INFOS("AppInit") << "Detected VRAM: " << gGLManager.mVRAM << LL_ENDL; + // LL_INFOS("AppInit") << "Detected VRAM: " << gGLManager.mVRAM << LL_ENDL; // move this into common code return true; } diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 2194d45948..0a9088155b 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -56,6 +56,7 @@ OS Version: [OS_VERSION] Graphics Card Vendor: [GRAPHICS_CARD_VENDOR] Graphics Card: [GRAPHICS_CARD] Graphics Card Memory: [GRAPHICS_CARD_MEMORY] MB +Graphics Card Memory (Detected): [GRAPHICS_CARD_MEMORY_DETECTED] MB Windows Graphics Driver Version: [GRAPHICS_DRIVER_VERSION] OpenGL Version: [OPENGL_VERSION]