From 50d9e332ac1eadba6f5642e655b2219c15250c15 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 13 May 2021 02:35:45 +0300 Subject: [PATCH 1/2] SL-15225 llSetAgentEnvironment cloud density transition doesn't work --- indra/newview/llenvironment.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 0cdafcba81..42f3d15a1c 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -611,6 +611,7 @@ namespace specialSet.insert(SETTING_CLOUD_TEXTUREID); specialSet.insert(SETTING_MOON_TEXTUREID); specialSet.insert(SETTING_SUN_TEXTUREID); + specialSet.insert(SETTING_CLOUD_SHADOW); // due to being part of skips } return specialSet; } @@ -651,6 +652,7 @@ namespace template<> void LLSettingsInjected::updateSpecial(const typename LLSettingsInjected::Injection::ptr_t &injection, typename LLSettingsBase::BlendFactor mix) { + bool is_texture = true; if (injection->mKeyName == SETTING_SUN_TEXTUREID) { mNextSunTextureId = injection->mValue.asUUID(); @@ -675,9 +677,29 @@ namespace { mNextHaloTextureId = injection->mValue.asUUID(); } + else if (injection->mKeyName == LLSettingsSky::SETTING_CLOUD_SHADOW) + { + // Special case due to being texture dependent and part of skips + is_texture = false; + if (!injection->mBlendIn) + mix = 1.0 - mix; + stringset_t dummy; + LLUUID cloud_noise_id = getCloudNoiseTextureId(); + F64 value = this->mSettings[injection->mKeyName].asReal(); + if (this->getCloudNoiseTextureId().isNull()) + { + value = 0; // there was no texture so start from zero coverage + } + // Ideally we need to check for texture in injection, but + // in this case user is setting value explicitly, potentially + // with different transitions, don't ignore it + F64 result = lerp(value, injection->mValue.asReal(), mix); + injection->mLastValue = LLSD::Real(result); + this->mSettings[injection->mKeyName] = injection->mLastValue; + } // Unfortunately I don't have a per texture blend factor. We'll just pick the one that is furthest along. - if (getBlendFactor() < mix) + if (is_texture && getBlendFactor() < mix) { setBlendFactor(mix); } From 1a440be5e1760ac95e9a1ef43e5c74b768726826 Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Wed, 19 Jan 2022 10:35:58 -0600 Subject: [PATCH 2/2] SL-16653 Fix for some textures having incorrect texel colors after the first row (and add more paranoia checks on texture data). --- indra/llrender/llrender.cpp | 8 ++++++ indra/newview/llviewertexture.cpp | 42 +++++++++++++++++++++++++++---- indra/newview/llviewerwindow.cpp | 9 ------- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 3b46eef1b4..92d8e6193f 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -860,6 +860,14 @@ LLRender::~LLRender() void LLRender::init() { + glPixelStorei(GL_PACK_ALIGNMENT, 1); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + gGL.setSceneBlendType(LLRender::BT_ALPHA); + gGL.setAmbientLightColor(LLColor4::black); + + glCullFace(GL_BACK); + if (sGLCoreProfile && !LLVertexBuffer::sUseVAO) { //bind a dummy vertex array object so we're core profile compliant #ifdef GL_ARB_vertex_array_object diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 06f623f1f8..5fed46f437 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -1626,10 +1626,21 @@ void LLViewerFetchedTexture::scheduleCreateTexture() { if (!mNeedsCreateTexture) { - ref(); mNeedsCreateTexture = TRUE; if (preCreateTexture()) { + ref(); +#if LL_IMAGEGL_THREAD_CHECK + //grab a copy of the raw image data to make sure it isn't modified pending texture creation + U8* data = mRawImage->getData(); + U8* data_copy = nullptr; + S32 size = mRawImage->getDataSize(); + if (data != nullptr && size > 0) + { + data_copy = new U8[size]; + memcpy(data_copy, data, size); + } +#endif mNeedsCreateTexture = TRUE; auto mainq = LLImageGLThread::sEnabled ? mMainQueue.lock() : nullptr; if (mainq) @@ -1637,19 +1648,40 @@ void LLViewerFetchedTexture::scheduleCreateTexture() mainq->postTo( mImageQueue, // work to be done on LLImageGL worker thread +#if LL_IMAGEGL_THREAD_CHECK + [this, data, data_copy, size]() + { + mGLTexturep->mActiveThread = LLThread::currentID(); + //verify data is unmodified + llassert(data == mRawImage->getData()); + llassert(mRawImage->getDataSize() == size); + llassert(memcmp(data, data_copy, size) == 0); +#else [this]() { -#if LL_IMAGEGL_THREAD_CHECK - mGLTexturep->mActiveThread = LLThread::currentID(); #endif //actually create the texture on a background thread createTexture(); + +#if LL_IMAGEGL_THREAD_CHECK + //verify data is unmodified + llassert(data == mRawImage->getData()); + llassert(mRawImage->getDataSize() == size); + llassert(memcmp(data, data_copy, size) == 0); +#endif }, // callback to be run on main thread - [this]() - { #if LL_IMAGEGL_THREAD_CHECK + [this, data, data_copy, size]() + { mGLTexturep->mActiveThread = LLThread::currentID(); + llassert(data == mRawImage->getData()); + llassert(mRawImage->getDataSize() == size); + llassert(memcmp(data, data_copy, size) == 0); + delete[] data_copy; +#else + [this]() + { #endif //finalize on main thread postCreateTexture(); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 2fc4e9d0bd..b9a5e90df0 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2058,15 +2058,6 @@ std::string LLViewerWindow::getLastSnapshotDir() void LLViewerWindow::initGLDefaults() { - gGL.setSceneBlendType(LLRender::BT_ALPHA); - - glPixelStorei(GL_PACK_ALIGNMENT,1); - glPixelStorei(GL_UNPACK_ALIGNMENT,1); - - gGL.setAmbientLightColor(LLColor4::black); - - glCullFace(GL_BACK); - // RN: Need this for translation and stretch manip. gBox.prerender(); }