From 8406d1052c70d1d9f964ec86f6f5468aa9f57bb1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 27 Aug 2024 11:53:54 -0500 Subject: #2428 Fix for crash when applying PBR material (#2430) Also attempt to fix some occasional bad texture memory tracking. --- indra/llrender/llimagegl.cpp | 10 +++++++--- indra/newview/llface.cpp | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 058afa0cf2..e4b176ff69 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -70,12 +70,15 @@ static U64 sTextureBytes = 0; void LLImageGLMemory::alloc_tex_image(U32 width, U32 height, U32 pixformat) { U32 texUnit = gGL.getCurrentTexUnitIndex(); + llassert(texUnit == 0); // allocations should always be done on tex unit 0 U32 texName = gGL.getTexUnit(texUnit)->getCurrTexture(); U64 size = LLImageGL::dataFormatBytes(pixformat, width, height); llassert(size >= 0); sTexMemMutex.lock(); + + // it is a precondition that no existing allocation exists for this texture llassert(sTextureAllocs.find(texName) == sTextureAllocs.end()); sTextureAllocs[texName] = size; @@ -89,7 +92,7 @@ void LLImageGLMemory::free_tex_image(U32 texName) { sTexMemMutex.lock(); auto iter = sTextureAllocs.find(texName); - if (iter != sTextureAllocs.end()) + if (iter != sTextureAllocs.end()) // sometimes a texName will be "freed" before allocated (e.g. first call to setManualImage for a given texName) { llassert(iter->second <= sTextureBytes); // sTextureBytes MUST NOT go below zero @@ -114,6 +117,7 @@ void LLImageGLMemory::free_tex_images(U32 count, const U32* texNames) void LLImageGLMemory::free_cur_tex_image() { U32 texUnit = gGL.getCurrentTexUnitIndex(); + llassert(texUnit == 0); // frees should always be done on tex unit 0 U32 texName = gGL.getTexUnit(texUnit)->getCurrTexture(); free_tex_image(texName); } @@ -1215,8 +1219,8 @@ void LLImageGL::deleteTextures(S32 numTextures, const U32 *textures) if (!sFreeList[idx].empty()) { - glDeleteTextures((GLsizei) sFreeList[idx].size(), sFreeList[idx].data()); free_tex_images((GLsizei) sFreeList[idx].size(), sFreeList[idx].data()); + glDeleteTextures((GLsizei)sFreeList[idx].size(), sFreeList[idx].data()); sFreeList[idx].resize(0); } } @@ -2405,7 +2409,7 @@ bool LLImageGL::scaleDown(S32 desired_discard) { // use a PBO to downscale the texture U64 size = getBytes(desired_discard); llassert(size <= 2048 * 2048 * 4); // we shouldn't be using this method to downscale huge textures, but it'll work - gGL.getTexUnit(0)->bind(this); + gGL.getTexUnit(0)->bind(this, false, true); if (sScratchPBO == 0) { diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index a8001699fe..9e504402c8 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -577,8 +577,11 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color) } } // Draw the selection marker using the correctly chosen vertex buffer - vertex_buffer->setBuffer(); - vertex_buffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); + if (vertex_buffer) + { + vertex_buffer->setBuffer(); + vertex_buffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); + } } gGL.popMatrix(); -- cgit v1.2.3 From f15228023f3a1094f69891a5f431cff3d895515a Mon Sep 17 00:00:00 2001 From: Brad Linden <46733234+brad-linden@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:20:25 -0700 Subject: Attempt to get better file/line info for LL_ERRS crahses in bugsplat. (#2447) secondlife/viewer#2445 --- indra/llcommon/llerror.cpp | 16 ---------------- indra/llcommon/llerror.h | 11 +++++------ 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 41c69ba194..ad35bc84f2 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -1641,19 +1641,3 @@ namespace LLError sLocalizedOutOfMemoryWarning = message; } } - -void crashdriver(void (*callback)(int*)) -{ - // The LLERROR_CRASH macro used to have inline code of the form: - //int* make_me_crash = NULL; - //*make_me_crash = 0; - - // But compilers are getting smart enough to recognize that, so we must - // assign to an address supplied by a separate source file. We could do - // the assignment here in crashdriver() -- but then BugSplat would group - // all LL_ERRS() crashes as the fault of this one function, instead of - // identifying the specific LL_ERRS() source line. So instead, do the - // assignment in a lambda in the caller's source. We just provide the - // nullptr target. - callback(nullptr); -} diff --git a/indra/llcommon/llerror.h b/indra/llcommon/llerror.h index 6176ce0d1d..8a143ff30a 100644 --- a/indra/llcommon/llerror.h +++ b/indra/llcommon/llerror.h @@ -408,9 +408,11 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG; #define LL_NEWLINE '\n' // Use this only in LL_ERRS or in a place that LL_ERRS may not be used -#define LLERROR_CRASH \ -{ \ - crashdriver([](int* ptr){ *ptr = 0; exit(*ptr); }); \ +#define LLERROR_CRASH \ +{ \ + int* make_me_crash = (int*)0xDEADBEEFDEADBEEFUL; \ + *make_me_crash = 0; \ + exit(*make_me_crash); \ } #define LL_ENDL \ @@ -512,7 +514,4 @@ LL_DEBUGS("SomeTag") performs the locking and map-searching ONCE, then caches the result in a static variable. */ -// used by LLERROR_CRASH -void crashdriver(void (*)(int*)); - #endif // LL_LLERROR_H -- cgit v1.2.3 From 11afd7f86afd19fde8b577f57736d6d27542484e 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: Add error handling for intel crashes from GLTF Scene shader (#2456) fix secondlife/viewer#1856 --- indra/newview/app_settings/settings.xml | 11 +++++++++++ indra/newview/gltfscenemanager.cpp | 8 ++++++++ indra/newview/llviewermenu.cpp | 15 +++++++++++++-- indra/newview/llviewershadermgr.cpp | 9 ++++++++- indra/newview/skins/default/xui/en/notifications.xml | 11 +++++++++++ 5 files changed, 51 insertions(+), 3 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 483c8774a7..5e7ae32b81 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -7172,6 +7172,17 @@ 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 086f41c1cb..e55d630940 100644 --- a/indra/newview/gltfscenemanager.cpp +++ b/indra/newview/gltfscenemanager.cpp @@ -45,6 +45,7 @@ #include "llfloaterreg.h" #include "llagentbenefits.h" #include "llfilesystem.h" +#include "llviewercontrol.h" #include "boost/json.hpp" #define GLTF_SIM_SUPPORT 1 @@ -618,6 +619,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 97d5781566..e1664752e7 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -3414,7 +3414,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() @@ -8207,7 +8209,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 073a1787d5..c98bd9b7e2 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1336,7 +1336,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 e539388735..5ce73b2cfa 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -12572,4 +12572,15 @@ are wearing now. yestext="OK"/> + + GLTF scenes are not yet supported on your graphics hardware. + fail + + + -- cgit v1.2.3 From b0fefd62adbf51f32434ba077e9f52d8a9241d15 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 29 Aug 2024 15:06:24 -0500 Subject: #2428 Fix for crash when applying PBR material to a single face (take 2) (#2463) Also fix for some objects randomly disappearing until they're selected again. --- indra/newview/llface.cpp | 5 +++-- indra/newview/llvovolume.cpp | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 9e504402c8..581328b3cb 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -573,7 +573,6 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color) if (LLGLTFMaterial* gltf_mat = te->getGLTFRenderMaterial()) { vertex_buffer = mVertexBufferGLTF.get(); - vertex_buffer->unmapBuffer(); } } // Draw the selection marker using the correctly chosen vertex buffer @@ -1220,7 +1219,8 @@ bool LLFace::getGeometryVolume(const LLVolume& volume, mVertexBufferGLTF = new LLVertexBuffer(mVertexBuffer->getTypeMask()); } - // Clone the existing vertex buffer into the temporary one + // Clone the existing vertex buffer into the temporary one + // TODO: factor out the need for mVertexBufferGLTF and make selection highlight shader work with the existing vertex buffer mVertexBuffer->clone(*mVertexBufferGLTF); // Recursive call the same function with the argument rebuild_for_gltf set to true @@ -1228,6 +1228,7 @@ bool LLFace::getGeometryVolume(const LLVolume& volume, mVertexBufferGLTF.swap(mVertexBufferGLTF, mVertexBuffer); getGeometryVolume(volume, face_index, mat_vert_in, mat_norm_in, index_offset, force_rebuild, no_debug_assert, true); mVertexBufferGLTF.swap(mVertexBufferGLTF, mVertexBuffer); + mVertexBufferGLTF->unmapBuffer(); } else if (!tep->isSelected() && mVertexBufferGLTF.notNull()) { diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index dcaf85b894..669ccb0924 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5765,9 +5765,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) continue; } - if (facep->hasGeometry() && - (rigged || // <-- HACK FIXME -- getPixelArea might be incorrect for rigged objects - facep->getPixelArea() > FORCE_CULL_AREA)) // <-- don't render tiny faces + if (facep->hasGeometry()) { cur_total += facep->getGeomCount(); -- cgit v1.2.3