From eb0bafc33a323296001bfa6b6a97f0c32b17b63f Mon Sep 17 00:00:00 2001 From: Brad Linden <46733234+brad-linden@users.noreply.github.com> Date: Thu, 29 Aug 2024 12:57:49 -0700 Subject: [PATCH 1/5] Backport fix for secondlife/viewer#1856 Add error handling for intel crashes from GLTF Scene shader (#2456) --- indra/newview/app_settings/settings.xml | 11 +++++++++++ indra/newview/gltfscenemanager.cpp | 8 ++++++++ indra/newview/llviewermenu.cpp | 15 +++++++++++++-- indra/newview/llviewershadermgr.cpp | 9 ++++++++- .../skins/default/xui/en/notifications.xml | 10 ++++++++++ 5 files changed, 50 insertions(+), 3 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 219901ae78..148bf7f718 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10484,6 +10484,17 @@ Change of this parameter will affect the layout of buttons in notification toast Value 0 + RenderCanUseGLTFPBROpaqueShaders + + Comment + Hardware has support for GLTF scene shaders + Persist + 0 + Type + Boolean + Value + 1 + RenderClass1MemoryBandwidth Comment diff --git a/indra/newview/gltfscenemanager.cpp b/indra/newview/gltfscenemanager.cpp index 318e765cdb..611162485c 100644 --- a/indra/newview/gltfscenemanager.cpp +++ b/indra/newview/gltfscenemanager.cpp @@ -44,6 +44,7 @@ #include "llfloaterperms.h" #include "llagentbenefits.h" #include "llfilesystem.h" +#include "llviewercontrol.h" #include "boost/json.hpp" #define GLTF_SIM_SUPPORT 1 @@ -597,6 +598,13 @@ void GLTFSceneManager::render(Asset& asset, U8 variant) { LL_PROFILE_ZONE_SCOPED_CATEGORY_GLTF; + static LLCachedControl can_use_shaders(gSavedSettings, "RenderCanUseGLTFPBROpaqueShaders", true); + if (!can_use_shaders) + { + // user should already have been notified of unsupported hardware + return; + } + for (U32 ds = 0; ds < 2; ++ds) { RenderData& rd = asset.mRenderData[ds]; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 4abad087ff..f9c66a64a6 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -4014,7 +4014,9 @@ bool enable_os_exception() bool enable_gltf() { static LLCachedControl enablegltf(gSavedSettings, "GLTFEnabled", false); - return enablegltf; + static LLCachedControl can_use(gSavedSettings, "RenderCanUseGLTFPBROpaqueShaders", true); + + return enablegltf && can_use; } bool enable_gltf_save_as() @@ -10102,7 +10104,16 @@ class LLAdvancedClickGLTFOpen: public view_listener_t { bool handleEvent(const LLSD& userdata) { - LL::GLTFSceneManager::instance().load(); + static LLCachedControl can_use_shaders(gSavedSettings, "RenderCanUseGLTFPBROpaqueShaders", true); + if (can_use_shaders) + { + LL::GLTFSceneManager::instance().load(); + } + else + { + LLNotificationsUtil::add("NoSupportGLTFShader"); + } + return true; } }; diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 266dd5e409..16da555351 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1344,7 +1344,14 @@ bool LLViewerShaderMgr::loadShadersDeferred() success = make_gltf_variants(gGLTFPBRMetallicRoughnessProgram, use_sun_shadow); - llassert(success); + //llassert(success); + if (!success) + { + LL_WARNS() << "Failed to create GLTF PBR Metallic Roughness Shader, disabling!" << LL_ENDL; + gSavedSettings.setBOOL("RenderCanUseGLTFPBROpaqueShaders", false); + // continue as if this shader never happened + success = true; + } } if (success) diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index b31b06efad..7e691a0f9e 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -14474,6 +14474,16 @@ This will replace the items in the selected outfit with the items you are wearin yestext="OK"/> + + GLTF scenes are not yet supported on your graphics hardware. + fail + + Date: Thu, 5 Sep 2024 15:48:48 +0200 Subject: [PATCH 2/5] Adding this translation for the 3rd time now... --- indra/newview/skins/default/xui/de/notifications.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/indra/newview/skins/default/xui/de/notifications.xml b/indra/newview/skins/default/xui/de/notifications.xml index da01c7c979..9bc1a13c73 100644 --- a/indra/newview/skins/default/xui/de/notifications.xml +++ b/indra/newview/skins/default/xui/de/notifications.xml @@ -5113,6 +5113,10 @@ Möchten Sie fortfahren? Upload wird gerade durchgeführt. Bitte versuchen Sie es später erneut. + + GLTF-Szenen werden auf Ihrer Hardware momentan noch nicht unterstützt. + + Keine gültige Einstellung für die Umgebung ausgewählt. From df60c3dd488cc693c50de548e0ecd8e0464e1416 Mon Sep 17 00:00:00 2001 From: Brad Linden <46733234+brad-linden@users.noreply.github.com> Date: Thu, 29 Aug 2024 12:57:49 -0700 Subject: [PATCH 3/5] Backport fix for secondlife/viewer#1856 Add error handling for intel crashes from GLTF Scene shader (#2456) --- indra/newview/app_settings/settings.xml | 11 +++++++++++ indra/newview/gltfscenemanager.cpp | 8 ++++++++ indra/newview/llviewermenu.cpp | 15 +++++++++++++-- indra/newview/llviewershadermgr.cpp | 9 ++++++++- .../skins/default/xui/en/notifications.xml | 10 ++++++++++ 5 files changed, 50 insertions(+), 3 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 219901ae78..148bf7f718 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10484,6 +10484,17 @@ Change of this parameter will affect the layout of buttons in notification toast Value 0 + RenderCanUseGLTFPBROpaqueShaders + + Comment + Hardware has support for GLTF scene shaders + Persist + 0 + Type + Boolean + Value + 1 + RenderClass1MemoryBandwidth Comment diff --git a/indra/newview/gltfscenemanager.cpp b/indra/newview/gltfscenemanager.cpp index 318e765cdb..611162485c 100644 --- a/indra/newview/gltfscenemanager.cpp +++ b/indra/newview/gltfscenemanager.cpp @@ -44,6 +44,7 @@ #include "llfloaterperms.h" #include "llagentbenefits.h" #include "llfilesystem.h" +#include "llviewercontrol.h" #include "boost/json.hpp" #define GLTF_SIM_SUPPORT 1 @@ -597,6 +598,13 @@ void GLTFSceneManager::render(Asset& asset, U8 variant) { LL_PROFILE_ZONE_SCOPED_CATEGORY_GLTF; + static LLCachedControl can_use_shaders(gSavedSettings, "RenderCanUseGLTFPBROpaqueShaders", true); + if (!can_use_shaders) + { + // user should already have been notified of unsupported hardware + return; + } + for (U32 ds = 0; ds < 2; ++ds) { RenderData& rd = asset.mRenderData[ds]; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 9aaa34d03a..62a8553d8b 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -4014,7 +4014,9 @@ bool enable_os_exception() bool enable_gltf() { static LLCachedControl enablegltf(gSavedSettings, "GLTFEnabled", false); - return enablegltf; + static LLCachedControl can_use(gSavedSettings, "RenderCanUseGLTFPBROpaqueShaders", true); + + return enablegltf && can_use; } bool enable_gltf_save_as() @@ -10102,7 +10104,16 @@ class LLAdvancedClickGLTFOpen: public view_listener_t { bool handleEvent(const LLSD& userdata) { - LL::GLTFSceneManager::instance().load(); + static LLCachedControl can_use_shaders(gSavedSettings, "RenderCanUseGLTFPBROpaqueShaders", true); + if (can_use_shaders) + { + LL::GLTFSceneManager::instance().load(); + } + else + { + LLNotificationsUtil::add("NoSupportGLTFShader"); + } + return true; } }; diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 266dd5e409..16da555351 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1344,7 +1344,14 @@ bool LLViewerShaderMgr::loadShadersDeferred() success = make_gltf_variants(gGLTFPBRMetallicRoughnessProgram, use_sun_shadow); - llassert(success); + //llassert(success); + if (!success) + { + LL_WARNS() << "Failed to create GLTF PBR Metallic Roughness Shader, disabling!" << LL_ENDL; + gSavedSettings.setBOOL("RenderCanUseGLTFPBROpaqueShaders", false); + // continue as if this shader never happened + success = true; + } } if (success) diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index b31b06efad..7e691a0f9e 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -14474,6 +14474,16 @@ This will replace the items in the selected outfit with the items you are wearin yestext="OK"/> + + GLTF scenes are not yet supported on your graphics hardware. + fail + + Date: Thu, 5 Sep 2024 18:47:36 +0200 Subject: [PATCH 4/5] Apply some VRAM detection changes from DeltaFPS --- indra/llrender/llgl.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 09252cd167..ff87f0407e 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -1188,7 +1188,7 @@ bool LLGLManager::initGL() // U32 old_vram = mVRAM; // mVRAM = 0; -#if LL_WINDOWS +#if 0 //LL_WINDOWS Special handling down below if (mHasAMDAssociations) { GLuint gl_gpus_count = wglGetGPUIDsAMD(0, 0); @@ -1249,6 +1249,32 @@ bool LLGLManager::initGL() LL_INFOS("RenderInit") << "VRAM Detected (NVXMemInfo):" << mVRAM << LL_ENDL; } + if (mHasAMDAssociations && mVRAM == 0) + { + GLuint gl_gpus_count = wglGetGPUIDsAMD(0, 0); + if (gl_gpus_count > 0) + { + GLuint* ids = new GLuint[gl_gpus_count]; + wglGetGPUIDsAMD(gl_gpus_count, ids); + + GLuint mem_mb = 0; + for (U32 i = 0; i < gl_gpus_count; i++) + { + wglGetGPUInfoAMD(ids[i], + WGL_GPU_RAM_AMD, + GL_UNSIGNED_INT, + sizeof(GLuint), + &mem_mb); + if (mVRAM < mem_mb) + { + // basically pick the best AMD and trust driver/OS to know to switch + mVRAM = mem_mb; + } + } + } + LL_INFOS("RenderInit") << "VRAM Detected (AMDAssociations):" << mVRAM << LL_ENDL; + } + if (mHasATIMemInfo && mVRAM == 0) { //ask the gl how much vram is free at startup and attempt to use no more than half of that S32 meminfo[4]; From 1f477be2cef1ee96e2f01a5d704ac6e41750f6ba Mon Sep 17 00:00:00 2001 From: Ansariel Date: Thu, 5 Sep 2024 21:08:09 +0200 Subject: [PATCH 5/5] In or out? Just throw it out! :) --- indra/llwindow/llwindowwin32.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 6e26ebd3ad..b9ed1e1017 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -1662,9 +1662,6 @@ const S32 max_format = (S32)num_formats - 1; close(); return false; } - //LL_PROFILER_GPU_CONTEXT; TODO(Beq) review this - - LL_PROFILER_GPU_CONTEXT // Disable vertical sync for swap toggleVSync(enable_vsync);