From 7997c743e8f8407287fb16a1eb547c3e2cb66ae9 Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Wed, 28 Feb 2024 16:51:16 -0500 Subject: [PATCH] Revert "Revert "Fixes for material preview from cosmic"" This reverts commit 143592604519165c1cfecb4735629e6983eb6fa5. --- indra/newview/llfetchedgltfmaterial.h | 2 ++ indra/newview/llgltfmaterialpreviewmgr.cpp | 9 ++++++--- indra/newview/lltexturectrl.cpp | 4 ++-- indra/newview/pipeline.cpp | 9 +++------ indra/newview/pipeline.h | 1 - 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/indra/newview/llfetchedgltfmaterial.h b/indra/newview/llfetchedgltfmaterial.h index 2559aa46cc3..b49c667fe0a 100644 --- a/indra/newview/llfetchedgltfmaterial.h +++ b/indra/newview/llfetchedgltfmaterial.h @@ -40,6 +40,8 @@ class LLFetchedGLTFMaterial: public LLGLTFMaterial virtual ~LLFetchedGLTFMaterial(); LLFetchedGLTFMaterial& operator=(const LLFetchedGLTFMaterial& rhs); + // LLGLTFMaterial::operator== is defined, but LLFetchedGLTFMaterial::operator== is not. + bool operator==(const LLGLTFMaterial& rhs) const = delete; // If this material is loaded, fire the given function void onMaterialComplete(std::function<void()> material_complete); diff --git a/indra/newview/llgltfmaterialpreviewmgr.cpp b/indra/newview/llgltfmaterialpreviewmgr.cpp index d020f5a2ff8..35cc370e838 100644 --- a/indra/newview/llgltfmaterialpreviewmgr.cpp +++ b/indra/newview/llgltfmaterialpreviewmgr.cpp @@ -34,6 +34,7 @@ #include "llenvironment.h" #include "llselectmgr.h" #include "llviewercamera.h" +#include "llviewercontrol.h" #include "llviewerobject.h" #include "llviewershadermgr.h" #include "llviewertexturelist.h" @@ -95,7 +96,7 @@ namespace { void fetch_texture_for_ui(LLPointer<LLViewerFetchedTexture>& img, const LLUUID& id) { - if (id.notNull()) + if (!img && id.notNull()) { if (LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(id)) { @@ -334,7 +335,7 @@ void set_preview_sphere_material(PreviewSphere& preview_sphere, LLPointer<LLFetc info->mGLTFMaterial = material; LLVertexBuffer* buf = info->mVertexBuffer.get(); LLStrider<LLColor4U> colors; - const S32 count = info->mEnd - info->mStart; + const S32 count = info->mEnd - info->mStart + 1; buf->getColorStrider(colors, info->mStart, count); for (S32 i = 0; i < count; ++i) { @@ -417,7 +418,8 @@ BOOL LLGLTFPreviewTexture::render() SetTemporarily<LLPipeline::RenderTargetPack*> use_auxiliary_render_target(&gPipeline.mRT, &gPipeline.mAuxillaryRT); const LLVector4a light_dir(1.0f, 1.0f, 1.0f, 0.f); - SetTemporarily<S32> sun_light_only(&LLPipeline::RenderLocalLightCount, 0); + const S32 old_local_light_count = gSavedSettings.get<S32>("RenderLocalLightCount"); + gSavedSettings.set<S32>("RenderLocalLightCount", 0); gPipeline.mReflectionMapManager.forceDefaultProbeAndUpdateUniforms(); @@ -522,6 +524,7 @@ BOOL LLGLTFPreviewTexture::render() // Clean up gPipeline.setupHWLights(); gPipeline.mReflectionMapManager.forceDefaultProbeAndUpdateUniforms(false); + gSavedSettings.set<S32>("RenderLocalLightCount", old_local_light_count); return TRUE; } diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index efb9dfbe43e..cbef3537630 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -672,7 +672,7 @@ void LLFloaterTexturePicker::draw() { mGLTFMaterial = (LLFetchedGLTFMaterial*) gGLTFMaterialList.getMaterial(mImageAssetID); llassert(mGLTFMaterial == nullptr || dynamic_cast<LLFetchedGLTFMaterial*>(gGLTFMaterialList.getMaterial(mImageAssetID)) != nullptr); - if (mGLTFPreview.isNull() || mGLTFMaterial.isNull() || (old_material.notNull() && (*old_material.get() != *mGLTFMaterial.get()))) + if (mGLTFPreview.isNull() || mGLTFMaterial.isNull() || (old_material.notNull() && (old_material.get() != mGLTFMaterial.get()))) { // Only update the preview if needed, since gGLTFMaterialPreviewMgr does not cache the preview. if (mGLTFMaterial.isNull()) @@ -2243,7 +2243,7 @@ void LLTextureCtrl::draw() if (mInventoryPickType == PICK_MATERIAL) { mGLTFMaterial = gGLTFMaterialList.getMaterial(mImageAssetID); - if (mGLTFPreview.isNull() || mGLTFMaterial.isNull() || (old_material.notNull() && (*old_material.get() != *mGLTFMaterial.get()))) + if (mGLTFPreview.isNull() || mGLTFMaterial.isNull() || (old_material.notNull() && (old_material.get() != mGLTFMaterial.get()))) { // Only update the preview if needed, since gGLTFMaterialPreviewMgr does not cache the preview. if (mGLTFMaterial.isNull()) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 64d1956b85d..fae60b8f177 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -179,7 +179,6 @@ F32 LLPipeline::CameraFocusTransitionTime; F32 LLPipeline::CameraFNumber; F32 LLPipeline::CameraFocalLength; F32 LLPipeline::CameraFieldOfView; -S32 LLPipeline::RenderLocalLightCount; F32 LLPipeline::RenderShadowNoise; F32 LLPipeline::RenderShadowBlurSize; F32 LLPipeline::RenderSSAOScale; @@ -550,7 +549,6 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("CameraFNumber"); connectRefreshCachedSettingsSafe("CameraFocalLength"); connectRefreshCachedSettingsSafe("CameraFieldOfView"); - connectRefreshCachedSettingsSafe("RenderLocalLightCount"); connectRefreshCachedSettingsSafe("RenderShadowNoise"); connectRefreshCachedSettingsSafe("RenderShadowBlurSize"); connectRefreshCachedSettingsSafe("RenderSSAOScale"); @@ -1091,7 +1089,6 @@ void LLPipeline::refreshCachedSettings() CameraFNumber = gSavedSettings.getF32("CameraFNumber"); CameraFocalLength = gSavedSettings.getF32("CameraFocalLength"); CameraFieldOfView = gSavedSettings.getF32("CameraFieldOfView"); - RenderLocalLightCount = gSavedSettings.getS32("RenderLocalLightCount"); RenderShadowNoise = gSavedSettings.getF32("RenderShadowNoise"); RenderShadowBlurSize = gSavedSettings.getF32("RenderShadowBlurSize"); RenderSSAOScale = gSavedSettings.getF32("RenderSSAOScale"); @@ -5366,7 +5363,7 @@ void LLPipeline::calcNearbyLights(LLCamera& camera) return; } - const S32 local_light_count = LLPipeline::RenderLocalLightCount; + static LLCachedControl<S32> local_light_count(gSavedSettings, "RenderLocalLightCount", 256); if (local_light_count >= 1) { @@ -5633,7 +5630,7 @@ void LLPipeline::setupHWLights() mLightMovingMask = 0; - const S32 local_light_count = LLPipeline::RenderLocalLightCount; + static LLCachedControl<S32> local_light_count(gSavedSettings, "RenderLocalLightCount", 256); if (local_light_count >= 1) { @@ -8019,7 +8016,7 @@ void LLPipeline::renderDeferredLighting() unbindDeferredShader(soften_shader); } - const S32 local_light_count = LLPipeline::RenderLocalLightCount; + static LLCachedControl<S32> local_light_count(gSavedSettings, "RenderLocalLightCount", 256); if (local_light_count > 0) { diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 76b1ba11efc..f56a3872621 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -1007,7 +1007,6 @@ class LLPipeline static F32 CameraFNumber; static F32 CameraFocalLength; static F32 CameraFieldOfView; - static S32 RenderLocalLightCount; static F32 RenderShadowNoise; static F32 RenderShadowBlurSize; static F32 RenderSSAOScale; -- GitLab