diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp index f8e50dd8570af2ceaf394acb20108149ea0a2d91..425132ed34b5eb219c8b40d85c32087922639f25 100644 --- a/indra/newview/lldynamictexture.cpp +++ b/indra/newview/lldynamictexture.cpp @@ -118,6 +118,8 @@ BOOL LLViewerDynamicTexture::render() //----------------------------------------------------------------------------- void LLViewerDynamicTexture::preRender(BOOL clear_depth) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; + //use the bottom left corner mOrigin.set(0, 0); diff --git a/indra/newview/llgltfmaterialpreviewmgr.cpp b/indra/newview/llgltfmaterialpreviewmgr.cpp index 35cc370e838a26f552669d0f2684f98fe4c11851..e472c06574cbb64e319dc7ab18dcaaf18ab58feb 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); @@ -185,17 +194,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); diff --git a/indra/newview/llgltfmaterialpreviewmgr.h b/indra/newview/llgltfmaterialpreviewmgr.h index cc40a6f2e2a1afdc5cab1811fe6772e2aa3a1ac3..981c8b0592214f2c8990e2f17caca90d4b87a54d 100644 --- a/indra/newview/llgltfmaterialpreviewmgr.h +++ b/indra/newview/llgltfmaterialpreviewmgr.h @@ -40,7 +40,7 @@ class LLGLTFPreviewTexture : public LLViewerDynamicTexture // Width scales with size of material's textures static LLPointer<LLGLTFPreviewTexture> create(LLPointer<LLFetchedGLTFMaterial> material); - BOOL needsRender() override { return mNeedsRender; } + BOOL needsRender() override; void preRender(BOOL clear_depth = TRUE) override; BOOL render() override; void postRender(BOOL success) override; @@ -50,15 +50,12 @@ class LLGLTFPreviewTexture : public LLViewerDynamicTexture S32 levels[LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT]; MaterialLoadLevels(); - + bool isFullyLoaded(); S32& operator[](size_t i); - const S32& operator[](size_t i) const; - // Less is better // Returns false if lhs is not strictly less or equal for all levels bool operator<(const MaterialLoadLevels& other) const; - // Less is better // Returns false if lhs is not strictly greater or equal for all levels bool operator>(const MaterialLoadLevels& other) const; @@ -66,7 +63,6 @@ class LLGLTFPreviewTexture : public LLViewerDynamicTexture private: LLPointer<LLFetchedGLTFMaterial> mGLTFMaterial; - bool mNeedsRender = true; bool mShouldRender = true; MaterialLoadLevels mBestLoad; };