From 1b4814f0e5784b3c339328cccde070dc7c20606b Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 28 Nov 2024 20:19:51 +0200 Subject: [PATCH 1/9] viewer#3170 Fix tonemaping slider At the moment slider is in general settings, not per environment --- indra/llinventory/llsettingssky.cpp | 9 --------- indra/llinventory/llsettingssky.h | 2 -- indra/newview/pipeline.cpp | 10 +++++++++- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index f773b64bde..17d259a163 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -1180,7 +1180,6 @@ void LLSettingsSky::loadValuesFromLLSD() mHDRMax = 2.0f; mHDRMin = 0.5f; mHDROffset = 1.0f; - mTonemapMix = 1.0f; mSunTextureId = settings[SETTING_SUN_TEXTUREID].asUUID(); mMoonTextureId = settings[SETTING_MOON_TEXTUREID].asUUID(); @@ -2056,14 +2055,6 @@ F32 LLSettingsSky::getHDROffset() const return mHDROffset; } -F32 LLSettingsSky::getTonemapMix() const -{ - if (mCanAutoAdjust) - return 0.0f; - - return mTonemapMix; -} - void LLSettingsSky::setGamma(F32 val) { mGamma = val; diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 8d73c35ff3..f61f8af116 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -212,7 +212,6 @@ public: F32 getHDRMin() const; F32 getHDRMax() const; F32 getHDROffset() const; - F32 getTonemapMix() const; void setGamma(F32 val); @@ -385,7 +384,6 @@ protected: F32 mCloudVariance; F32 mCloudShadow; F32 mCloudScale; - F32 mTonemapMix; F32 mHDROffset; F32 mHDRMax; F32 mHDRMin; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 3b51cbfbb2..037dfd1d66 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7152,7 +7152,15 @@ void LLPipeline::tonemap(LLRenderTarget* src, LLRenderTarget* dst) shader.uniform1i(tonemap_type, tonemap_type_setting); static LLCachedControl tonemap_mix_setting(gSavedSettings, "RenderTonemapMix", 1.f); - shader.uniform1f(tonemap_mix, psky->getTonemapMix()); + if (psky->canAutoAdjust()) + { + // Legacy skies + shader.uniform1f(tonemap_mix, 0.f); + } + else + { + shader.uniform1f(tonemap_mix, tonemap_mix_setting()); + } mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); From 5ac2adfa280ad589de7530c6d72db09c7788b27f Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Fri, 29 Nov 2024 00:16:20 +0200 Subject: [PATCH 2/9] #3133 add handler to prevent crash when preview gets closed before getting the callback --- indra/newview/llmodelpreview.cpp | 43 +++++++++++++++++++++----------- indra/newview/llmodelpreview.h | 4 +-- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index d61333c2cc..29ab4e38c0 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -555,7 +555,7 @@ void LLModelPreview::rebuildUploadData() { // in case user provided a missing file later texture->setIsMissingAsset(false); - texture->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, this, &mCallbackTextureList, false); + texture->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, new LLHandle(getHandle()), &mCallbackTextureList, false); texture->forceToSaveRawImage(0, F32_MAX); texture->updateFetch(); if (mModelLoader) @@ -784,6 +784,10 @@ void LLModelPreview::loadModel(std::string filename, S32 lod, bool force_disable std::map joint_alias_map; getJointAliases(joint_alias_map); + LLHandle preview_handle = getHandle(); + auto load_textures_cb = + [preview_handle](LLImportMaterial& material, void* opaque) { return LLModelPreview::loadTextures(material, preview_handle); }; + // three possible file extensions, .dae .gltf .glb // check for .dae and if not then assume one of the .gl?? std::string filename_lc(filename); @@ -795,7 +799,7 @@ void LLModelPreview::loadModel(std::string filename, S32 lod, bool force_disable lod, &LLModelPreview::loadedCallback, &LLModelPreview::lookupJointByName, - &LLModelPreview::loadTextures, + load_textures_cb, &LLModelPreview::stateChangedCallback, this, mJointTransformMap, @@ -812,7 +816,7 @@ void LLModelPreview::loadModel(std::string filename, S32 lod, bool force_disable lod, &LLModelPreview::loadedCallback, &LLModelPreview::lookupJointByName, - &LLModelPreview::loadTextures, + load_textures_cb, &LLModelPreview::stateChangedCallback, this, mJointTransformMap, @@ -3130,9 +3134,9 @@ LLJoint* LLModelPreview::lookupJointByName(const std::string& str, void* opaque) return NULL; } -U32 LLModelPreview::loadTextures(LLImportMaterial& material, void* opaque) +U32 LLModelPreview::loadTextures(LLImportMaterial& material, LLHandle handle) { - if (material.mDiffuseMapFilename.size()) + if (material.mDiffuseMapFilename.size() && !handle.isDead()) { material.mOpaqueData = new LLPointer< LLViewerFetchedTexture >; LLPointer< LLViewerFetchedTexture >& tex = (*reinterpret_cast< LLPointer< LLViewerFetchedTexture > * >(material.mOpaqueData)); @@ -3143,10 +3147,8 @@ U32 LLModelPreview::loadTextures(LLImportMaterial& material, void* opaque) // file was loaded previosly, reload image to get potential changes tex->clearFetchedResults(); } - // Todo: might cause a crash if preview gets closed before we get the callback. - // Use a callback list or guard callback in some way - LLModelPreview* preview = (LLModelPreview*)opaque; - tex->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, opaque, &preview->mCallbackTextureList, false); + LLModelPreview* preview = (LLModelPreview*)handle.get(); + tex->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, new LLHandle(handle), &preview->mCallbackTextureList, false); tex->forceToSaveRawImage(0, F32_MAX); material.setDiffuseMap(tex->getID()); // record tex ID return 1; @@ -4003,16 +4005,29 @@ void LLModelPreview::textureLoadedCallback( bool final, void* userdata) { - LLModelPreview* preview = (LLModelPreview*)userdata; - preview->refresh(); + if (!userdata) + return; - if (final && preview->mModelLoader) + LLHandle* handle = (LLHandle*)userdata; + + if (!handle->isDead()) { - if (preview->mModelLoader->mNumOfFetchingTextures > 0) + LLModelPreview* preview = static_cast(handle->get()); + preview->refresh(); + + if (final && preview->mModelLoader) { - preview->mModelLoader->mNumOfFetchingTextures--; + if (preview->mModelLoader->mNumOfFetchingTextures > 0) + { + preview->mModelLoader->mNumOfFetchingTextures--; + } } } + + if (final || !success) + { + delete handle; + } } // static diff --git a/indra/newview/llmodelpreview.h b/indra/newview/llmodelpreview.h index e236d7ced7..0873263587 100644 --- a/indra/newview/llmodelpreview.h +++ b/indra/newview/llmodelpreview.h @@ -111,7 +111,7 @@ static const std::string lod_label_name[NUM_LOD + 1] = "I went off the end of the lod_label_name array. Me so smart." }; -class LLModelPreview : public LLViewerDynamicTexture, public LLMutex +class LLModelPreview : public LLViewerDynamicTexture, public LLMutex, public LLHandleProvider { LOG_CLASS(LLModelPreview); @@ -211,7 +211,7 @@ protected: static void stateChangedCallback(U32 state, void* opaque); static LLJoint* lookupJointByName(const std::string&, void* opaque); - static U32 loadTextures(LLImportMaterial& material, void* opaque); + static U32 loadTextures(LLImportMaterial& material, LLHandle handle); void lookupLODModelFiles(S32 lod); From c02baded8464781fcb208676610727e677ac6907 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Thu, 28 Nov 2024 17:57:30 -0500 Subject: [PATCH 3/9] #3170 Fix for tonemapping not working with PBR skies. --- indra/llinventory/llsettingssky.cpp | 17 +++++++++++++++++ indra/llinventory/llsettingssky.h | 3 +++ indra/newview/llsettingsvo.cpp | 6 ++++++ indra/newview/pipeline.cpp | 12 +----------- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 17d259a163..50b458de14 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -1180,6 +1180,7 @@ void LLSettingsSky::loadValuesFromLLSD() mHDRMax = 2.0f; mHDRMin = 0.5f; mHDROffset = 1.0f; + mTonemapMix = 1.0f; mSunTextureId = settings[SETTING_SUN_TEXTUREID].asUUID(); mMoonTextureId = settings[SETTING_MOON_TEXTUREID].asUUID(); @@ -2055,6 +2056,22 @@ F32 LLSettingsSky::getHDROffset() const return mHDROffset; } +F32 LLSettingsSky::getTonemapMix() const +{ + if (mCanAutoAdjust) + return 0.0f; + + return mTonemapMix; +} + +void LLSettingsSky::setTonemapMix(F32 mix) +{ + if (mCanAutoAdjust) + return; + + mTonemapMix = mix; +} + void LLSettingsSky::setGamma(F32 val) { mGamma = val; diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index f61f8af116..4c635fd946 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -212,6 +212,8 @@ public: F32 getHDRMin() const; F32 getHDRMax() const; F32 getHDROffset() const; + F32 getTonemapMix() const; + void setTonemapMix(F32 mix); void setGamma(F32 val); @@ -384,6 +386,7 @@ protected: F32 mCloudVariance; F32 mCloudShadow; F32 mCloudScale; + F32 mTonemapMix; F32 mHDROffset; F32 mHDRMax; F32 mHDRMin; diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index b1bef4c4d8..836b181623 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -804,10 +804,16 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force) static LLCachedControl sunlight_scale(gSavedSettings, "RenderSkySunlightScale", 1.5f); static LLCachedControl sunlight_hdr_scale(gSavedSettings, "RenderHDRSkySunlightScale", 1.5f); static LLCachedControl ambient_scale(gSavedSettings, "RenderSkyAmbientScale", 1.5f); + 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(); + if (!classic_mode) + { + psky->setTonemapMix(tonemap_mix_setting); + } + shader->uniform1f(LLShaderMgr::SKY_SUNLIGHT_SCALE, hdr ? sunlight_hdr_scale : sunlight_scale); shader->uniform1f(LLShaderMgr::SKY_AMBIENT_SCALE, ambient_scale); shader->uniform1i(LLShaderMgr::CLASSIC_MODE, classic_mode); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 037dfd1d66..1221601c97 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7150,17 +7150,7 @@ void LLPipeline::tonemap(LLRenderTarget* src, LLRenderTarget* dst) static LLCachedControl tonemap_type_setting(gSavedSettings, "RenderTonemapType", 0U); shader.uniform1i(tonemap_type, tonemap_type_setting); - - static LLCachedControl tonemap_mix_setting(gSavedSettings, "RenderTonemapMix", 1.f); - if (psky->canAutoAdjust()) - { - // Legacy skies - shader.uniform1f(tonemap_mix, 0.f); - } - else - { - shader.uniform1f(tonemap_mix, tonemap_mix_setting()); - } + shader.uniform1f(tonemap_mix, psky->getTonemapMix()); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); From a88373a4fc720785f7508bd999abe62a43f617b7 Mon Sep 17 00:00:00 2001 From: Rye Date: Sun, 3 Nov 2024 10:37:11 -0500 Subject: [PATCH 4/9] Fix crash from null texture entry during updateTextureVirtualSize --- indra/newview/llvovolume.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 3ea91447cc..6514db0814 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -791,8 +791,10 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) for (S32 i = 0; i < num_faces; i++) { LLFace* face = mDrawable->getFace(i); - if (!face) continue; + if (!face || face->mExtents[0].equals3(face->mExtents[1])) continue; const LLTextureEntry *te = face->getTextureEntry(); + if (!te) continue; + LLViewerTexture *imagep = nullptr; U32 ch_min; U32 ch_max; @@ -811,8 +813,7 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) // Get _a_ non-null texture if possible (usually diffuse/basecolor, but could be something else) imagep = face->getTexture(ch); } - if (!imagep || !te || - face->mExtents[0].equals3(face->mExtents[1])) + if (!imagep) { continue; } From 9cc343b5ebaab50b273205f36b6604e64191caee Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 29 Nov 2024 15:52:11 +0200 Subject: [PATCH 5/9] #3093 #3055 World Map tiles are blurry #2 --- indra/newview/lltexturefetch.cpp | 45 ++++- indra/newview/lltexturefetch.h | 18 +- indra/newview/llviewertexture.cpp | 294 +++++++++++++++++------------- indra/newview/llviewertexture.h | 2 + 4 files changed, 231 insertions(+), 128 deletions(-) diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 5172fad29d..703030b978 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -2481,7 +2481,7 @@ S32 LLTextureFetch::createRequest(FTType f_type, const std::string& url, const L LL_PROFILE_ZONE_SCOPED; if (mDebugPause) { - return -1; + return CREATE_REQUEST_ERROR_DEFAULT; } if (f_type == FTT_SERVER_BAKE) @@ -2497,7 +2497,7 @@ S32 LLTextureFetch::createRequest(FTType f_type, const std::string& url, const L << host << " != " << worker->mHost << LL_ENDL; removeRequest(worker, true); worker = NULL; - return -1; + return CREATE_REQUEST_ERROR_MHOSTS; } } @@ -2550,13 +2550,13 @@ S32 LLTextureFetch::createRequest(FTType f_type, const std::string& url, const L { if (worker->wasAborted()) { - return -1; // need to wait for previous aborted request to complete + return CREATE_REQUEST_ERROR_ABORTED; // need to wait for previous aborted request to complete } worker->lockWorkMutex(); // +Mw if (worker->mState == LLTextureFetchWorker::DONE && worker->mDesiredSize == llmax(desired_size, TEXTURE_CACHE_ENTRY_SIZE) && worker->mDesiredDiscard == desired_discard) { worker->unlockWorkMutex(); // -Mw - return -1; // similar request has failed or is in a transitional state + return CREATE_REQUEST_ERROR_TRANSITION; // similar request has finished, failed or is in a transitional state } worker->mActiveCount++; worker->mNeedsAux = needs_aux; @@ -3149,6 +3149,43 @@ S32 LLTextureFetch::getFetchState(const LLUUID& id, F32& data_progress_p, F32& r return state; } +// Threads: T* +S32 LLTextureFetch::getLastFetchState(const LLUUID& id, S32& requested_discard, S32& decoded_discard, bool& decoded) +{ + LL_PROFILE_ZONE_SCOPED; + S32 state = LLTextureFetchWorker::INVALID; + + LLTextureFetchWorker* worker = getWorker(id); + if (worker) // Don't check haveWork, intent is to get whatever is in the worker + { + worker->lockWorkMutex(); // +Mw + state = worker->mState; + requested_discard = worker->mDesiredDiscard; + decoded_discard = worker->mDecodedDiscard; + decoded = worker->mDecoded; + worker->unlockWorkMutex(); // -Mw + } + return state; +} + +// Threads: T* +S32 LLTextureFetch::getLastRawImage(const LLUUID& id, + LLPointer& raw, LLPointer& aux) +{ + LL_PROFILE_ZONE_SCOPED; + S32 decoded_discard = -1; + LLTextureFetchWorker* worker = getWorker(id); + if (worker && !worker->haveWork() && worker->mDecodedDiscard >= 0) + { + worker->lockWorkMutex(); // +Mw + raw = worker->mRawImage; + aux = worker->mAuxImage; + decoded_discard = worker->mDecodedDiscard; + worker->unlockWorkMutex(); // -Mw + } + return decoded_discard; +} + void LLTextureFetch::dump() { LL_INFOS(LOG_TXT) << "LLTextureFetch ACTIVE_HTTP:" << LL_ENDL; diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index c2c5ec5acc..8ab90896dc 100644 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -76,6 +76,14 @@ public: // Threads: Tmain void shutDownImageDecodeThread(); + enum e_crete_request_errors + { + CREATE_REQUEST_ERROR_DEFAULT = -1, + CREATE_REQUEST_ERROR_MHOSTS = -2, + CREATE_REQUEST_ERROR_ABORTED = -3, + CREATE_REQUEST_ERROR_TRANSITION = -4, + }; + // Threads: T* (but Tmain mostly) S32 createRequest(FTType f_type, const std::string& url, const LLUUID& id, const LLHost& host, F32 priority, S32 w, S32 h, S32 c, S32 discard, bool needs_aux, bool can_use_http); @@ -114,12 +122,20 @@ public: // get the current fetch state, if any, from the given UUID S32 getFetchState(const LLUUID& id); - // @return Fetch state of given image and associates statistics + // @return Fetch state of an active given image and associates statistics // See also getStateString // Threads: T* S32 getFetchState(const LLUUID& id, F32& decode_progress_p, F32& requested_priority_p, U32& fetch_priority_p, F32& fetch_dtime_p, F32& request_dtime_p, bool& can_use_http); + // @return Fetch last state of given image + // Threads: T* + S32 getLastFetchState(const LLUUID& id, S32& requested_discard, S32 &decoded_discard, bool &decoded); + + // @return Fetch last raw image + // Threads: T* + S32 getLastRawImage(const LLUUID& id, LLPointer& raw, LLPointer& aux); + // Debug utility - generally not safe void dump(); diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 00e1ea4cd3..36cc9bf88f 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -1808,6 +1808,141 @@ void LLViewerFetchedTexture::setBoostLevel(S32 level) } } +bool LLViewerFetchedTexture::processFetchResults(S32& desired_discard, S32 current_discard, S32 fetch_discard, F32 decode_priority) +{ + // We may have data ready regardless of whether or not we are finished (e.g. waiting on write) + if (mRawImage.notNull()) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - has raw image"); + LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); + if (tester) + { + mIsFetched = true; + tester->updateTextureLoadingStats(this, mRawImage, LLAppViewer::getTextureFetch()->isFromLocalCache(mID)); + } + mRawDiscardLevel = fetch_discard; + if ((mRawImage->getDataSize() > 0 && mRawDiscardLevel >= 0) && + (current_discard < 0 || mRawDiscardLevel < current_discard)) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - data good"); + + // This is going to conflict with Develop, just pick from develop + // where it uses setDimensions instead of setTexelsPerImage + mFullWidth = mRawImage->getWidth() << mRawDiscardLevel; + mFullHeight = mRawImage->getHeight() << mRawDiscardLevel; + setTexelsPerImage(); + + if (mFullWidth > MAX_IMAGE_SIZE || mFullHeight > MAX_IMAGE_SIZE) + { + //discard all oversized textures. + destroyRawImage(); + LL_WARNS() << "oversize, setting as missing" << LL_ENDL; + setIsMissingAsset(); + mRawDiscardLevel = INVALID_DISCARD_LEVEL; + mIsFetching = false; + mLastPacketTimer.reset(); + } + else + { + mIsRawImageValid = true; + addToCreateTexture(); + } + + if (mBoostLevel == LLGLTexture::BOOST_ICON) + { + S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENSIONS; + S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENSIONS; + if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)) + { + // scale oversized icon, no need to give more work to gl + // since we got mRawImage from thread worker and image may be in use (ex: writing cache), make a copy + // + // BOOST_ICON gets scaling because profile icons can have a bunch of different formats, not just j2c + // Might need another pass to use discard for j2c and scaling for everything else. + mRawImage = mRawImage->scaled(expected_width, expected_height); + } + } + + if (mBoostLevel == LLGLTexture::BOOST_THUMBNAIL) + { + S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_THUMBNAIL_DIMENSIONS; + S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_THUMBNAIL_DIMENSIONS; + if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)) + { + // scale oversized icon, no need to give more work to gl + // since we got mRawImage from thread worker and image may be in use (ex: writing cache), make a copy + // + // Todo: probably needs to be remade to use discard, all thumbnails are supposed to be j2c, + // so no need to scale, should be posible to use discard to scale image down. + mRawImage = mRawImage->scaled(expected_width, expected_height); + } + } + + return true; + } + else + { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - data not needed"); + // Data is ready but we don't need it + // (received it already while fetcher was writing to disk) + destroyRawImage(); + return false; // done + } + } + + if (!mIsFetching) + { + if ((decode_priority > 0) + && (mRawDiscardLevel < 0 || mRawDiscardLevel == INVALID_DISCARD_LEVEL) + && mFetchState > 1) // 1 - initial, make sure fetcher did at least something + { + // We finished but received no data + if (getDiscardLevel() < 0) + { + if (getFTType() != FTT_MAP_TILE) + { + LL_WARNS() << mID + << " Fetch failure, setting as missing, decode_priority " << decode_priority + << " mRawDiscardLevel " << mRawDiscardLevel + << " current_discard " << current_discard + << " stats " << mLastHttpGetStatus.toHex() + << " worker state " << mFetchState + << LL_ENDL; + } + setIsMissingAsset(); + desired_discard = -1; + } + else + { + //LL_WARNS() << mID << ": Setting min discard to " << current_discard << LL_ENDL; + if (current_discard >= 0) + { + mMinDiscardLevel = current_discard; + //desired_discard = current_discard; + } + else + { + S32 dis_level = getDiscardLevel(); + mMinDiscardLevel = dis_level; + //desired_discard = dis_level; + } + } + destroyRawImage(); + } + else if (mRawImage.notNull()) + { + // We have data, but our fetch failed to return raw data + // *TODO: FIgure out why this is happening and fix it + // Potentially can happen when TEX_LIST_SCALE and TEX_LIST_STANDARD + // get requested for the same texture id at the same time + // (two textures, one fetcher) + destroyRawImage(); + } + } + + return true; +} + bool LLViewerFetchedTexture::updateFetch() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; @@ -1892,127 +2027,12 @@ bool LLViewerFetchedTexture::updateFetch() mFetchPriority, mFetchDeltaTime, mRequestDeltaTime, mCanUseHTTP); } - // We may have data ready regardless of whether or not we are finished (e.g. waiting on write) - if (mRawImage.notNull()) + if (!processFetchResults(desired_discard, current_discard, fetch_discard, decode_priority)) { - LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - has raw image"); - LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); - if (tester) - { - mIsFetched = true; - tester->updateTextureLoadingStats(this, mRawImage, LLAppViewer::getTextureFetch()->isFromLocalCache(mID)); - } - mRawDiscardLevel = fetch_discard; - if ((mRawImage->getDataSize() > 0 && mRawDiscardLevel >= 0) && - (current_discard < 0 || mRawDiscardLevel < current_discard)) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - data good"); - mFullWidth = mRawImage->getWidth() << mRawDiscardLevel; - mFullHeight = mRawImage->getHeight() << mRawDiscardLevel; - setTexelsPerImage(); - - if(mFullWidth > MAX_IMAGE_SIZE || mFullHeight > MAX_IMAGE_SIZE) - { - //discard all oversized textures. - destroyRawImage(); - LL_WARNS() << "oversize, setting as missing" << LL_ENDL; - setIsMissingAsset(); - mRawDiscardLevel = INVALID_DISCARD_LEVEL; - mIsFetching = false; - mLastPacketTimer.reset(); - } - else - { - mIsRawImageValid = true; - addToCreateTexture(); - } - - if (mBoostLevel == LLGLTexture::BOOST_ICON) - { - S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENSIONS; - S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENSIONS; - if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)) - { - // scale oversized icon, no need to give more work to gl - // since we got mRawImage from thread worker and image may be in use (ex: writing cache), make a copy - mRawImage = mRawImage->scaled(expected_width, expected_height); - } - } - - if (mBoostLevel == LLGLTexture::BOOST_THUMBNAIL) - { - S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_THUMBNAIL_DIMENSIONS; - S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_THUMBNAIL_DIMENSIONS; - if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)) - { - // scale oversized icon, no need to give more work to gl - // since we got mRawImage from thread worker and image may be in use (ex: writing cache), make a copy - mRawImage = mRawImage->scaled(expected_width, expected_height); - } - } - - return true; - } - else - { - LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - data not needed"); - // Data is ready but we don't need it - // (received it already while fetcher was writing to disk) - destroyRawImage(); - return false; // done - } + return false; } - if (!mIsFetching) - { - if ((decode_priority > 0) - && (mRawDiscardLevel < 0 || mRawDiscardLevel == INVALID_DISCARD_LEVEL) - && mFetchState > 1) // 1 - initial, make sure fetcher did at least something - { - // We finished but received no data - if (getDiscardLevel() < 0) - { - if (getFTType() != FTT_MAP_TILE) - { - LL_WARNS() << mID - << " Fetch failure, setting as missing, decode_priority " << decode_priority - << " mRawDiscardLevel " << mRawDiscardLevel - << " current_discard " << current_discard - << " stats " << mLastHttpGetStatus.toHex() - << " worker state " << mFetchState - << LL_ENDL; - } - setIsMissingAsset(); - desired_discard = -1; - } - else - { - //LL_WARNS() << mID << ": Setting min discard to " << current_discard << LL_ENDL; - if(current_discard >= 0) - { - mMinDiscardLevel = current_discard; - //desired_discard = current_discard; - } - else - { - S32 dis_level = getDiscardLevel(); - mMinDiscardLevel = dis_level; - //desired_discard = dis_level; - } - } - destroyRawImage(); - } - else if (mRawImage.notNull()) - { - // We have data, but our fetch failed to return raw data - // *TODO: FIgure out why this is happening and fix it - // Potentially can happen when TEX_LIST_SCALE and TEX_LIST_STANDARD - // get requested for the same texture id at the same time - // (two textures, one fetcher) - destroyRawImage(); - } - } - else + if (mIsFetching) { static const F32 MAX_HOLD_TIME = 5.0f; //seconds to wait before canceling fecthing if decode_priority is 0.f. if(decode_priority > 0.0f || mStopFetchingTimer.getElapsedTimeF32() > MAX_HOLD_TIME) @@ -2087,21 +2107,49 @@ bool LLViewerFetchedTexture::updateFetch() } // bypass texturefetch directly by pulling from LLTextureCache - S32 fetch_request_discard = -1; - fetch_request_discard = LLAppViewer::getTextureFetch()->createRequest(mFTType, mUrl, getID(), getTargetHost(), decode_priority, + S32 fetch_request_response = -1; + S32 worker_discard = -1; + fetch_request_response = LLAppViewer::getTextureFetch()->createRequest(mFTType, mUrl, getID(), getTargetHost(), decode_priority, w, h, c, desired_discard, needsAux(), mCanUseHTTP); - if (fetch_request_discard >= 0) + if (fetch_request_response >= 0) // positive values and 0 are discard values { LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - request created"); mHasFetcher = true; mIsFetching = true; // in some cases createRequest can modify discard, as an example // bake textures are always at discard 0 - mRequestedDiscardLevel = llmin(desired_discard, fetch_request_discard); + mRequestedDiscardLevel = llmin(desired_discard, fetch_request_response); mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority, mFetchPriority, mFetchDeltaTime, mRequestDeltaTime, mCanUseHTTP); } + else if (fetch_request_response == LLTextureFetch::CREATE_REQUEST_ERROR_TRANSITION) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - processing transition error"); + // Request wasn't created because similar one finished or is in a transitional state, check worker state + // As an example can happen if an image (like a server bake always fetches at dis 0), was scaled down to + // needed discard after fetching then sudenly needed higher dis and worker wasn't yet deleted. Worker + // discard will be identical to requested one and worker will have nothing new to do despite GL image + // not being up to data. + S32 desired_discard; + S32 decoded_discard; + bool decoded; + S32 fetch_state = LLAppViewer::getTextureFetch()->getLastFetchState(mID, desired_discard, decoded_discard, decoded); + if (fetch_state > 1 && decoded && decoded_discard >=0 && decoded_discard <= desired_discard) + { + // worker actually has the image + if (mRawImage.notNull()) sRawCount--; + if (mAuxRawImage.notNull()) sAuxCount--; + decoded_discard = LLAppViewer::getTextureFetch()->getLastRawImage(getID(), mRawImage, mAuxRawImage); + if (mRawImage.notNull()) sRawCount++; + if (mAuxRawImage.notNull()) + { + mHasAux = true; + sAuxCount++; + } + processFetchResults(desired_discard, current_discard, decoded_discard, decode_priority); + } + } // If createRequest() failed, that means one of two things: // 1. We're finishing up a request for this UUID, so we @@ -2923,7 +2971,7 @@ void LLViewerLODTexture::processTextureStats() mDesiredDiscardLevel = 0; } // Generate the request priority and render priority - else if (mDontDiscard || !mUseMipMaps || (getFTType() == FTT_MAP_TILE)) + else if (mDontDiscard || !mUseMipMaps) { mDesiredDiscardLevel = 0; if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT) diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 1da8548573..4241ef958f 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -423,6 +423,8 @@ private: void init(bool firstinit) ; void cleanup() ; + bool processFetchResults(S32& desired_discard, S32 current_discard, S32 fetch_discard, F32 decode_priority); + void saveRawImage() ; private: From 73420f4f34976eedb4d01855a71513a4c1bd95bb Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 3 Dec 2024 14:32:20 -0800 Subject: [PATCH 6/9] #3184 Fix for crash on some GPUs when setting quality to High or higher (#3201) --- indra/llrender/llgl.cpp | 1 + indra/llrender/llgl.h | 1 + indra/newview/featuretable.txt | 6 +++++- indra/newview/featuretable_mac.txt | 6 +++++- indra/newview/llfeaturemanager.cpp | 4 ++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index c5c9d50dee..1bc5e79835 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -1259,6 +1259,7 @@ bool LLGLManager::initGL() glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &mMaxIntegerSamples); glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &mMaxSampleMaskWords); glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples); + glGetIntegerv(GL_MAX_VARYING_VECTORS, &mMaxVaryingVectors); glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &mMaxUniformBlockSize); // sanity clamp max uniform block size to 64k just in case diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index f5b1e8d786..24ba4d6deb 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -88,6 +88,7 @@ public: S32 mGLMaxTextureSize; F32 mMaxAnisotropy = 0.f; S32 mMaxUniformBlockSize = 0; + S32 mMaxVaryingVectors = 0; // GL 4.x capabilities bool mHasCubeMapArray = false; diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index fceb81f061..01356c3949 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -1,4 +1,4 @@ -version 72 +version 73 // The version number above should be incremented IF AND ONLY IF some // change has been made that is sufficiently important to justify // resetting the graphics preferences of all users to the recommended @@ -428,3 +428,7 @@ RenderVintageMode 1 1 list TexUnit16orLess RenderTerrainPBRDetail 1 -1 + +list VaryingVectors16orLess +RenderTerrainPBRPlanarSampleCount 1 1 + diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 079e01076f..9688693850 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 66 +version 67 // The version number above should be incremented IF AND ONLY IF some // change has been made that is sufficiently important to justify // resetting the graphics preferences of all users to the recommended @@ -426,3 +426,7 @@ RenderReflectionProbeDetail 0 0 RenderReflectionsEnabled 0 0 RenderMirrors 0 0 RenderVintageMode 1 1 + +list VaryingVectors16orLess +RenderTerrainPBRPlanarSampleCount 1 1 + diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index 22ba20100e..2adc6e4a29 100644 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -721,6 +721,10 @@ void LLFeatureManager::applyBaseMasks() // Make extra sure that vintage mode also gets enabled. gSavedSettings.setBOOL("RenderVintageMode", true); } + if (gGLManager.mMaxVaryingVectors <= 16) + { + maskFeatures("VaryingVectors16orLess"); + } // now mask by gpu string // Replaces ' ' with '_' in mGPUString to deal with inability for parser to handle spaces From 30012801417fca3d4b7848e1bc40b7386ef573d8 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Tue, 3 Dec 2024 18:01:37 -0500 Subject: [PATCH 7/9] Additional tweaks to get skies closer to 6.6.17 in classic mode. (#3202) --- .../shaders/class1/deferred/deferredUtil.glsl | 19 ++++++++++++------- .../shaders/class2/deferred/alphaF.glsl | 15 +++++++++++---- .../shaders/class2/deferred/pbralphaF.glsl | 10 +++++++--- .../shaders/class3/deferred/materialF.glsl | 15 ++++++++++----- .../class3/deferred/multiPointLightF.glsl | 7 +++++-- .../shaders/class3/deferred/pointLightF.glsl | 7 +++++-- .../shaders/class3/deferred/softenLightF.glsl | 10 ++++++++-- .../shaders/class3/deferred/spotLightF.glsl | 7 +++++-- indra/newview/pipeline.cpp | 8 ++++++++ 9 files changed, 71 insertions(+), 27 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index b47fae73af..94711be473 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -544,8 +544,10 @@ vec3 pbrCalcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor, pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv, nl, diffPunc, specPunc); color = intensity * clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10)); } - - return color; + float final_scale = 1.0; + if (classic_mode > 0) + final_scale = 0.9; + return color * final_scale; } void calcDiffuseSpecular(vec3 baseColor, float metallic, inout vec3 diffuseColor, inout vec3 specularColor) @@ -576,22 +578,25 @@ vec3 pbrBaseLight(vec3 diffuseColor, vec3 specularColor, float metallic, vec3 v, // Depending on the sky, we combine these differently. if (classic_mode > 0) { + irradiance.rgb = srgb_to_linear(irradiance * 0.9); // BINGO + // Reconstruct the diffuse lighting that we do for blinn-phong materials here. // A special note about why we do some really janky stuff for classic mode. // Since adding classic mode, we've moved the lambertian diffuse multiply out from pbrPunctual and instead handle it in the different light type calcs. - // For classic mode, this baiscally introduces a double multiplication that we need to somehow avoid - // Using one of the old mobile gamma correction tricks (val * val to "linearize", sqrt(val) to bring back into sRGB), we can _mostly_ avert this // This will never be 100% correct, but at the very least we can make it look mostly correct with legacy skies and classic mode. - float da = pow(sqrt(nl), 1.2); + float da = pow(nl, 1.2); vec3 sun_contrib = vec3(min(da, scol)); // Multiply by PI to account for lambertian diffuse colors. Otherwise things will be too dark when lit by the sun on legacy skies. - sun_contrib = srgb_to_linear(color.rgb * 0.9 + linear_to_srgb(sun_contrib) * sunlit * 0.7) * M_PI; + sun_contrib = srgb_to_linear(linear_to_srgb(sun_contrib) * sunlit * 0.7) * M_PI; // Manually recombine everything here. We have to separate the shading to ensure that lighting is able to more closely match blinn-phong. - color.rgb = srgb_to_linear(iblDiff) + clamp(sun_contrib * (da * (diffPunc.rgb + specPunc.rgb) * scol), vec3(0), vec3(10)); + vec3 finalAmbient = irradiance.rgb * diffuseColor.rgb; // BINGO + vec3 finalSun = clamp(sun_contrib * ((diffPunc.rgb + specPunc.rgb) * scol), vec3(0), vec3(10)); // QUESTIONABLE BINGO? + color.rgb = srgb_to_linear(linear_to_srgb(finalAmbient) + (linear_to_srgb(finalSun) * 1.1)); + //color.rgb = sun_contrib * diffuseColor.rgb; } else { diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 89fe4b6007..02aaf24194 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -163,7 +163,10 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec // no spec for alpha shader... } - col = max(col, vec3(0)); + float final_scale = 1.0; + if (classic_mode > 0) + final_scale = 0.9; + col = max(col * final_scale, vec3(0)); return col; } @@ -241,7 +244,8 @@ void main() vec3 atten; calcAtmosphericVarsLinear(pos.xyz, norm, light_dir, sunlit, amblit, additive, atten); - + if (classic_mode > 0) + sunlit *= 1.35; vec3 sunlit_linear = sunlit; vec3 amblit_linear = amblit; @@ -296,11 +300,14 @@ void main() color.rgb = applySkyAndWaterFog(pos.xyz, additive, atten, color).rgb; #endif // #else // FOR_IMPOSTOR - + float final_scale = 1; + if (classic_mode > 0) + final_scale = 1.1; #ifdef IS_HUD color.rgb = linear_to_srgb(color.rgb); + final_scale = 1; #endif - frag_color = max(color, vec4(0)); + frag_color = max(color * final_scale, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl index cec844559f..0418f99459 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl @@ -43,6 +43,7 @@ uniform sampler2D lightMap; uniform int sun_up_factor; uniform vec3 sun_dir; uniform vec3 moon_dir; +uniform int classic_mode; out vec4 frag_color; @@ -160,7 +161,8 @@ void main() vec3 additive; vec3 atten; calcAtmosphericVarsLinear(pos.xyz, norm, light_dir, sunlit, amblit, additive, atten); - + if (classic_mode > 0) + sunlit *= 1.35; vec3 sunlit_linear = sunlit; vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; @@ -212,8 +214,10 @@ void main() color.rgb = applySkyAndWaterFog(pos.xyz, additive, atten, vec4(color, 1.0)).rgb; float a = basecolor.a*vertex_color.a; - - frag_color = max(vec4(color.rgb,a), vec4(0)); + float final_scale = 1; + if (classic_mode > 0) + final_scale = 1.1; + frag_color = max(vec4(color.rgb * final_scale,a), vec4(0)); } #else diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index e15317f5b5..7f871c0d5e 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -178,8 +178,10 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe } } } - - return max(col, vec3(0.0, 0.0, 0.0)); + float final_scale = 1.0; + if (classic_mode > 0) + final_scale = 0.9; + return max(col * final_scale, vec3(0.0, 0.0, 0.0)); } #else @@ -329,7 +331,8 @@ void main() vec3 additive; vec3 atten; calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten); - + if (classic_mode > 0) + sunlit *= 1.35; vec3 sunlit_linear = sunlit; vec3 amblit_linear = amblit; @@ -418,8 +421,10 @@ void main() glare *= 1.0-emissive; glare = min(glare, 1.0); float al = max(diffcol.a, glare) * vertex_color.a; - - frag_color = max(vec4(color, al), vec4(0)); + float final_scale = 1; + if (classic_mode > 0) + final_scale = 1.1; + frag_color = max(vec4(color * final_scale, al), vec4(0)); #else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer // deferred path // See: C++: addDeferredAttachment(), shader: softenLightF.glsl diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl index 8db3bcd363..96cda1ef49 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl @@ -38,6 +38,7 @@ uniform vec4 light_col[LIGHT_COUNT]; // .a = falloff uniform vec2 screen_res; uniform float far_z; uniform mat4 inv_proj; +uniform int classic_mode; in vec4 vary_fragcoord; @@ -169,8 +170,10 @@ void main() } } } - - frag_color.rgb = max(final_color, vec3(0)); + float final_scale = 1.0; + if (classic_mode > 0) + final_scale = 0.9; + frag_color.rgb = max(final_color * final_scale, vec3(0)); frag_color.a = 0.0; #ifdef IS_AMD_CARD diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl index 987089fcc9..ceb37f36a5 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl @@ -44,6 +44,7 @@ uniform vec2 screen_res; uniform mat4 inv_proj; uniform vec4 viewport; +uniform int classic_mode; void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist); float calcLegacyDistanceAttenuation(float distance, float falloff); @@ -149,7 +150,9 @@ void main() discard; } } - - frag_color.rgb = max(final_color, vec3(0)); + float final_scale = 1.0; + if (classic_mode > 0) + final_scale = 0.9; + frag_color.rgb = max(final_color * final_scale, vec3(0)); frag_color.a = 0.0; } diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 52799dbba1..aac75a0739 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -155,6 +155,9 @@ void main() calcAtmosphericVarsLinear(pos.xyz, gb.normal, light_dir, sunlit, amblit, additive, atten); + if (classic_mode > 0) + sunlit *= 1.35; + vec3 sunlit_linear = sunlit; vec3 amblit_linear = amblit; @@ -224,7 +227,7 @@ void main() da = pow(da,1.2); vec3 sun_contrib = vec3(min(da, scol)); - color.rgb = srgb_to_linear(color.rgb * 0.9 + linear_to_srgb(sun_contrib) * sunlit_linear * 0.7); + color.rgb = srgb_to_linear(color.rgb * 0.9 + (linear_to_srgb(sun_contrib) * sunlit_linear * 0.7)); sunlit_linear = srgb_to_linear(sunlit_linear); } else @@ -272,6 +275,9 @@ void main() } //color.r = classic_mode > 0 ? 1.0 : 0.0; - frag_color.rgb = max(color.rgb, vec3(0)); //output linear since local lights will be added to this shader's results + float final_scale = 1; + if (classic_mode > 0) + final_scale = 1.1; + frag_color.rgb = max(color.rgb * final_scale, vec3(0)); //output linear since local lights will be added to this shader's results frag_color.a = 0.0; } diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl index 78db8ccf5b..a46e3688dc 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -47,6 +47,7 @@ uniform vec3 proj_origin; //origin of projection to be used for angular attenuat uniform float sun_wash; uniform int proj_shadow_idx; uniform float shadow_fade; +uniform int classic_mode; // Light params #if defined(MULTI_SPOTLIGHT) @@ -267,8 +268,10 @@ void main() //not sure why, but this line prevents MATBUG-194 final_color = max(final_color, vec3(0.0)); - + float final_scale = 1.0; + if (classic_mode > 0) + final_scale = 0.9; //output linear - frag_color.rgb = final_color; + frag_color.rgb = final_color * final_scale; frag_color.a = 0.0; } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1221601c97..e92d59e4e4 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8518,6 +8518,7 @@ void LLPipeline::renderDeferredLighting() std::list fullscreen_lights; LLDrawable::drawable_list_t spot_lights; LLDrawable::drawable_list_t fullscreen_spot_lights; + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); if (!gCubeSnapshot) { @@ -8613,6 +8614,8 @@ void LLPipeline::renderDeferredLighting() gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff(DEFERRED_LIGHT_FALLOFF)); + gDeferredLightProgram.uniform1i(LLShaderMgr::CLASSIC_MODE, (psky->canAutoAdjust()) ? 1 : 0); + gGL.syncMatrices(); mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); @@ -8673,6 +8676,8 @@ void LLPipeline::renderDeferredLighting() gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff(DEFERRED_LIGHT_FALLOFF)); + gDeferredSpotLightProgram.uniform1i(LLShaderMgr::CLASSIC_MODE, (psky->canAutoAdjust()) ? 1 : 0); + gGL.syncMatrices(); mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); @@ -8711,6 +8716,7 @@ void LLPipeline::renderDeferredLighting() gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*)light); gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*)col); gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); + gDeferredMultiLightProgram[idx].uniform1i(LLShaderMgr::CLASSIC_MODE, (psky->canAutoAdjust()) ? 1 : 0); far_z = 0.f; count = 0; mScreenTriangleVB->setBuffer(); @@ -8748,6 +8754,8 @@ void LLPipeline::renderDeferredLighting() gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, light_size_final); gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, light_falloff_final); + gDeferredMultiSpotLightProgram.uniform1i(LLShaderMgr::CLASSIC_MODE, (psky->canAutoAdjust()) ? 1 : 0); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } From 91692511a6a5071c09b7d1fa6b8f3b0a090abd4e Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Tue, 3 Dec 2024 18:20:44 -0500 Subject: [PATCH 8/9] Rename "Vintage Mode" to "HDR and Emissive" in advanced settings. (#3192) #2590 #3167 --- indra/newview/app_settings/settings.xml | 6 +++--- indra/newview/featuretable.txt | 12 ++++++------ indra/newview/featuretable_mac.txt | 15 +++++++-------- indra/newview/llfeaturemanager.cpp | 2 +- .../llfloaterpreferencesgraphicsadvanced.cpp | 12 ++++++------ indra/newview/llviewercontrol.cpp | 8 ++++---- .../en/floater_preferences_graphics_advanced.xml | 4 ++-- .../xui/en/panel_preferences_graphics1.xml | 2 +- 8 files changed, 30 insertions(+), 31 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 2d545fde07..65235b47af 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -16071,16 +16071,16 @@ Value 1 - RenderVintageMode + RenderDisableVintageMode Comment - Disable different rendering pipeline features to improve performance on older machines that makes the world look closer to how it used to prior to V7. + Enables additional rendering pipeline features on newer machines such as HDR and emissive textures on PBR content. Persist 1 Type Boolean Value - 0 + 1 diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index 01356c3949..920b197034 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -86,7 +86,7 @@ RenderTonemapType 1 1 RenderTonemapMix 1 1 RenderEnableEmissiveBuffer 1 1 RenderHDREnabled 1 1 -RenderVintageMode 1 1 +RenderDisableVintageMode 1 1 // // Low Graphics Settings @@ -127,7 +127,7 @@ RenderCASSharpness 1 0 RenderExposure 1 1 RenderTonemapType 1 1 RenderTonemapMix 1 0.7 -RenderVintageMode 1 1 +RenderDisableVintageMode 1 0 // // Medium Low Graphics Settings @@ -168,7 +168,7 @@ RenderCASSharpness 1 0 RenderExposure 1 1 RenderTonemapType 1 1 RenderTonemapMix 1 0.7 -RenderVintageMode 1 1 +RenderDisableVintageMode 1 0 // // Medium Graphics Settings (standard) @@ -378,7 +378,7 @@ RenderShadowDetail 1 0 RenderDeferredSSAO 1 0 RenderMirrors 1 0 RenderEnableEmissiveBuffer 1 0 -RenderVintageMode 1 1 +RenderDisableVintageMode 1 0 // // VRAM > 512MB @@ -401,7 +401,7 @@ RenderDeferredSSAO 0 0 RenderShadowDetail 0 0 RenderReflectionProbeDetail 0 -1 RenderMirrors 0 0 -RenderVintageMode 1 1 +RenderDisableVintageMode 1 0 list Intel RenderAnisotropic 1 0 @@ -424,7 +424,7 @@ RenderEnableEmissiveBuffer 1 0 RenderGLMultiThreadedTextures 0 0 RenderGLMultiThreadedMedia 0 0 RenderHDREnabled 1 0 -RenderVintageMode 1 1 +RenderDisableVintageMode 1 0 list TexUnit16orLess RenderTerrainPBRDetail 1 -1 diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 9688693850..b05e66fed6 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 67 +version 68 // The version number above should be incremented IF AND ONLY IF some // change has been made that is sufficiently important to justify // resetting the graphics preferences of all users to the recommended @@ -83,7 +83,7 @@ RenderCASSharpness 1 1 RenderExposure 1 1 RenderTonemapType 1 1 RenderTonemapMix 1 1 -RenderVintageMode 1 1 +RenderDisableVintageMode 1 1 // // Low Graphics Settings @@ -124,7 +124,7 @@ RenderCASSharpness 1 0 RenderExposure 1 1 RenderTonemapType 1 1 RenderTonemapMix 1 0.7 -RenderVintageMode 1 1 +RenderDisableVintageMode 1 0 // // Medium Low Graphics Settings @@ -165,7 +165,7 @@ RenderCASSharpness 1 0 RenderExposure 1 1 RenderTonemapType 1 1 RenderTonemapMix 1 0.7 -RenderVintageMode 1 1 +RenderDisableVintageMode 1 0 // // Medium Graphics Settings (standard) @@ -374,7 +374,7 @@ list Unknown RenderShadowDetail 1 0 RenderDeferredSSAO 1 0 RenderMirrors 1 0 -RenderVintageMode 1 1 +RenderDisableVintageMode 1 0 // @@ -396,7 +396,7 @@ RenderTerrainDetail 1 0 RenderDeferredSSAO 0 0 RenderShadowDetail 0 0 RenderMirrors 0 0 -RenderVintageMode 1 1 +RenderDisableVintageMode 1 0 list TexUnit8orLess RenderDeferredSSAO 0 0 @@ -425,8 +425,7 @@ RenderFSAASamples 0 0 RenderReflectionProbeDetail 0 0 RenderReflectionsEnabled 0 0 RenderMirrors 0 0 -RenderVintageMode 1 1 +RenderDisableVintageMode 1 0 list VaryingVectors16orLess RenderTerrainPBRPlanarSampleCount 1 1 - diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index 2adc6e4a29..ba54d93c75 100644 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -719,7 +719,7 @@ void LLFeatureManager::applyBaseMasks() LLImageGLThread::sEnabledTextures = false; // Make extra sure that vintage mode also gets enabled. - gSavedSettings.setBOOL("RenderVintageMode", true); + gSavedSettings.setBOOL("RenderDisableVintageMode", false); } if (gGLManager.mMaxVaryingVectors <= 16) { diff --git a/indra/newview/llfloaterpreferencesgraphicsadvanced.cpp b/indra/newview/llfloaterpreferencesgraphicsadvanced.cpp index 89ff9988a6..cc4ca611ab 100644 --- a/indra/newview/llfloaterpreferencesgraphicsadvanced.cpp +++ b/indra/newview/llfloaterpreferencesgraphicsadvanced.cpp @@ -321,17 +321,17 @@ void LLFloaterPreferenceGraphicsAdvanced::disableUnavailableSettings() } // Vintage mode - LLCachedControl is_vintage(gSavedSettings, "RenderVintageMode"); + LLCachedControl is_not_vintage(gSavedSettings, "RenderDisableVintageMode"); LLSliderCtrl* tonemapMix = getChild("TonemapMix"); LLComboBox* tonemapSelect = getChild("TonemapType"); LLTextBox* tonemapLabel = getChild("TonemapTypeText"); LLSliderCtrl* exposureSlider = getChild("RenderExposure"); - tonemapSelect->setEnabled(!is_vintage); - tonemapLabel->setEnabled(!is_vintage); - tonemapMix->setEnabled(!is_vintage); - exposureSlider->setEnabled(!is_vintage); - cas_slider->setEnabled(!is_vintage); + tonemapSelect->setEnabled(is_not_vintage); + tonemapLabel->setEnabled(is_not_vintage); + tonemapMix->setEnabled(is_not_vintage); + exposureSlider->setEnabled(is_not_vintage); + cas_slider->setEnabled(is_not_vintage); } void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index c4afaac476..172ffcb0d4 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -248,10 +248,10 @@ static bool handleEnableEmissiveChanged(const LLSD& newvalue) return handleReleaseGLBufferChanged(newvalue) && handleSetShaderChanged(newvalue); } -static bool handleEnableClassicMode(const LLSD& newvalue) +static bool handleDisableVintageMode(const LLSD& newvalue) { - gSavedSettings.setBOOL("RenderEnableEmissiveBuffer", !newvalue.asBoolean()); - gSavedSettings.setBOOL("RenderHDREnabled", !newvalue.asBoolean()); + gSavedSettings.setBOOL("RenderEnableEmissiveBuffer", newvalue.asBoolean()); + gSavedSettings.setBOOL("RenderHDREnabled", newvalue.asBoolean()); return true; } @@ -798,7 +798,7 @@ void settings_setup_listeners() setting_setup_signal_listener(gSavedSettings, "RenderGlowResolutionPow", handleReleaseGLBufferChanged); setting_setup_signal_listener(gSavedSettings, "RenderGlowHDR", handleReleaseGLBufferChanged); setting_setup_signal_listener(gSavedSettings, "RenderEnableEmissiveBuffer", handleEnableEmissiveChanged); - setting_setup_signal_listener(gSavedSettings, "RenderVintageMode", handleEnableClassicMode); + setting_setup_signal_listener(gSavedSettings, "RenderDisableVintageMode", handleDisableVintageMode); setting_setup_signal_listener(gSavedSettings, "RenderHDREnabled", handleEnableHDR); setting_setup_signal_listener(gSavedSettings, "RenderGlowNoise", handleSetShaderChanged); setting_setup_signal_listener(gSavedSettings, "RenderGammaFull", handleSetShaderChanged); diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index 37972f2159..65b98c65cf 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -685,10 +685,10 @@ Date: Tue, 3 Dec 2024 16:33:32 -0800 Subject: [PATCH 9/9] unbreak mac build due to actions/runner-images#10721 (#3204) --- .github/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2cb94c9c90..57e86ad8f6 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -42,7 +42,7 @@ jobs: needs: setup strategy: matrix: - runner: [windows-large, macos-12-xl] + runner: [windows-large, macos-13-xlarge] configuration: ${{ fromJSON(needs.setup.outputs.configurations) }} runs-on: ${{ matrix.runner }} outputs: @@ -64,7 +64,7 @@ jobs: # autobuild-package.xml. AUTOBUILD_VCS_INFO: "true" AUTOBUILD_VSVER: "170" - DEVELOPER_DIR: "/Applications/Xcode_14.0.1.app/Contents/Developer" + DEVELOPER_DIR: "/Applications/Xcode_14.1.app/Contents/Developer" # Ensure that Linden viewer builds engage Bugsplat. BUGSPLAT_DB: ${{ needs.setup.outputs.bugsplat_db }} build_coverity: false