From a27515748fd1fd14a12ffc7f12b415decf6099de Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 2 Jan 2025 17:31:23 +0200 Subject: [PATCH 1/6] #3311 RenderSkyAutoAdjustLegacy does not engage tonemapper --- indra/llinventory/llsettingssky.cpp | 22 +++++++++++----------- indra/llinventory/llsettingssky.h | 8 ++++---- indra/newview/llsettingsvo.cpp | 2 +- indra/newview/pipeline.cpp | 14 +++++++------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 50b458de14..be64578d54 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -2032,43 +2032,43 @@ F32 LLSettingsSky::getGamma() const return mGamma; } -F32 LLSettingsSky::getHDRMin() const +F32 LLSettingsSky::getHDRMin(bool auto_adjust) const { - if (mCanAutoAdjust) + if (mCanAutoAdjust && !auto_adjust) return 0.f; return mHDRMin; } -F32 LLSettingsSky::getHDRMax() const +F32 LLSettingsSky::getHDRMax(bool auto_adjust) const { - if (mCanAutoAdjust) + if (mCanAutoAdjust && !auto_adjust) return 0.f; return mHDRMax; } -F32 LLSettingsSky::getHDROffset() const +F32 LLSettingsSky::getHDROffset(bool auto_adjust) const { - if (mCanAutoAdjust) + if (mCanAutoAdjust && !auto_adjust) return 1.0f; return mHDROffset; } -F32 LLSettingsSky::getTonemapMix() const +F32 LLSettingsSky::getTonemapMix(bool auto_adjust) const { - if (mCanAutoAdjust) + if (mCanAutoAdjust && !auto_adjust) + { + // legacy settings do not support tonemaping return 0.0f; + } return mTonemapMix; } void LLSettingsSky::setTonemapMix(F32 mix) { - if (mCanAutoAdjust) - return; - mTonemapMix = mix; } diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 4c635fd946..801fafff4b 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -209,10 +209,10 @@ public: F32 getGamma() const; - F32 getHDRMin() const; - F32 getHDRMax() const; - F32 getHDROffset() const; - F32 getTonemapMix() const; + F32 getHDRMin(bool auto_adjust = false) const; + F32 getHDRMax(bool auto_adjust = false) const; + F32 getHDROffset(bool auto_adjust = false) const; + F32 getTonemapMix(bool auto_adjust = false) const; void setTonemapMix(F32 mix); void setGamma(F32 val); diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index cf96072ae2..6f9d4a24bc 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -807,7 +807,7 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force) static LLCachedControl tonemap_mix_setting(gSavedSettings, "RenderTonemapMix", 1.f); // sky is a "classic" sky following pre SL 7.0 shading - bool classic_mode = psky->canAutoAdjust(); + bool classic_mode = psky->canAutoAdjust() && !should_auto_adjust(); if (!classic_mode) { diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1ca67dd88a..38f158c1df 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7076,7 +7076,7 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst, bool LLSettingsSky::ptr_t sky = LLEnvironment::instance().getCurrentSky(); - F32 probe_ambiance = LLEnvironment::instance().getCurrentSky()->getReflectionProbeAmbiance(should_auto_adjust); + F32 probe_ambiance = LLEnvironment::instance().getCurrentSky()->getReflectionProbeAmbiance(should_auto_adjust()); F32 exp_min = 1.f; F32 exp_max = 1.f; @@ -7087,13 +7087,13 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst, bool { if (dynamic_exposure_enabled) { - exp_min = sky->getHDROffset() - sky->getHDRMin(); - exp_max = sky->getHDROffset() + sky->getHDRMax(); + exp_min = sky->getHDROffset(should_auto_adjust()) - sky->getHDRMin(should_auto_adjust()); + exp_max = sky->getHDROffset(should_auto_adjust()) + sky->getHDRMax(should_auto_adjust()); } else { - exp_min = sky->getHDROffset(); - exp_max = sky->getHDROffset(); + exp_min = sky->getHDROffset(should_auto_adjust()); + exp_max = sky->getHDROffset(should_auto_adjust()); } } else if (dynamic_exposure_enabled) @@ -7113,7 +7113,7 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst, bool shader->uniform1f(dt, gFrameIntervalSeconds); shader->uniform2f(noiseVec, ll_frand() * 2.0f - 1.0f, ll_frand() * 2.0f - 1.0f); shader->uniform4f(dynamic_exposure_params, dynamic_exposure_coefficient, exp_min, exp_max, dynamic_exposure_speed_error); - shader->uniform4f(dynamic_exposure_params2, sky->getHDROffset(), exp_min, exp_max, dynamic_exposure_speed_target); + shader->uniform4f(dynamic_exposure_params2, sky->getHDROffset(should_auto_adjust()), exp_min, exp_max, dynamic_exposure_speed_target); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); @@ -7171,7 +7171,7 @@ void LLPipeline::tonemap(LLRenderTarget* src, LLRenderTarget* dst) static LLCachedControl tonemap_type_setting(gSavedSettings, "RenderTonemapType", 0U); shader.uniform1i(tonemap_type, tonemap_type_setting); - shader.uniform1f(tonemap_mix, psky->getTonemapMix()); + shader.uniform1f(tonemap_mix, psky->getTonemapMix(should_auto_adjust())); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); From cba1807a9164442880dbcbd48e1faff7a82153c7 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Thu, 2 Jan 2025 14:42:49 -0500 Subject: [PATCH 2/6] #3326 Skip ambient probe sampling when we're in classic mode. Ensure that our passed in ambient lighting is the only thing that gets applied. (#3327) --- .../shaders/class3/deferred/reflectionProbeF.glsl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 5dfa196cf6..a975b1f121 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -38,6 +38,8 @@ uniform float max_probe_lod; uniform bool transparent_surface; +uniform int classic_mode; + #define MAX_REFMAP_COUNT 256 // must match LL_MAX_REFLECTION_PROBE_COUNT layout (std140) uniform ReflectionProbes @@ -739,7 +741,10 @@ void doProbeSample(inout vec3 ambenv, inout vec3 glossenv, vec3 refnormpersp = reflect(pos.xyz, norm.xyz); - ambenv = sampleProbeAmbient(pos, norm, amblit); + ambenv = amblit; + + if (classic_mode == 0) + ambenv = sampleProbeAmbient(pos, norm, amblit); float lod = (1.0-glossiness)*reflection_lods; glossenv = sampleProbes(pos, normalize(refnormpersp), lod); @@ -845,7 +850,10 @@ void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 refnormpersp = reflect(pos.xyz, norm.xyz); - ambenv = sampleProbeAmbient(pos, norm, amblit); + ambenv = amblit; + + if (classic_mode == 0) + ambenv = sampleProbeAmbient(pos, norm, amblit); if (glossiness > 0.0) { From a259316dc6212744194f340246b840e0a42b0191 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 2 Jan 2025 23:01:14 +0200 Subject: [PATCH 3/6] #3329 Crash at LLSpatialGroup::dirtyGeom --- indra/newview/llvovolume.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 6514db0814..99f31f33df 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -645,8 +645,12 @@ void LLVOVolume::animateTextures() // LLVOVolume::updateTextureVirtualSize when the // mTextureMatrix is not yet present gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD); - mDrawable->getSpatialGroup()->dirtyGeom(); - gPipeline.markRebuild(mDrawable->getSpatialGroup()); + LLSpatialGroup* group = mDrawable->getSpatialGroup(); + if (group) + { + group->dirtyGeom(); + gPipeline.markRebuild(group); + } } } From 85162a4f609efaf3aa7412c6cd422f3900ba0cb3 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 2 Jan 2025 23:08:38 +0200 Subject: [PATCH 4/6] #3302 Crash at LLSaveFolderState::doFolder --- indra/newview/llpanelcontents.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/indra/newview/llpanelcontents.cpp b/indra/newview/llpanelcontents.cpp index 2624ef1207..7910bcb41d 100644 --- a/indra/newview/llpanelcontents.cpp +++ b/indra/newview/llpanelcontents.cpp @@ -145,6 +145,7 @@ void LLPanelContents::onFilterEdit() } else { + LLFolderView* root_folder = mPanelInventoryObject->getRootFolder(); if (filter_substring.empty()) { if (mPanelInventoryObject->getFilter().getFilterSubString().empty()) @@ -155,19 +156,28 @@ void LLPanelContents::onFilterEdit() if (mDirtyFilter && !mSavedFolderState.hasOpenFolders()) { - mPanelInventoryObject->getRootFolder()->setOpenArrangeRecursively(true, LLFolderViewFolder::ERecurseType::RECURSE_DOWN); + if (root_folder) + { + root_folder->setOpenArrangeRecursively(true, LLFolderViewFolder::ERecurseType::RECURSE_DOWN); + } } else { mSavedFolderState.setApply(true); - mPanelInventoryObject->getRootFolder()->applyFunctorRecursively(mSavedFolderState); + if (root_folder) + { + root_folder->applyFunctorRecursively(mSavedFolderState); + } } mDirtyFilter = false; // Add a folder with the current item to the list of previously opened folders - LLOpenFoldersWithSelection opener; - mPanelInventoryObject->getRootFolder()->applyFunctorRecursively(opener); - mPanelInventoryObject->getRootFolder()->scrollToShowSelection(); + if (root_folder) + { + LLOpenFoldersWithSelection opener; + root_folder->applyFunctorRecursively(opener); + root_folder->scrollToShowSelection(); + } } else if (mPanelInventoryObject->getFilter().getFilterSubString().empty()) { @@ -175,7 +185,10 @@ void LLPanelContents::onFilterEdit() if (!mPanelInventoryObject->getFilter().isNotDefault()) { mSavedFolderState.setApply(false); - mPanelInventoryObject->getRootFolder()->applyFunctorRecursively(mSavedFolderState); + if (root_folder) + { + root_folder->applyFunctorRecursively(mSavedFolderState); + } mDirtyFilter = false; } } From edebc8f7a785be10753eb0b826b5fac3905e34ca Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 6 Jan 2025 17:54:23 +0200 Subject: [PATCH 5/6] #3344 Crash at LLFloater::openFloater --- indra/newview/llstartup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index b32b80331a..3726a95f64 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1507,7 +1507,7 @@ bool idle_startup() // create a container's instance for start a controlling conversation windows // by the voice's events LLFloaterIMContainer *im_inst = LLFloaterIMContainer::getInstance(); - if(gAgent.isFirstLogin()) + if(gAgent.isFirstLogin() && im_inst) { im_inst->openFloater(im_inst->getKey()); } From 12303e21c9bfa6a32bef2a6a5f2f5a7978356b50 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 6 Jan 2025 22:54:59 +0200 Subject: [PATCH 6/6] #3347 Crashes in LLFontFreetype::renderGlyph Try to handle this more gracefully, but primary purpose of this change is to log wchars in case issue is reproducible. --- indra/llrender/llfontfreetype.cpp | 25 +++++++++++++++++++++---- indra/llrender/llfontfreetype.h | 2 +- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index 6128e03fa7..1f14d82bf1 100644 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -552,7 +552,7 @@ LLFontGlyphInfo* LLFontFreetype::addGlyphFromFont(const LLFontFreetype *fontp, l return NULL; llassert(!mIsFallback); - fontp->renderGlyph(requested_glyph_type, glyph_index); + fontp->renderGlyph(requested_glyph_type, glyph_index, wch); EFontGlyphType bitmap_glyph_type = EFontGlyphType::Unspecified; switch (fontp->mFTFace->glyph->bitmap.pixel_mode) @@ -697,7 +697,7 @@ void LLFontFreetype::insertGlyphInfo(llwchar wch, LLFontGlyphInfo* gi) const } } -void LLFontFreetype::renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index) const +void LLFontFreetype::renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index, llwchar wch) const { if (mFTFace == NULL) return; @@ -712,11 +712,28 @@ void LLFontFreetype::renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index) co FT_Error error = FT_Load_Glyph(mFTFace, glyph_index, load_flags); if (FT_Err_Ok != error) { + if (error == FT_Err_Out_Of_Memory) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Out of memory loading glyph for character " << wch << LL_ENDL; + } + std::string message = llformat( - "Error %d (%s) loading glyph %u: bitmap_type=%u, load_flags=%d", - error, FT_Error_String(error), glyph_index, bitmap_type, load_flags); + "Error %d (%s) loading wchar %u glyph %u/%u: bitmap_type=%u, load_flags=%d", + error, FT_Error_String(error), wch, glyph_index, mFTFace->num_glyphs, bitmap_type, load_flags); LL_WARNS_ONCE() << message << LL_ENDL; error = FT_Load_Glyph(mFTFace, glyph_index, load_flags ^ FT_LOAD_COLOR); + if (FT_Err_Invalid_Outline == error + || FT_Err_Invalid_Composite == error + || (FT_Err_Ok != error && LLStringOps::isEmoji(wch))) + { + glyph_index = FT_Get_Char_Index(mFTFace, '?'); + // if '?' is not present, potentially can use last index, that's supposed to be null glyph + if (glyph_index > 0) + { + error = FT_Load_Glyph(mFTFace, glyph_index, load_flags ^ FT_LOAD_COLOR); + } + } llassert_always_msg(FT_Err_Ok == error, message.c_str()); } diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h index eba89f5def..1ad795060a 100644 --- a/indra/llrender/llfontfreetype.h +++ b/indra/llrender/llfontfreetype.h @@ -156,7 +156,7 @@ private: bool hasGlyph(llwchar wch) const; // Has a glyph for this character LLFontGlyphInfo* addGlyph(llwchar wch, EFontGlyphType glyph_type) const; // Add a new character to the font if necessary LLFontGlyphInfo* addGlyphFromFont(const LLFontFreetype *fontp, llwchar wch, U32 glyph_index, EFontGlyphType bitmap_type) const; // Add a glyph from this font to the other (returns the glyph_index, 0 if not found) - void renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index) const; + void renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index, llwchar wch) const; void insertGlyphInfo(llwchar wch, LLFontGlyphInfo* gi) const; std::string mName;