summaryrefslogtreecommitdiff
path: root/indra/newview/llviewertexturelist.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2024-06-10 20:03:54 +0300
committerGitHub <noreply@github.com>2024-06-10 20:03:54 +0300
commitf74c10c4ec6435471bac84473fe865f90843c2df (patch)
treeb2853d87789dbb84d6c26c259eab6639d3a7e482 /indra/newview/llviewertexturelist.cpp
parent5fccb539937a52d286274a002266e022e2102e5e (diff)
parent32fcefc058ae38eff0572326ef3efd1c7b343144 (diff)
Merge branch 'DRTVWR-600-maint-A' into signal/trim-trailing
Diffstat (limited to 'indra/newview/llviewertexturelist.cpp')
-rw-r--r--indra/newview/llviewertexturelist.cpp108
1 files changed, 57 insertions, 51 deletions
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 4c1dc7eb71..21572ef620 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -91,14 +91,14 @@ LLTextureKey::LLTextureKey(LLUUID id, ETexListType tex_type)
///////////////////////////////////////////////////////////////////////////////
LLViewerTextureList::LLViewerTextureList()
- : mForceResetTextureStats(FALSE),
- mInitialized(FALSE)
+ : mForceResetTextureStats(false),
+ mInitialized(false)
{
}
void LLViewerTextureList::init()
{
- mInitialized = TRUE ;
+ mInitialized = true ;
sNumImages = 0;
doPreloadImages();
}
@@ -139,12 +139,12 @@ void LLViewerTextureList::doPreloadImages()
image_list->initFromFile();
// turn off clamping and bilinear filtering for uv picking images
- //LLViewerFetchedTexture* uv_test = preloadUIImage("uv_test1.tga", LLUUID::null, FALSE);
- //uv_test->setClamp(FALSE, FALSE);
- //uv_test->setMipFilterNearest(TRUE, TRUE);
- //uv_test = preloadUIImage("uv_test2.tga", LLUUID::null, FALSE);
- //uv_test->setClamp(FALSE, FALSE);
- //uv_test->setMipFilterNearest(TRUE, TRUE);
+ //LLViewerFetchedTexture* uv_test = preloadUIImage("uv_test1.tga", LLUUID::null, false);
+ //uv_test->setClamp(false, false);
+ //uv_test->setMipFilterNearest(true, true);
+ //uv_test = preloadUIImage("uv_test2.tga", LLUUID::null, false);
+ //uv_test->setClamp(false, false);
+ //uv_test->setMipFilterNearest(true, true);
LLViewerFetchedTexture* image = LLViewerTextureManager::getFetchedTextureFromFile("silhouette.j2c", FTT_LOCAL_FILE, MIPMAP_YES, LLViewerFetchedTexture::BOOST_UI);
if (image)
@@ -188,9 +188,9 @@ void LLViewerTextureList::doPreloadImages()
LLPointer<LLImageRaw> img_blak_square_tex(new LLImageRaw(2, 2, 3));
memset(img_blak_square_tex->getData(), 0, img_blak_square_tex->getDataSize());
- LLPointer<LLViewerFetchedTexture> img_blak_square(new LLViewerFetchedTexture(img_blak_square_tex, FTT_DEFAULT, FALSE));
+ LLPointer<LLViewerFetchedTexture> img_blak_square(new LLViewerFetchedTexture(img_blak_square_tex, FTT_DEFAULT, false));
gBlackSquareID = img_blak_square->getID();
- img_blak_square->setUnremovable(TRUE);
+ img_blak_square->setUnremovable(true);
addImage(img_blak_square, TEX_LIST_STANDARD);
}
@@ -231,7 +231,7 @@ void LLViewerTextureList::doPrefetchImages()
LLViewerTextureManager::getFetchedTexture(IMG_SHOT);
LLViewerTextureManager::getFetchedTexture(IMG_SMOKE_POOF);
- LLViewerFetchedTexture::sSmokeImagep = LLViewerTextureManager::getFetchedTexture(IMG_SMOKE, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
+ LLViewerFetchedTexture::sSmokeImagep = LLViewerTextureManager::getFetchedTexture(IMG_SMOKE, FTT_DEFAULT, true, LLGLTexture::BOOST_UI);
LLViewerFetchedTexture::sSmokeImagep->setNoDelete();
LLStandardBumpmap::addstandard();
@@ -360,7 +360,7 @@ void LLViewerTextureList::shutdown()
mImageList.clear();
- mInitialized = FALSE ; //prevent loading textures again.
+ mInitialized = false; //prevent loading textures again.
}
void LLViewerTextureList::dump()
@@ -381,7 +381,7 @@ void LLViewerTextureList::dump()
}
}
-void LLViewerTextureList::destroyGL(BOOL save_state)
+void LLViewerTextureList::destroyGL(bool save_state)
{
LLImageGL::destroyGL(save_state);
}
@@ -403,7 +403,7 @@ void LLViewerTextureList::restoreGL()
LLViewerFetchedTexture* LLViewerTextureList::getImageFromFile(const std::string& filename,
FTType f_type,
- BOOL usemipmaps,
+ bool usemipmaps,
LLViewerTexture::EBoostLevel boost_priority,
S8 texture_type,
LLGLint internal_format,
@@ -421,7 +421,7 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromFile(const std::string&
{
LL_WARNS() << "Failed to find local image file: " << filename << LL_ENDL;
LLViewerTexture::EBoostLevel priority = LLGLTexture::BOOST_UI;
- return LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, FTT_DEFAULT, TRUE, priority);
+ return LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, FTT_DEFAULT, true, priority);
}
std::string url = "file://" + full_path;
@@ -431,7 +431,7 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromFile(const std::string&
LLViewerFetchedTexture* LLViewerTextureList::getImageFromUrl(const std::string& url,
FTType f_type,
- BOOL usemipmaps,
+ bool usemipmaps,
LLViewerTexture::EBoostLevel boost_priority,
S8 texture_type,
LLGLint internal_format,
@@ -521,7 +521,7 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromUrl(const std::string&
LLViewerFetchedTexture* LLViewerTextureList::getImage(const LLUUID &image_id,
FTType f_type,
- BOOL usemipmaps,
+ bool usemipmaps,
LLViewerTexture::EBoostLevel boost_priority,
S8 texture_type,
LLGLint internal_format,
@@ -540,7 +540,7 @@ LLViewerFetchedTexture* LLViewerTextureList::getImage(const LLUUID &image_id,
if (image_id.isNull())
{
- return (LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI));
+ return (LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, FTT_DEFAULT, true, LLGLTexture::BOOST_UI));
}
LLPointer<LLViewerFetchedTexture> imagep = findImage(image_id, get_element_type(boost_priority));
@@ -578,7 +578,7 @@ LLViewerFetchedTexture* LLViewerTextureList::getImage(const LLUUID &image_id,
//when this function is called, there is no such texture in the gTextureList with image_id.
LLViewerFetchedTexture* LLViewerTextureList::createImage(const LLUUID &image_id,
FTType f_type,
- BOOL usemipmaps,
+ bool usemipmaps,
LLViewerTexture::EBoostLevel boost_priority,
S8 texture_type,
LLGLint internal_format,
@@ -675,12 +675,12 @@ void LLViewerTextureList::addImageToList(LLViewerFetchedTexture *image)
}
else
{
- if((mImageList.insert(image)).second != true)
- {
+ if (!(mImageList.insert(image)).second)
+ {
LL_WARNS() << "Error happens when insert image " << image->getID() << " into mImageList!" << LL_ENDL ;
+ }
+ image->setInImageList(true);
}
- image->setInImageList(TRUE) ;
-}
}
void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image)
@@ -690,7 +690,7 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image)
llassert_always(mInitialized) ;
llassert(image);
- S32 count = 0;
+ size_t count = 0;
if (image->isInImageList())
{
count = mImageList.erase(image) ;
@@ -730,7 +730,7 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image)
}
}
- image->setInImageList(FALSE) ;
+ image->setInImageList(false) ;
}
void LLViewerTextureList::addImage(LLViewerFetchedTexture *new_image, ETexListType tex_type)
@@ -788,18 +788,18 @@ void LLViewerTextureList::dirtyImage(LLViewerFetchedTexture *image)
void LLViewerTextureList::updateImages(F32 max_time)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
- static BOOL cleared = FALSE;
+ static bool cleared = false;
if(gTeleportDisplay)
{
if(!cleared)
{
clearFetchingRequests();
gPipeline.clearRebuildGroups();
- cleared = TRUE;
+ cleared = true;
}
return;
}
- cleared = FALSE;
+ cleared = false;
LLAppViewer::getTextureFetch()->setTextureBandwidth(LLTrace::get_frame_recording().getPeriodMeanPerSec(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED).value());
@@ -878,7 +878,7 @@ static void touch_texture(LLViewerFetchedTexture* tex, F32 vsize)
}
}
-extern BOOL gCubeSnapshot;
+extern bool gCubeSnapshot;
void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imagep)
{
@@ -891,12 +891,14 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
llassert(!gCubeSnapshot);
static LLCachedControl<F32> bias_distance_scale(gSavedSettings, "TextureBiasDistanceScale", 1.f);
+ static LLCachedControl<F32> texture_scale_min(gSavedSettings, "TextureScaleMinAreaFactor", 0.04f);
+ static LLCachedControl<F32> texture_scale_max(gSavedSettings, "TextureScaleMaxAreaFactor", 25.f);
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE
{
for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i)
{
- for (U32 fi = 0; fi < imagep->getNumFaces(i); ++fi)
+ for (S32 fi = 0; fi < imagep->getNumFaces(i); ++fi)
{
LLFace* face = (*(imagep->getFaceList(i)))[fi];
@@ -904,27 +906,27 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
{
F32 vsize = face->getPixelArea();
- // scale desired texture resolution higher or lower depending on texture scale
+ // Scale desired texture resolution higher or lower depending on texture scale
+ //
+ // Minimum usage examples: a 1024x1024 texture with aplhabet, runing string
+ // shows one letter at a time
+ //
+ // Maximum usage examples: huge chunk of terrain repeats texture
const LLTextureEntry* te = face->getTextureEntry();
F32 min_scale = te ? llmin(fabsf(te->getScaleS()), fabsf(te->getScaleT())) : 1.f;
- min_scale = llmax(min_scale*min_scale, 0.1f);
+ min_scale = llclamp(min_scale*min_scale, texture_scale_min(), texture_scale_max());
vsize /= min_scale;
-
-#if LL_DARWIN
- vsize /= 1.f + LLViewerTexture::sDesiredDiscardBias*(1.f+face->getDrawable()->mDistanceWRTCamera*bias_distance_scale);
-#else
vsize /= LLViewerTexture::sDesiredDiscardBias;
vsize /= llmax(1.f, (LLViewerTexture::sDesiredDiscardBias-1.f) * (1.f + face->getDrawable()->mDistanceWRTCamera * bias_distance_scale));
F32 radius;
F32 cos_angle_to_view_dir;
- BOOL in_frustum = face->calcPixelArea(cos_angle_to_view_dir, radius);
+ bool in_frustum = face->calcPixelArea(cos_angle_to_view_dir, radius);
if (!in_frustum || !face->getDrawable()->isVisible())
{ // further reduce by discard bias when off screen or occluded
vsize /= LLViewerTexture::sDesiredDiscardBias;
}
-#endif
// if a GLTF material is present, ignore that face
// as far as this texture stats go, but update the GLTF material
// stats
@@ -1179,7 +1181,7 @@ void LLViewerTextureList::updateImagesUpdateStats()
LLViewerFetchedTexture* imagep = *iter++;
imagep->resetTextureStats();
}
- mForceResetTextureStats = FALSE;
+ mForceResetTextureStats = false;
}
}
@@ -1198,7 +1200,7 @@ void LLViewerTextureList::decodeAllImages(F32 max_time)
{
LLViewerFetchedTexture* imagep = *iter++;
image_list.push_back(imagep);
- imagep->setInImageList(FALSE) ;
+ imagep->setInImageList(false) ;
}
llassert_always(image_list.size() == mImageList.size()) ;
@@ -1221,7 +1223,7 @@ void LLViewerTextureList::decodeAllImages(F32 max_time)
}
std::shared_ptr<LL::WorkQueue> main_queue = LLImageGLThread::sEnabledTextures ? LL::WorkQueue::getInstance("mainloop") : NULL;
// Run threads
- S32 fetch_pending = 0;
+ size_t fetch_pending = 0;
while (1)
{
LLAppViewer::instance()->getTextureCache()->update(1); // unpauses the texture cache thread
@@ -1263,6 +1265,8 @@ bool LLViewerTextureList::createUploadFile(LLPointer<LLImageRaw> raw_image,
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
+ LLImageDataSharedLock lock(raw_image);
+
// make a copy, since convertToUploadFile scales raw image
LLPointer<LLImageRaw> scale_image = new LLImageRaw(
raw_image->getData(),
@@ -1376,6 +1380,8 @@ bool LLViewerTextureList::createUploadFile(const std::string& filename,
LLPointer<LLImageJ2C> LLViewerTextureList::convertToUploadFile(LLPointer<LLImageRaw> raw_image, const S32 max_image_dimentions, bool force_square, bool force_lossless)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
+ LLImageDataLock lock(raw_image);
+
if (force_square)
{
S32 biggest_side = llmax(raw_image->getWidth(), raw_image->getHeight());
@@ -1393,7 +1399,7 @@ LLPointer<LLImageJ2C> LLViewerTextureList::convertToUploadFile(LLPointer<LLImage
(gSavedSettings.getBOOL("LosslessJ2CUpload") &&
(raw_image->getWidth() * raw_image->getHeight() <= LL_IMAGE_REZ_LOSSLESS_CUTOFF * LL_IMAGE_REZ_LOSSLESS_CUTOFF)))
{
- compressedImage->setReversible(TRUE);
+ compressedImage->setReversible(true);
}
@@ -1469,7 +1475,7 @@ LLUIImagePtr LLUIImageList::getUIImageByID(const LLUUID& image_id, S32 priority)
return found_it->second;
}
- const BOOL use_mips = FALSE;
+ const bool use_mips = false;
const LLRect scale_rect = LLRect::null;
const LLRect clip_rect = LLRect::null;
return loadUIImageByID(image_id, use_mips, scale_rect, clip_rect, (LLViewerTexture::EBoostLevel)priority);
@@ -1485,14 +1491,14 @@ LLUIImagePtr LLUIImageList::getUIImage(const std::string& image_name, S32 priori
return found_it->second;
}
- const BOOL use_mips = FALSE;
+ const bool use_mips = false;
const LLRect scale_rect = LLRect::null;
const LLRect clip_rect = LLRect::null;
return loadUIImageByName(image_name, image_name, use_mips, scale_rect, clip_rect, (LLViewerTexture::EBoostLevel)priority);
}
LLUIImagePtr LLUIImageList::loadUIImageByName(const std::string& name, const std::string& filename,
- BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect, LLViewerTexture::EBoostLevel boost_priority,
+ bool use_mips, const LLRect& scale_rect, const LLRect& clip_rect, LLViewerTexture::EBoostLevel boost_priority,
LLUIImage::EScaleStyle scale_style)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
@@ -1505,7 +1511,7 @@ LLUIImagePtr LLUIImageList::loadUIImageByName(const std::string& name, const std
}
LLUIImagePtr LLUIImageList::loadUIImageByID(const LLUUID& id,
- BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect, LLViewerTexture::EBoostLevel boost_priority,
+ bool use_mips, const LLRect& scale_rect, const LLRect& clip_rect, LLViewerTexture::EBoostLevel boost_priority,
LLUIImage::EScaleStyle scale_style)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
@@ -1517,7 +1523,7 @@ LLUIImagePtr LLUIImageList::loadUIImageByID(const LLUUID& id,
return loadUIImage(imagep, id.asString(), use_mips, scale_rect, clip_rect, scale_style);
}
-LLUIImagePtr LLUIImageList::loadUIImage(LLViewerFetchedTexture* imagep, const std::string& name, BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect,
+LLUIImagePtr LLUIImageList::loadUIImage(LLViewerFetchedTexture* imagep, const std::string& name, bool use_mips, const LLRect& scale_rect, const LLRect& clip_rect,
LLUIImage::EScaleStyle scale_style)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
@@ -1552,12 +1558,12 @@ LLUIImagePtr LLUIImageList::loadUIImage(LLViewerFetchedTexture* imagep, const st
datap->mImageScaleRegion = scale_rect;
datap->mImageClipRegion = clip_rect;
- imagep->setLoadedCallback(onUIImageLoaded, 0, FALSE, FALSE, datap, NULL);
+ imagep->setLoadedCallback(onUIImageLoaded, 0, false, false, datap, NULL);
}
return new_imagep;
}
-LLUIImagePtr LLUIImageList::preloadUIImage(const std::string& name, const std::string& filename, BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect, LLUIImage::EScaleStyle scale_style)
+LLUIImagePtr LLUIImageList::preloadUIImage(const std::string& name, const std::string& filename, bool use_mips, const LLRect& scale_rect, const LLRect& clip_rect, LLUIImage::EScaleStyle scale_style)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
// look for existing image
@@ -1572,7 +1578,7 @@ LLUIImagePtr LLUIImageList::preloadUIImage(const std::string& name, const std::s
}
//static
-void LLUIImageList::onUIImageLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* user_data )
+void LLUIImageList::onUIImageLoaded( bool success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, bool final, void* user_data )
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
if(!success || !user_data)