summaryrefslogtreecommitdiff
path: root/indra/newview/llgltfmaterialpreviewmgr.cpp
diff options
context:
space:
mode:
authorcosmic-linden <111533034+cosmic-linden@users.noreply.github.com>2024-02-21 16:49:04 -0800
committerGitHub <noreply@github.com>2024-02-21 16:49:04 -0800
commit6a97433f3bd025fc0011bc4399b05ecbcc11d89a (patch)
tree595c349db5c0aa39992a4fb5412309d8b26ecf7a /indra/newview/llgltfmaterialpreviewmgr.cpp
parent1552ee3a5d72a1d6b2dc536d033d4c2d8f2e74ee (diff)
parentfc7abe8cb9ef737cb1ad4431e30c42f08d6e8899 (diff)
Merge pull request #849 from secondlife/vi-72
secondlife/viewer-issues#72: Fix material preview making things disappear. General cleanup.
Diffstat (limited to 'indra/newview/llgltfmaterialpreviewmgr.cpp')
-rw-r--r--indra/newview/llgltfmaterialpreviewmgr.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/indra/newview/llgltfmaterialpreviewmgr.cpp b/indra/newview/llgltfmaterialpreviewmgr.cpp
index 901db87eed..1c39f1ae7d 100644
--- a/indra/newview/llgltfmaterialpreviewmgr.cpp
+++ b/indra/newview/llgltfmaterialpreviewmgr.cpp
@@ -58,6 +58,15 @@ LLGLTFPreviewTexture::MaterialLoadLevels::MaterialLoadLevels()
}
}
+bool LLGLTFPreviewTexture::MaterialLoadLevels::isFullyLoaded()
+{
+ for (U32 i = 0; i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++i)
+ {
+ if (levels[i] != FULLY_LOADED) { return false; }
+ }
+ return true;
+}
+
S32& LLGLTFPreviewTexture::MaterialLoadLevels::operator[](size_t i)
{
llassert(i >= 0 && i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT);
@@ -187,17 +196,26 @@ LLPointer<LLGLTFPreviewTexture> LLGLTFPreviewTexture::create(LLPointer<LLFetched
return new LLGLTFPreviewTexture(material, LLPipeline::MAX_BAKE_WIDTH);
}
-void LLGLTFPreviewTexture::preRender(BOOL clear_depth)
+BOOL LLGLTFPreviewTexture::needsRender()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_UI;
+ if (!mShouldRender && mBestLoad.isFullyLoaded()) { return false; }
MaterialLoadLevels current_load = get_material_load_levels(*mGLTFMaterial.get());
if (current_load < mBestLoad)
{
mShouldRender = true;
mBestLoad = current_load;
+ return true;
}
+ return false;
+}
+void LLGLTFPreviewTexture::preRender(BOOL clear_depth)
+{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_UI;
+
+ llassert(mShouldRender);
if (!mShouldRender) { return; }
LLViewerDynamicTexture::preRender(clear_depth);
@@ -499,9 +517,12 @@ BOOL LLGLTFPreviewTexture::render()
screen.flush();
}
+ // *HACK: Hide mExposureMap from generateExposure
+ gPipeline.mExposureMap.swapFBORefs(gPipeline.mLastExposure);
+
gPipeline.copyScreenSpaceReflections(&screen, &gPipeline.mSceneMap);
gPipeline.generateLuminance(&screen, &gPipeline.mLuminanceMap);
- gPipeline.generateExposure(&gPipeline.mLuminanceMap, &gPipeline.mExposureMap);
+ gPipeline.generateExposure(&gPipeline.mLuminanceMap, &gPipeline.mExposureMap, /*use_history = */ false);
gPipeline.gammaCorrect(&screen, &gPipeline.mPostMap);
LLVertexBuffer::unbind();
gPipeline.generateGlow(&gPipeline.mPostMap);
@@ -509,6 +530,9 @@ BOOL LLGLTFPreviewTexture::render()
gPipeline.renderDoF(&screen, &gPipeline.mPostMap);
gPipeline.applyFXAA(&gPipeline.mPostMap, &screen);
+ // *HACK: Restore mExposureMap (it will be consumed by generateExposure next frame)
+ gPipeline.mExposureMap.swapFBORefs(gPipeline.mLastExposure);
+
// Final render
gDeferredPostNoDoFProgram.bind();