From 9ccd8f107c3a7feaa7ccf51b899b1d3c7d0c1e13 Mon Sep 17 00:00:00 2001 From: minerjr Date: Wed, 26 Mar 2025 12:14:10 -0300 Subject: [PATCH] [FIRE-35292] Fix for textures getting downscaled and compressed (J2C save fix) Added fix for not reading enough LLImageJ2K data from the cache to save to file. Issue is caused by hard coded data size of 999,999 used for the amount of data to read from the cache. Used the LLImageJ2C::calcDataSizeJ2C to properly calculate the amount of data to read from the cache. --- indra/newview/daeexport.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/indra/newview/daeexport.cpp b/indra/newview/daeexport.cpp index bb2562b1ff..c9de9a8c32 100644 --- a/indra/newview/daeexport.cpp +++ b/indra/newview/daeexport.cpp @@ -505,7 +505,15 @@ void ColladaExportFloater::CacheReadResponder::saveTexturesWorker(void* data) std::string name = gDirUtilp->getDirName(me->mFilename); name += gDirUtilp->getDirDelimiter() + me->mTexturesToSave[id]; CacheReadResponder* responder = new CacheReadResponder(id, img, name, img_type); - LLAppViewer::getTextureCache()->readFromCache(id, 0, 999999, responder); + // [FIRE-35292] Fix for textures getting downscaled and compressed + //LLAppViewer::getTextureCache()->readFromCache(id, 0, 999999, responder); + // The above line hard coded the size of data to read from the cached version of the texture as 999999, + // where now we will calcuate the correct value based upon the texture's full width, height and # of components (3=RGB, 4=RGBA) and + // the discard level (0)). There is a choice to change the rate, but we seem to use the value of 1/8 compression level + S32 texture_size = LLImageJ2C::calcDataSizeJ2C(imagep->getFullWidth(), imagep->getFullHeight(), imagep->getComponents(), 0);// , F32 rate) rate = const F32 DEFAULT_COMPRESSION_RATE = 1.f/8.f; + // Use calculated texture_size (from LLTextureFetch::createRequest see "else if (w*h*c > 0)" statement for more info) + LLAppViewer::getTextureCache()->readFromCache(id, 0, texture_size, responder); + // [FIRE-35292] me->mTexturesToSave.erase(id); me->updateTitleProgress(); me->mTimer.reset();