From f0e1bcfed35f4162f235129da0aaba022ce90a55 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Wed, 31 Jan 2024 19:39:44 -0500
Subject: [PATCH] Potentially fix bake issues and a few other bugs

---
 indra/newview/lldynamictexture.cpp | 2 +-
 indra/newview/pipeline.cpp         | 6 +++++-
 indra/newview/pipeline.h           | 1 +
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp
index 0232514ef54..f8e50dd8570 100644
--- a/indra/newview/lldynamictexture.cpp
+++ b/indra/newview/lldynamictexture.cpp
@@ -189,7 +189,7 @@ BOOL LLViewerDynamicTexture::updateAllInstances()
 		return TRUE;
 	}
 
-    LLRenderTarget& bake_target = gPipeline.mAuxillaryRT.deferredScreen;
+    LLRenderTarget& bake_target = gPipeline.mBake;
 
 	if (!bake_target.isComplete())
     {
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 9481e9a9b2a..fae60b8f177 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -217,7 +217,7 @@ S32 LLPipeline::RenderBufferVisualization;
 F32 LLPipeline::RenderNormalMapScale;
 LLTrace::EventStatHandle<S64> LLPipeline::sStatBatchSize("renderbatchsize");
 
-const U32 LLPipeline::MAX_BAKE_WIDTH = 512;
+const U32 LLPipeline::MAX_BAKE_WIDTH = 1024;
 
 const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f;
 const F32 BACKLIGHT_NIGHT_MAGNITUDE_OBJECT = 0.08f;
@@ -1173,6 +1173,7 @@ void LLPipeline::releaseGLBuffers()
 	releaseLUTBuffers();
 
 	mWaterDis.release();
+    mBake.release();
 	
     mSceneMap.release();
 
@@ -1252,6 +1253,9 @@ void LLPipeline::createGLBuffers()
     stop_glerror();
 	assertInitialized();
 
+    // Use FBO for bake tex
+    mBake.allocate(1024, 1024, GL_RGBA, true); // SL-12781 Build > Upload > Model; 3D Preview
+
 	stop_glerror();
 
 	GLuint resX = gViewerWindow->getWorldViewWidthRaw();
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index c3cc62965c5..f56a3872621 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -739,6 +739,7 @@ class LLPipeline
 	LLRenderTarget				mWaterDis;
 
     static const U32 MAX_BAKE_WIDTH;
+	LLRenderTarget				mBake;
 
 	//texture for making the glow
 	LLRenderTarget				mGlow[3];
-- 
GitLab