summaryrefslogtreecommitdiff
path: root/indra/newview/llviewertexture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewertexture.cpp')
-rw-r--r--indra/newview/llviewertexture.cpp907
1 files changed, 359 insertions, 548 deletions
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 9aee1c0caf..9648a9af18 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -1,3 +1,4 @@
+
/**
* @file llviewertexture.cpp
* @brief Object which handles a received image (and associated texture(s))
@@ -62,23 +63,18 @@
#include "llwindow.h"
///////////////////////////////////////////////////////////////////////////////
-// extern
-const S32Megabytes gMinVideoRam(32);
-const S32Megabytes gMaxVideoRam(512);
-
-
// statics
-LLPointer<LLViewerTexture> LLViewerTexture::sNullImagep = NULL;
-LLPointer<LLViewerTexture> LLViewerTexture::sBlackImagep = NULL;
-LLPointer<LLViewerTexture> LLViewerTexture::sCheckerBoardImagep = NULL;
-LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sMissingAssetImagep = NULL;
-LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sWhiteImagep = NULL;
-LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultImagep = NULL;
-LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sSmokeImagep = NULL;
-LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sFlatNormalImagep = NULL;
+LLPointer<LLViewerTexture> LLViewerTexture::sNullImagep = nullptr;
+LLPointer<LLViewerTexture> LLViewerTexture::sBlackImagep = nullptr;
+LLPointer<LLViewerTexture> LLViewerTexture::sCheckerBoardImagep = nullptr;
+LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sMissingAssetImagep = nullptr;
+LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sWhiteImagep = nullptr;
+LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultImagep = nullptr;
+LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sSmokeImagep = nullptr;
+LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sFlatNormalImagep = nullptr;
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultIrradiancePBRp;
LLViewerMediaTexture::media_map_t LLViewerMediaTexture::sMediaMap;
-LLTexturePipelineTester* LLViewerTextureManager::sTesterp = NULL;
+LLTexturePipelineTester* LLViewerTextureManager::sTesterp = nullptr;
F32 LLViewerFetchedTexture::sMaxVirtualSize = 8192.f*8192.f;
const std::string sTesterName("TextureTester");
@@ -88,18 +84,22 @@ S32 LLViewerTexture::sRawCount = 0;
S32 LLViewerTexture::sAuxCount = 0;
LLFrameTimer LLViewerTexture::sEvaluationTimer;
F32 LLViewerTexture::sDesiredDiscardBias = 0.f;
-F32 LLViewerTexture::sDesiredDiscardScale = 1.1f;
+
S32 LLViewerTexture::sMaxSculptRez = 128; //max sculpt image size
-const S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64;
+constexpr S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64;
const S32 MAX_CACHED_RAW_SCULPT_IMAGE_AREA = LLViewerTexture::sMaxSculptRez * LLViewerTexture::sMaxSculptRez;
-const S32 MAX_CACHED_RAW_TERRAIN_IMAGE_AREA = 128 * 128;
-const S32 DEFAULT_ICON_DIMENSIONS = 32;
-const S32 DEFAULT_THUMBNAIL_DIMENSIONS = 256;
+constexpr S32 MAX_CACHED_RAW_TERRAIN_IMAGE_AREA = 128 * 128;
+constexpr S32 DEFAULT_ICON_DIMENSIONS = 32;
+constexpr S32 DEFAULT_THUMBNAIL_DIMENSIONS = 256;
U32 LLViewerTexture::sMinLargeImageSize = 65536; //256 * 256.
U32 LLViewerTexture::sMaxSmallImageSize = MAX_CACHED_RAW_IMAGE_AREA;
bool LLViewerTexture::sFreezeImageUpdates = false;
F32 LLViewerTexture::sCurrentTime = 0.0f;
+constexpr F32 MEMORY_CHECK_WAIT_TIME = 1.0f;
+constexpr F32 MIN_VRAM_BUDGET = 768.f;
+F32 LLViewerTexture::sFreeVRAMMegabytes = MIN_VRAM_BUDGET;
+
LLViewerTexture::EDebugTexels LLViewerTexture::sDebugTexelsMode = LLViewerTexture::DEBUG_TEXELS_OFF;
const F64 log_2 = log(2.0);
@@ -116,11 +116,11 @@ const U32 DESIRED_NORMAL_TEXTURE_SIZE = (U32)LLViewerFetchedTexture::MAX_IMAGE_S
LLLoadedCallbackEntry::LLLoadedCallbackEntry(loaded_callback_func cb,
S32 discard_level,
- BOOL need_imageraw, // Needs image raw for the callback
+ bool need_imageraw, // Needs image raw for the callback
void* userdata,
LLLoadedCallbackEntry::source_callback_list_t* src_callback_list,
LLViewerFetchedTexture* target,
- BOOL pause)
+ bool pause)
: mCallback(cb),
mLastUsedDiscard(MAX_DISCARD_LEVEL+1),
mDesiredDiscard(discard_level),
@@ -141,7 +141,7 @@ LLLoadedCallbackEntry::~LLLoadedCallbackEntry()
void LLLoadedCallbackEntry::removeTexture(LLViewerFetchedTexture* tex)
{
- if(mSourceCallbackList)
+ if (mSourceCallbackList && tex)
{
mSourceCallbackList->erase(LLTextureKey(tex->getID(), (ETexListType)tex->getTextureListType()));
}
@@ -166,7 +166,7 @@ void LLLoadedCallbackEntry::cleanUpCallbackList(LLLoadedCallbackEntry::source_ca
}
}
-LLViewerMediaTexture* LLViewerTextureManager::createMediaTexture(const LLUUID &media_id, BOOL usemipmaps, LLImageGL* gl_image)
+LLViewerMediaTexture* LLViewerTextureManager::createMediaTexture(const LLUUID &media_id, bool usemipmaps, LLImageGL* gl_image)
{
return new LLViewerMediaTexture(media_id, usemipmaps, gl_image);
}
@@ -212,7 +212,7 @@ LLViewerMediaTexture* LLViewerTextureManager::findMediaTexture(const LLUUID &med
return LLViewerMediaTexture::findMediaTexture(media_id);
}
-LLViewerMediaTexture* LLViewerTextureManager::getMediaTexture(const LLUUID& id, BOOL usemipmaps, LLImageGL* gl_image)
+LLViewerMediaTexture* LLViewerTextureManager::getMediaTexture(const LLUUID& id, bool usemipmaps, LLImageGL* gl_image)
{
LLViewerMediaTexture* tex = LLViewerMediaTexture::findMediaTexture(id);
if(!tex)
@@ -225,7 +225,7 @@ LLViewerMediaTexture* LLViewerTextureManager::getMediaTexture(const LLUUID& id,
return tex;
}
-LLViewerFetchedTexture* LLViewerTextureManager::staticCastToFetchedTexture(LLTexture* tex, BOOL report_error)
+LLViewerFetchedTexture* LLViewerTextureManager::staticCastToFetchedTexture(LLTexture* tex, bool report_error)
{
if(!tex)
{
@@ -246,7 +246,7 @@ LLViewerFetchedTexture* LLViewerTextureManager::staticCastToFetchedTexture(LLTex
return NULL;
}
-LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(BOOL usemipmaps, BOOL generate_gl_tex)
+LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(bool usemipmaps, bool generate_gl_tex)
{
LLPointer<LLViewerTexture> tex = new LLViewerTexture(usemipmaps);
if(generate_gl_tex)
@@ -256,7 +256,7 @@ LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(BOOL usemipma
}
return tex;
}
-LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const LLUUID& id, BOOL usemipmaps, BOOL generate_gl_tex)
+LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const LLUUID& id, bool usemipmaps, bool generate_gl_tex)
{
LLPointer<LLViewerTexture> tex = new LLViewerTexture(id, usemipmaps);
if(generate_gl_tex)
@@ -266,13 +266,13 @@ LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const LLUUID&
}
return tex;
}
-LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const LLImageRaw* raw, BOOL usemipmaps)
+LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const LLImageRaw* raw, bool usemipmaps)
{
LLPointer<LLViewerTexture> tex = new LLViewerTexture(raw, usemipmaps);
tex->setCategory(LLGLTexture::LOCAL);
return tex;
}
-LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const U32 width, const U32 height, const U8 components, BOOL usemipmaps, BOOL generate_gl_tex)
+LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const U32 width, const U32 height, const U8 components, bool usemipmaps, bool generate_gl_tex)
{
LLPointer<LLViewerTexture> tex = new LLViewerTexture(width, height, components, usemipmaps);
if(generate_gl_tex)
@@ -285,6 +285,7 @@ LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const U32 wid
LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTexture(const LLImageRaw* raw, FTType type, bool usemipmaps)
{
+ LLImageDataSharedLock lock(raw);
LLViewerFetchedTexture* ret = new LLViewerFetchedTexture(raw, type, usemipmaps);
gTextureList.addImage(ret, TEX_LIST_STANDARD);
return ret;
@@ -293,7 +294,7 @@ LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTexture(const LLImageR
LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTexture(
const LLUUID &image_id,
FTType f_type,
- BOOL usemipmaps,
+ bool usemipmaps,
LLViewerTexture::EBoostLevel boost_priority,
S8 texture_type,
LLGLint internal_format,
@@ -306,7 +307,7 @@ LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTexture(
LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromFile(
const std::string& filename,
FTType f_type,
- BOOL usemipmaps,
+ bool usemipmaps,
LLViewerTexture::EBoostLevel boost_priority,
S8 texture_type,
LLGLint internal_format,
@@ -319,7 +320,7 @@ LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromFile(
//static
LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromUrl(const std::string& url,
FTType f_type,
- BOOL usemipmaps,
+ bool usemipmaps,
LLViewerTexture::EBoostLevel boost_priority,
S8 texture_type,
LLGLint internal_format,
@@ -330,6 +331,18 @@ LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromUrl(const s
return gTextureList.getImageFromUrl(url, f_type, usemipmaps, boost_priority, texture_type, internal_format, primary_format, force_id);
}
+//static
+LLImageRaw* LLViewerTextureManager::getRawImageFromMemory(const U8* data, U32 size, std::string_view mimetype)
+{
+ return gTextureList.getRawImageFromMemory(data, size, mimetype);
+}
+
+//static
+LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromMemory(const U8* data, U32 size, std::string_view mimetype)
+{
+ return gTextureList.getImageFromMemory(data, size, mimetype);
+}
+
LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromHost(const LLUUID& image_id, FTType f_type, LLHost host)
{
return gTextureList.getImageFromHost(image_id, f_type, host);
@@ -338,12 +351,12 @@ LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromHost(const
// Create a bridge to the viewer texture manager.
class LLViewerTextureManagerBridge : public LLTextureManagerBridge
{
- /*virtual*/ LLPointer<LLGLTexture> getLocalTexture(BOOL usemipmaps = TRUE, BOOL generate_gl_tex = TRUE)
+ /*virtual*/ LLPointer<LLGLTexture> getLocalTexture(bool usemipmaps = true, bool generate_gl_tex = true)
{
return LLViewerTextureManager::getLocalTexture(usemipmaps, generate_gl_tex);
}
- /*virtual*/ LLPointer<LLGLTexture> getLocalTexture(const U32 width, const U32 height, const U8 components, BOOL usemipmaps, BOOL generate_gl_tex = TRUE)
+ /*virtual*/ LLPointer<LLGLTexture> getLocalTexture(const U32 width, const U32 height, const U8 components, bool usemipmaps, bool generate_gl_tex = true)
{
return LLViewerTextureManager::getLocalTexture(width, height, components, usemipmaps, generate_gl_tex);
}
@@ -360,7 +373,7 @@ void LLViewerTextureManager::init()
{
LLPointer<LLImageRaw> raw = new LLImageRaw(1,1,3);
raw->clear(0x77, 0x77, 0x77, 0xFF);
- LLViewerTexture::sNullImagep = LLViewerTextureManager::getLocalTexture(raw.get(), TRUE);
+ LLViewerTexture::sNullImagep = LLViewerTextureManager::getLocalTexture(raw.get(), true);
}
const S32 dim = 128;
@@ -368,7 +381,7 @@ void LLViewerTextureManager::init()
U8* data = image_raw->getData();
memset(data, 0, dim * dim * 3);
- LLViewerTexture::sBlackImagep = LLViewerTextureManager::getLocalTexture(image_raw.get(), TRUE);
+ LLViewerTexture::sBlackImagep = LLViewerTextureManager::getLocalTexture(image_raw.get(), true);
#if 1
LLPointer<LLViewerFetchedTexture> imagep = LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT);
@@ -396,11 +409,9 @@ void LLViewerTextureManager::init()
}
}
imagep->createGLTexture(0, image_raw);
- //cache the raw image
- imagep->setCachedRawImage(0, image_raw);
image_raw = NULL;
#else
- LLViewerFetchedTexture::sDefaultImagep = LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
+ LLViewerFetchedTexture::sDefaultImagep = LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, true, LLGLTexture::BOOST_UI);
#endif
LLViewerFetchedTexture::sDefaultImagep->dontDiscard();
LLViewerFetchedTexture::sDefaultImagep->setCategory(LLGLTexture::OTHER);
@@ -418,7 +429,7 @@ void LLViewerTextureManager::init()
data[i+2] = color;
}
- LLViewerTexture::sCheckerBoardImagep = LLViewerTextureManager::getLocalTexture(image_raw.get(), TRUE);
+ LLViewerTexture::sCheckerBoardImagep = LLViewerTextureManager::getLocalTexture(image_raw.get(), true);
LLViewerTexture::initClass();
@@ -467,58 +478,6 @@ void LLViewerTexture::initClass()
LLImageGL::sDefaultGLTexture = LLViewerFetchedTexture::sDefaultImagep->getGLTexture();
}
-// tuning params
-const F32 GPU_MEMORY_CHECK_WAIT_TIME = 1.0f;
-// non-const (used externally
-F32 texmem_lower_bound_scale = 0.85f;
-F32 texmem_middle_bound_scale = 0.925f;
-
-//static
-bool LLViewerTexture::isMemoryForTextureLow()
-{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
- // Note: we need to figure out a better source for 'min' values,
- // what is free for low end at minimal settings is 'nothing left'
- // for higher end gpus at high settings.
- const S32Megabytes MIN_FREE_TEXTURE_MEMORY(20);
- const S32Megabytes MIN_FREE_MAIN_MEMORY(100);
-
- S32Megabytes gpu;
- S32Megabytes physical;
- getGPUMemoryForTextures(gpu, physical);
-
- return (gpu < MIN_FREE_TEXTURE_MEMORY); // || (physical < MIN_FREE_MAIN_MEMORY);
-}
-
-//static
-void LLViewerTexture::getGPUMemoryForTextures(S32Megabytes &gpu, S32Megabytes &physical)
-{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
- static LLFrameTimer timer;
-
- static S32Megabytes gpu_res = S32Megabytes(S32_MAX);
- static S32Megabytes physical_res = S32Megabytes(S32_MAX);
-
- if (timer.getElapsedTimeF32() < GPU_MEMORY_CHECK_WAIT_TIME) //call this once per second.
- {
- gpu = gpu_res;
- physical = physical_res;
- return;
- }
- timer.reset();
-
- {
- gpu_res = (S32Megabytes)gViewerWindow->getWindow()->getAvailableVRAMMegabytes();
-
- //check main memory, only works for windows and macos.
- LLMemory::updateMemoryInfo();
- physical_res = LLMemory::getAvailableMemKB();
-
- gpu = gpu_res;
- physical = physical_res;
- }
-}
-
//static
void LLViewerTexture::updateClass()
{
@@ -537,32 +496,88 @@ void LLViewerTexture::updateClass()
F64 texture_bytes_alloc = LLImageGL::getTextureBytesAllocated() / 1024.0 / 512.0;
F64 vertex_bytes_alloc = LLVertexBuffer::getBytesAllocated() / 1024.0 / 512.0;
+ F64 render_bytes_alloc = LLRenderTarget::sBytesAllocated / 1024.0 / 512.0;
// get an estimate of how much video memory we're using
// NOTE: our metrics miss about half the vram we use, so this biases high but turns out to typically be within 5% of the real number
- F32 used = (F32)ll_round(texture_bytes_alloc + vertex_bytes_alloc);
+ F32 used = (F32)ll_round(texture_bytes_alloc + vertex_bytes_alloc + render_bytes_alloc);
- F32 budget = max_vram_budget == 0 ? gGLManager.mVRAM : max_vram_budget;
+ F32 budget = max_vram_budget == 0 ? (F32)gGLManager.mVRAM : (F32)max_vram_budget;
// try to leave half a GB for everyone else, but keep at least 768MB for ourselves
- F32 target = llmax(budget - 512.f, 768.f);
+ F32 target = llmax(budget - 512.f, MIN_VRAM_BUDGET);
+ sFreeVRAMMegabytes = target - used;
+
+ F32 over_pct = (used - target) / target;
- F32 over_pct = llmax((used-target) / target, 0.f);
- sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.f + over_pct);
+ bool is_low = over_pct > 0.f;
- if (sDesiredDiscardBias > 1.f)
+ if (isSystemMemoryLow())
+ {
+ is_low = true;
+ // System RAM is low -> ramp up discard bias over time to free memory
+ if (sEvaluationTimer.getElapsedTimeF32() > MEMORY_CHECK_WAIT_TIME)
+ {
+ static LLCachedControl<F32> low_mem_min_discard_increment(gSavedSettings, "RenderLowMemMinDiscardIncrement", .1f);
+ sDesiredDiscardBias += (F32) low_mem_min_discard_increment * (F32) gFrameIntervalSeconds;
+ sEvaluationTimer.reset();
+ }
+ }
+ else
{
- sDesiredDiscardBias -= gFrameIntervalSeconds * 0.01;
+ sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.f + over_pct);
+
+ if (sDesiredDiscardBias > 1.f && over_pct < 0.f)
+ {
+ sDesiredDiscardBias -= gFrameIntervalSeconds * 0.01f;
+ }
}
- LLViewerTexture::sFreezeImageUpdates = false; // sDesiredDiscardBias > (desired_discard_bias_max - 1.0f);
+ static bool was_low = false;
+ if (is_low && !was_low)
+ {
+ LL_WARNS() << "Low system memory detected, emergency downrezzing off screen textures" << LL_ENDL;
+ sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.5f);
+
+ for (auto image : gTextureList)
+ {
+ gTextureList.updateImageDecodePriority(image);
+ }
+ }
+
+ was_low = is_low;
+
+ sDesiredDiscardBias = llclamp(sDesiredDiscardBias, 1.f, 3.f);
+
+ LLViewerTexture::sFreezeImageUpdates = false;
+}
+
+//static
+bool LLViewerTexture::isSystemMemoryLow()
+{
+ static LLFrameTimer timer;
+ static U32Megabytes physical_res = U32Megabytes(U32_MAX);
+
+ static LLCachedControl<U32> min_free_main_memory(gSavedSettings, "RenderMinFreeMainMemoryThreshold", 512);
+ const U32Megabytes MIN_FREE_MAIN_MEMORY(min_free_main_memory);
+
+ if (timer.getElapsedTimeF32() < MEMORY_CHECK_WAIT_TIME) //call this once per second.
+ {
+ return physical_res < MIN_FREE_MAIN_MEMORY;
+ }
+
+ timer.reset();
+
+ LLMemory::updateMemoryInfo();
+ physical_res = LLMemory::getAvailableMemKB();
+ return physical_res < MIN_FREE_MAIN_MEMORY;
}
//end of static functions
//-------------------------------------------------------------------------------------------
const U32 LLViewerTexture::sCurrentFileVersion = 1;
-LLViewerTexture::LLViewerTexture(BOOL usemipmaps) :
+LLViewerTexture::LLViewerTexture(bool usemipmaps) :
LLGLTexture(usemipmaps)
{
init(true);
@@ -571,7 +586,7 @@ LLViewerTexture::LLViewerTexture(BOOL usemipmaps) :
sImageCount++;
}
-LLViewerTexture::LLViewerTexture(const LLUUID& id, BOOL usemipmaps) :
+LLViewerTexture::LLViewerTexture(const LLUUID& id, bool usemipmaps) :
LLGLTexture(usemipmaps),
mID(id)
{
@@ -580,7 +595,7 @@ LLViewerTexture::LLViewerTexture(const LLUUID& id, BOOL usemipmaps) :
sImageCount++;
}
-LLViewerTexture::LLViewerTexture(const U32 width, const U32 height, const U8 components, BOOL usemipmaps) :
+LLViewerTexture::LLViewerTexture(const U32 width, const U32 height, const U8 components, bool usemipmaps) :
LLGLTexture(width, height, components, usemipmaps)
{
init(true);
@@ -589,7 +604,7 @@ LLViewerTexture::LLViewerTexture(const U32 width, const U32 height, const U8 com
sImageCount++;
}
-LLViewerTexture::LLViewerTexture(const LLImageRaw* raw, BOOL usemipmaps) :
+LLViewerTexture::LLViewerTexture(const LLImageRaw* raw, bool usemipmaps) :
LLGLTexture(raw, usemipmaps)
{
init(true);
@@ -614,16 +629,15 @@ void LLViewerTexture::init(bool firstinit)
mParcelMedia = NULL;
memset(&mNumVolumes, 0, sizeof(U32)* LLRender::NUM_VOLUME_TEXTURE_CHANNELS);
- mFaceList[LLRender::DIFFUSE_MAP].clear();
- mFaceList[LLRender::NORMAL_MAP].clear();
- mFaceList[LLRender::SPECULAR_MAP].clear();
- mNumFaces[LLRender::DIFFUSE_MAP] =
- mNumFaces[LLRender::NORMAL_MAP] =
- mNumFaces[LLRender::SPECULAR_MAP] = 0;
-
mVolumeList[LLRender::LIGHT_TEX].clear();
mVolumeList[LLRender::SCULPT_TEX].clear();
+ for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; i++)
+ {
+ mNumFaces[i] = 0;
+ mFaceList[i].clear();
+ }
+
mMainQueue = LL::WorkQueue::getInstance("mainloop");
mImageQueue = LL::WorkQueue::getInstance("LLImageGL");
}
@@ -725,9 +739,6 @@ bool LLViewerTexture::bindDefaultImage(S32 stage)
}
stop_glerror();
- //check if there is cached raw image and switch to it if possible
- switchToCachedImage();
-
LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName);
if (tester)
{
@@ -737,9 +748,9 @@ bool LLViewerTexture::bindDefaultImage(S32 stage)
}
//virtual
-BOOL LLViewerTexture::isMissingAsset()const
+bool LLViewerTexture::isMissingAsset()const
{
- return FALSE;
+ return false;
}
//virtual
@@ -747,12 +758,12 @@ void LLViewerTexture::forceImmediateUpdate()
{
}
-void LLViewerTexture::addTextureStats(F32 virtual_size, BOOL needs_gltexture) const
+void LLViewerTexture::addTextureStats(F32 virtual_size, bool needs_gltexture) const
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
if(needs_gltexture)
{
- mNeedsGLTexture = TRUE;
+ mNeedsGLTexture = true;
}
virtual_size = llmin(virtual_size, LLViewerFetchedTexture::sMaxVirtualSize);
@@ -806,8 +817,8 @@ void LLViewerTexture::removeFace(U32 ch, LLFace* facep)
if(mNumFaces[ch] > 1)
{
S32 index = facep->getIndexInTex(ch);
- llassert(index < mFaceList[ch].size());
- llassert(index < mNumFaces[ch]);
+ llassert(index < (S32)mFaceList[ch].size());
+ llassert(index < (S32)mNumFaces[ch]);
mFaceList[ch][index] = mFaceList[ch][--mNumFaces[ch]];
mFaceList[ch][index]->setIndexInTex(ch, index);
}
@@ -859,8 +870,8 @@ void LLViewerTexture::removeVolume(U32 ch, LLVOVolume* volumep)
if (mNumVolumes[ch] > 1)
{
S32 index = volumep->getIndexInTex(ch);
- llassert(index < mVolumeList[ch].size());
- llassert(index < mNumVolumes[ch]);
+ llassert(index < (S32)mVolumeList[ch].size());
+ llassert(index < (S32)mNumVolumes[ch]);
mVolumeList[ch][index] = mVolumeList[ch][--mNumVolumes[ch]];
mVolumeList[ch][index]->setIndexInTex(ch, index);
}
@@ -928,19 +939,7 @@ void LLViewerTexture::reorganizeVolumeList()
}
}
-//virtual
-void LLViewerTexture::switchToCachedImage()
-{
- //nothing here.
-}
-
-//virtual
-void LLViewerTexture::setCachedRawImage(S32 discard_level, LLImageRaw* imageraw)
-{
- //nothing here.
-}
-
-BOOL LLViewerTexture::isLargeImage()
+bool LLViewerTexture::isLargeImage()
{
return (S32)mTexelsPerImage > LLViewerTexture::sMinLargeImageSize;
}
@@ -997,11 +996,11 @@ LLViewerFetchedTexture* LLViewerFetchedTexture::getSmokeImage()
return sSmokeImagep;
}
-LLViewerFetchedTexture::LLViewerFetchedTexture(const LLUUID& id, FTType f_type, const LLHost& host, BOOL usemipmaps)
+LLViewerFetchedTexture::LLViewerFetchedTexture(const LLUUID& id, FTType f_type, const LLHost& host, bool usemipmaps)
: LLViewerTexture(id, usemipmaps),
mTargetHost(host)
{
- init(TRUE);
+ init(true);
mFTType = f_type;
if (mFTType == FTT_HOST_BAKE)
{
@@ -1010,18 +1009,18 @@ LLViewerFetchedTexture::LLViewerFetchedTexture(const LLUUID& id, FTType f_type,
generateGLTexture();
}
-LLViewerFetchedTexture::LLViewerFetchedTexture(const LLImageRaw* raw, FTType f_type, BOOL usemipmaps)
+LLViewerFetchedTexture::LLViewerFetchedTexture(const LLImageRaw* raw, FTType f_type, bool usemipmaps)
: LLViewerTexture(raw, usemipmaps)
{
- init(TRUE);
+ init(true);
mFTType = f_type;
}
-LLViewerFetchedTexture::LLViewerFetchedTexture(const std::string& url, FTType f_type, const LLUUID& id, BOOL usemipmaps)
+LLViewerFetchedTexture::LLViewerFetchedTexture(const std::string& url, FTType f_type, const LLUUID& id, bool usemipmaps)
: LLViewerTexture(id, usemipmaps),
mUrl(url)
{
- init(TRUE);
+ init(true);
mFTType = f_type;
generateGLTexture();
}
@@ -1030,20 +1029,20 @@ void LLViewerFetchedTexture::init(bool firstinit)
{
mOrigWidth = 0;
mOrigHeight = 0;
- mHasAux = FALSE;
- mNeedsAux = FALSE;
+ mHasAux = false;
+ mNeedsAux = false;
mRequestedDiscardLevel = -1;
mRequestedDownloadPriority = 0.f;
- mFullyLoaded = FALSE;
+ mFullyLoaded = false;
mCanUseHTTP = true;
mDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1;
mMinDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1;
- mDecodingAux = FALSE;
+ mDecodingAux = false;
mKnownDrawWidth = 0;
mKnownDrawHeight = 0;
- mKnownDrawSizeChanged = FALSE;
+ mKnownDrawSizeChanged = false;
if (firstinit)
{
@@ -1052,43 +1051,39 @@ void LLViewerFetchedTexture::init(bool firstinit)
// Only set mIsMissingAsset true when we know for certain that the database
// does not contain this image.
- mIsMissingAsset = FALSE;
+ mIsMissingAsset = false;
mLoadedCallbackDesiredDiscardLevel = S8_MAX;
- mPauseLoadedCallBacks = FALSE;
+ mPauseLoadedCallBacks = false;
mNeedsCreateTexture = false;
- mIsRawImageValid = FALSE;
+ mIsRawImageValid = false;
mRawDiscardLevel = INVALID_DISCARD_LEVEL;
mMinDiscardLevel = 0;
- mHasFetcher = FALSE;
- mIsFetching = FALSE;
+ mHasFetcher = false;
+ mIsFetching = false;
mFetchState = 0;
mFetchPriority = 0;
mDownloadProgress = 0.f;
mFetchDeltaTime = 999999.f;
mRequestDeltaTime = 0.f;
- mForSculpt = FALSE;
- mIsFetched = FALSE;
- mInFastCacheList = FALSE;
-
- mCachedRawImage = NULL;
- mCachedRawDiscardLevel = -1;
- mCachedRawImageReady = FALSE;
+ mForSculpt = false;
+ mIsFetched = false;
+ mInFastCacheList = false;
mSavedRawImage = NULL;
- mForceToSaveRawImage = FALSE;
- mSaveRawImage = FALSE;
+ mForceToSaveRawImage = false;
+ mSaveRawImage = false;
mSavedRawDiscardLevel = -1;
mDesiredSavedRawDiscardLevel = -1;
mLastReferencedSavedRawImageTime = 0.0f;
mKeptSavedRawImageTime = 0.f;
mLastCallBackActiveTime = 0.f;
- mForceCallbackFetch = FALSE;
- mInDebug = FALSE;
- mUnremovable = FALSE;
+ mForceCallbackFetch = false;
+ mInDebug = false;
+ mUnremovable = false;
mFTType = FTT_UNKNOWN;
}
@@ -1126,18 +1121,15 @@ void LLViewerFetchedTexture::cleanup()
LLLoadedCallbackEntry *entryp = *iter++;
// We never finished loading the image. Indicate failure.
// Note: this allows mLoadedCallbackUserData to be cleaned up.
- entryp->mCallback( FALSE, this, NULL, NULL, 0, TRUE, entryp->mUserData );
+ entryp->mCallback( false, this, NULL, NULL, 0, true, entryp->mUserData );
entryp->removeTexture(this);
delete entryp;
}
mLoadedCallbackList.clear();
- mNeedsAux = FALSE;
+ mNeedsAux = false;
// Clean up image data
destroyRawImage();
- mCachedRawImage = NULL;
- mCachedRawDiscardLevel = -1;
- mCachedRawImageReady = FALSE;
mSavedRawImage = NULL;
mSavedRawDiscardLevel = -1;
}
@@ -1150,7 +1142,7 @@ void LLViewerFetchedTexture::loadFromFastCache()
{
return; //no need to access the fast cache.
}
- mInFastCacheList = FALSE;
+ mInFastCacheList = false;
add(LLTextureFetch::sCacheAttempt, 1.0);
@@ -1203,7 +1195,7 @@ void LLViewerFetchedTexture::loadFromFastCache()
}
mRequestedDiscardLevel = mDesiredDiscardLevel + 1;
- mIsRawImageValid = TRUE;
+ mIsRawImageValid = true;
addToCreateTexture();
}
}
@@ -1217,32 +1209,36 @@ void LLViewerFetchedTexture::setForSculpt()
{
static const S32 MAX_INTERVAL = 8; //frames
- mForSculpt = TRUE;
+ forceToSaveRawImage(0, F32_MAX);
+
+ setBoostLevel(llmax((S32)getBoostLevel(),
+ (S32)LLGLTexture::BOOST_SCULPTED));
+
+ mForSculpt = true;
if(isForSculptOnly() && hasGLTexture() && !getBoundRecently())
{
destroyGLTexture(); //sculpt image does not need gl texture.
mTextureState = ACTIVE;
}
- checkCachedRawSculptImage();
setMaxVirtualSizeResetInterval(MAX_INTERVAL);
}
-BOOL LLViewerFetchedTexture::isForSculptOnly() const
+bool LLViewerFetchedTexture::isForSculptOnly() const
{
return mForSculpt && !mNeedsGLTexture;
}
-BOOL LLViewerFetchedTexture::isDeleted()
+bool LLViewerFetchedTexture::isDeleted()
{
return mTextureState == DELETED;
}
-BOOL LLViewerFetchedTexture::isInactive()
+bool LLViewerFetchedTexture::isInactive()
{
return mTextureState == INACTIVE;
}
-BOOL LLViewerFetchedTexture::isDeletionCandidate()
+bool LLViewerFetchedTexture::isDeletionCandidate()
{
return mTextureState == DELETION_CANDIDATE;
}
@@ -1264,7 +1260,7 @@ void LLViewerFetchedTexture::setInactive()
}
}
-BOOL LLViewerFetchedTexture::isFullyLoaded() const
+bool LLViewerFetchedTexture::isFullyLoaded() const
{
// Unfortunately, the boolean "mFullyLoaded" is never updated correctly so we use that logic
// to check if the texture is there and completely downloaded
@@ -1311,7 +1307,7 @@ void LLViewerFetchedTexture::destroyTexture()
//LL_DEBUGS("Avatar") << mID << LL_ENDL;
destroyGLTexture();
- mFullyLoaded = FALSE;
+ mFullyLoaded = false;
}
void LLViewerFetchedTexture::addToCreateTexture()
@@ -1336,10 +1332,6 @@ void LLViewerFetchedTexture::addToCreateTexture()
}
}
- //discard the cached raw image and the saved raw image
- mCachedRawImageReady = FALSE;
- mCachedRawDiscardLevel = -1;
- mCachedRawImage = NULL;
mSavedRawDiscardLevel = -1;
mSavedRawImage = NULL;
}
@@ -1347,7 +1339,7 @@ void LLViewerFetchedTexture::addToCreateTexture()
if(isForSculptOnly())
{
//just update some variables, not to create a real GL texture.
- createGLTexture(mRawDiscardLevel, mRawImage, 0, FALSE);
+ createGLTexture(mRawDiscardLevel, mRawImage, 0, false);
mNeedsCreateTexture = false;
destroyRawImage();
}
@@ -1367,8 +1359,8 @@ void LLViewerFetchedTexture::addToCreateTexture()
//
if(mRequestedDiscardLevel <= mDesiredDiscardLevel && !mForceToSaveRawImage)
{
- S32 w = mFullWidth >> mRawDiscardLevel;
- S32 h = mFullHeight >> mRawDiscardLevel;
+ U32 w = mFullWidth >> mRawDiscardLevel;
+ U32 h = mFullHeight >> mRawDiscardLevel;
//if big image, do not load extra data
//scale it down to size >= LLViewerTexture::sMinLargeImageSize
@@ -1409,7 +1401,7 @@ void LLViewerFetchedTexture::addToCreateTexture()
}
// ONLY called from LLViewerTextureList
-BOOL LLViewerFetchedTexture::preCreateTexture(S32 usename/*= 0*/)
+bool LLViewerFetchedTexture::preCreateTexture(S32 usename/*= 0*/)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
#if LL_IMAGEGL_THREAD_CHECK
@@ -1419,7 +1411,7 @@ BOOL LLViewerFetchedTexture::preCreateTexture(S32 usename/*= 0*/)
if (!mNeedsCreateTexture)
{
destroyRawImage();
- return FALSE;
+ return false;
}
mNeedsCreateTexture = false;
@@ -1431,13 +1423,13 @@ BOOL LLViewerFetchedTexture::preCreateTexture(S32 usename/*= 0*/)
{
LL_WARNS() << "Can't create a texture: invalid image data" << LL_ENDL;
destroyRawImage();
- return FALSE;
+ return false;
}
// LL_INFOS() << llformat("IMAGE Creating (%d) [%d x %d] Bytes: %d ",
// mRawDiscardLevel,
// mRawImage->getWidth(), mRawImage->getHeight(),mRawImage->getDataSize())
// << mID.getString() << LL_ENDL;
- BOOL res = TRUE;
+ bool res = true;
// store original size only for locally-sourced images
if (mUrl.compare(0, 7, "file://") == 0)
@@ -1453,7 +1445,7 @@ BOOL LLViewerFetchedTexture::preCreateTexture(S32 usename/*= 0*/)
}
else
{ // leave black border, do not scale image content
- mRawImage->expandToPowerOfTwo(MAX_IMAGE_SIZE, FALSE);
+ mRawImage->expandToPowerOfTwo(MAX_IMAGE_SIZE, false);
}
mFullWidth = mRawImage->getWidth();
@@ -1499,7 +1491,7 @@ BOOL LLViewerFetchedTexture::preCreateTexture(S32 usename/*= 0*/)
LL_WARNS() << "!size_ok, setting as missing" << LL_ENDL;
setIsMissingAsset();
destroyRawImage();
- return FALSE;
+ return false;
}
if (mGLTexturep->getHasExplicitFormat())
@@ -1518,21 +1510,21 @@ BOOL LLViewerFetchedTexture::preCreateTexture(S32 usename/*= 0*/)
setIsMissingAsset();
destroyRawImage();
LLAppViewer::getTextureCache()->removeFromCache(mID);
- return FALSE;
+ return false;
}
}
return res;
}
-BOOL LLViewerFetchedTexture::createTexture(S32 usename/*= 0*/)
+bool LLViewerFetchedTexture::createTexture(S32 usename/*= 0*/)
{
if (!mNeedsCreateTexture)
{
- return FALSE;
+ return false;
}
- BOOL res = mGLTexturep->createGLTexture(mRawDiscardLevel, mRawImage, usename, TRUE, mBoostLevel);
+ bool res = mGLTexturep->createGLTexture(mRawDiscardLevel, mRawImage, usename, true, mBoostLevel);
return res;
}
@@ -1552,7 +1544,7 @@ void LLViewerFetchedTexture::postCreateTexture()
if (!needsToSaveRawImage())
{
- mNeedsAux = FALSE;
+ mNeedsAux = false;
destroyRawImage();
}
@@ -1629,7 +1621,11 @@ void LLViewerFetchedTexture::scheduleCreateTexture()
}
else
{
- gTextureList.mCreateTextureList.insert(this);
+ if (!mCreatePending)
+ {
+ mCreatePending = true;
+ gTextureList.mCreateTextureList.push(this);
+ }
}
}
}
@@ -1645,21 +1641,20 @@ void LLViewerFetchedTexture::setKnownDrawSize(S32 width, S32 height)
mKnownDrawWidth = llmax(mKnownDrawWidth, width);
mKnownDrawHeight = llmax(mKnownDrawHeight, height);
- mKnownDrawSizeChanged = TRUE;
- mFullyLoaded = FALSE;
+ mKnownDrawSizeChanged = true;
+ mFullyLoaded = false;
}
addTextureStats((F32)(mKnownDrawWidth * mKnownDrawHeight));
}
void LLViewerFetchedTexture::setDebugText(const std::string& text)
{
- for (U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch)
+ for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i)
{
- llassert(mNumFaces[ch] <= mFaceList[ch].size());
-
- for (U32 i = 0; i < mNumFaces[ch]; i++)
+ for (S32 fi = 0; fi < getNumFaces(i); ++fi)
{
- LLFace* facep = mFaceList[ch][i];
+ LLFace* facep = (*(getFaceList(i)))[fi];
+
if (facep)
{
LLDrawable* drawable = facep->getDrawable();
@@ -1672,16 +1667,21 @@ void LLViewerFetchedTexture::setDebugText(const std::string& text)
}
}
+extern bool gCubeSnapshot;
+
//virtual
void LLViewerFetchedTexture::processTextureStats()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
+ llassert(!gCubeSnapshot); // should only be called when the main camera is active
+ llassert(!LLPipeline::sShadowRender);
+
if(mFullyLoaded)
{
if(mDesiredDiscardLevel > mMinDesiredDiscardLevel)//need to load more
{
mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, mMinDesiredDiscardLevel);
- mFullyLoaded = FALSE;
+ mFullyLoaded = false;
}
//setDebugText("fully loaded");
}
@@ -1713,7 +1713,7 @@ void LLViewerFetchedTexture::processTextureStats()
else
{
U32 desired_size = MAX_IMAGE_SIZE_DEFAULT; // MAX_IMAGE_SIZE_DEFAULT = 2048 and max size ever is 4096
- if(!mKnownDrawWidth || !mKnownDrawHeight || mFullWidth <= mKnownDrawWidth || mFullHeight <= mKnownDrawHeight)
+ if(!mKnownDrawWidth || !mKnownDrawHeight || (S32)mFullWidth <= mKnownDrawWidth || (S32)mFullHeight <= mKnownDrawHeight)
{
if (mFullWidth > desired_size || mFullHeight > desired_size)
{
@@ -1731,11 +1731,11 @@ void LLViewerFetchedTexture::processTextureStats()
mDesiredDiscardLevel = llclamp(mDesiredDiscardLevel, (S8)0, (S8)getMaxDiscardLevel());
mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, mMinDesiredDiscardLevel);
}
- mKnownDrawSizeChanged = FALSE;
+ mKnownDrawSizeChanged = false;
if(getDiscardLevel() >= 0 && (getDiscardLevel() <= mDesiredDiscardLevel))
{
- mFullyLoaded = TRUE;
+ mFullyLoaded = true;
}
}
}
@@ -1745,7 +1745,7 @@ void LLViewerFetchedTexture::processTextureStats()
mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, (S8)mDesiredSavedRawDiscardLevel);
if(getDiscardLevel() < 0 || getDiscardLevel() > mDesiredDiscardLevel)
{
- mFullyLoaded = FALSE;
+ mFullyLoaded = false;
}
}
}
@@ -1781,10 +1781,10 @@ bool LLViewerFetchedTexture::setDebugFetching(S32 debug_level)
{
if(debug_level < 0)
{
- mInDebug = FALSE;
+ mInDebug = false;
return false;
}
- mInDebug = TRUE;
+ mInDebug = true;
mDesiredDiscardLevel = debug_level;
@@ -1877,12 +1877,12 @@ bool LLViewerFetchedTexture::updateFetch()
if (mRawImage.notNull()) sRawCount++;
if (mAuxRawImage.notNull())
{
- mHasAux = TRUE;
+ mHasAux = true;
sAuxCount++;
}
if (finished)
{
- mIsFetching = FALSE;
+ mIsFetching = false;
mLastFetchState = -1;
mLastPacketTimer.reset();
}
@@ -1899,7 +1899,7 @@ bool LLViewerFetchedTexture::updateFetch()
LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName);
if (tester)
{
- mIsFetched = TRUE;
+ mIsFetched = true;
tester->updateTextureLoadingStats(this, mRawImage, LLAppViewer::getTextureFetch()->isFromLocalCache(mID));
}
mRawDiscardLevel = fetch_discard;
@@ -1918,12 +1918,12 @@ bool LLViewerFetchedTexture::updateFetch()
LL_WARNS() << "oversize, setting as missing" << LL_ENDL;
setIsMissingAsset();
mRawDiscardLevel = INVALID_DISCARD_LEVEL;
- mIsFetching = FALSE;
+ mIsFetching = false;
mLastPacketTimer.reset();
}
else
{
- mIsRawImageValid = TRUE;
+ mIsRawImageValid = true;
addToCreateTexture();
}
@@ -1951,7 +1951,7 @@ bool LLViewerFetchedTexture::updateFetch()
}
}
- return TRUE;
+ return true;
}
else
{
@@ -2040,13 +2040,6 @@ bool LLViewerFetchedTexture::updateFetch()
LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - current < min");
make_request = false;
}
- else if(mCachedRawImage.notNull() // can be empty
- && mCachedRawImageReady
- && (current_discard < 0 || current_discard > mCachedRawDiscardLevel))
- {
- make_request = false;
- switchToCachedImage(); //use the cached raw data first
- }
if (make_request)
{
@@ -2095,8 +2088,8 @@ bool LLViewerFetchedTexture::updateFetch()
if (fetch_request_discard >= 0)
{
LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - request created");
- mHasFetcher = TRUE;
- mIsFetching = TRUE;
+ mHasFetcher = true;
+ mIsFetching = true;
// in some cases createRequest can modify discard, as an example
// bake textures are always at discard 0
mRequestedDiscardLevel = llmin(desired_discard, fetch_request_discard);
@@ -2120,11 +2113,11 @@ bool LLViewerFetchedTexture::updateFetch()
{
LL_DEBUGS("Texture") << "exceeded idle time " << FETCH_IDLE_TIME << ", deleting request: " << getID() << LL_ENDL;
LLAppViewer::getTextureFetch()->deleteRequest(getID(), true);
- mHasFetcher = FALSE;
+ mHasFetcher = false;
}
}
- return mIsFetching ? true : false;
+ return mIsFetching;
}
void LLViewerFetchedTexture::clearFetchedResults()
@@ -2147,8 +2140,8 @@ void LLViewerFetchedTexture::forceToDeleteRequest()
{
if (mHasFetcher)
{
- mHasFetcher = FALSE;
- mIsFetching = FALSE;
+ mHasFetcher = false;
+ mIsFetching = false;
}
resetTextureStats();
@@ -2156,7 +2149,7 @@ void LLViewerFetchedTexture::forceToDeleteRequest()
mDesiredDiscardLevel = getMaxDiscardLevel() + 1;
}
-void LLViewerFetchedTexture::setIsMissingAsset(BOOL is_missing)
+void LLViewerFetchedTexture::setIsMissingAsset(bool is_missing)
{
if (is_missing == mIsMissingAsset)
{
@@ -2181,8 +2174,8 @@ void LLViewerFetchedTexture::setIsMissingAsset(BOOL is_missing)
if (mHasFetcher)
{
LLAppViewer::getTextureFetch()->deleteRequest(getID(), true);
- mHasFetcher = FALSE;
- mIsFetching = FALSE;
+ mHasFetcher = false;
+ mIsFetching = false;
mLastPacketTimer.reset();
mFetchState = 0;
mFetchPriority = 0;
@@ -2196,8 +2189,8 @@ void LLViewerFetchedTexture::setIsMissingAsset(BOOL is_missing)
}
void LLViewerFetchedTexture::setLoadedCallback( loaded_callback_func loaded_callback,
- S32 discard_level, BOOL keep_imageraw, BOOL needs_aux, void* userdata,
- LLLoadedCallbackEntry::source_callback_list_t* src_callback_list, BOOL pause)
+ S32 discard_level, bool keep_imageraw, bool needs_aux, void* userdata,
+ LLLoadedCallbackEntry::source_callback_list_t* src_callback_list, bool pause)
{
//
// Don't do ANYTHING here, just add it to the global callback list
@@ -2231,7 +2224,7 @@ void LLViewerFetchedTexture::setLoadedCallback( loaded_callback_func loaded_call
mNeedsAux |= needs_aux;
if(keep_imageraw)
{
- mSaveRawImage = TRUE;
+ mSaveRawImage = true;
}
if (mNeedsAux && mAuxRawImage.isNull() && getDiscardLevel() >= 0)
{
@@ -2264,7 +2257,7 @@ void LLViewerFetchedTexture::clearCallbackEntryList()
// We never finished loading the image. Indicate failure.
// Note: this allows mLoadedCallbackUserData to be cleaned up.
- entryp->mCallback(FALSE, this, NULL, NULL, 0, TRUE, entryp->mUserData);
+ entryp->mCallback(false, this, NULL, NULL, 0, true, entryp->mUserData);
iter = mLoadedCallbackList.erase(iter);
delete entryp;
}
@@ -2296,7 +2289,7 @@ void LLViewerFetchedTexture::deleteCallbackEntry(const LLLoadedCallbackEntry::so
{
// We never finished loading the image. Indicate failure.
// Note: this allows mLoadedCallbackUserData to be cleaned up.
- entryp->mCallback(FALSE, this, NULL, NULL, 0, TRUE, entryp->mUserData);
+ entryp->mCallback(false, this, NULL, NULL, 0, true, entryp->mUserData);
iter = mLoadedCallbackList.erase(iter);
delete entryp;
}
@@ -2340,30 +2333,30 @@ void LLViewerFetchedTexture::unpauseLoadedCallbacks(const LLLoadedCallbackEntry:
{
if(!callback_list)
{
- mPauseLoadedCallBacks = FALSE;
+ mPauseLoadedCallBacks = false;
return;
}
- BOOL need_raw = FALSE;
+ bool need_raw = false;
for(callback_list_t::iterator iter = mLoadedCallbackList.begin();
iter != mLoadedCallbackList.end(); )
{
LLLoadedCallbackEntry *entryp = *iter++;
if(entryp->mSourceCallbackList == callback_list)
{
- entryp->mPaused = FALSE;
+ entryp->mPaused = false;
if(entryp->mNeedsImageRaw)
{
- need_raw = TRUE;
+ need_raw = true;
}
}
}
- mPauseLoadedCallBacks = FALSE ;
+ mPauseLoadedCallBacks = false ;
mLastCallBackActiveTime = sCurrentTime ;
- mForceCallbackFetch = TRUE;
+ mForceCallbackFetch = true;
if(need_raw)
{
- mSaveRawImage = TRUE;
+ mSaveRawImage = true;
}
}
@@ -2382,7 +2375,7 @@ void LLViewerFetchedTexture::pauseLoadedCallbacks(const LLLoadedCallbackEntry::s
LLLoadedCallbackEntry *entryp = *iter++;
if(entryp->mSourceCallbackList == callback_list)
{
- entryp->mPaused = TRUE;
+ entryp->mPaused = true;
}
else if(!entryp->mPaused)
{
@@ -2392,9 +2385,9 @@ void LLViewerFetchedTexture::pauseLoadedCallbacks(const LLLoadedCallbackEntry::s
if(paused)
{
- mPauseLoadedCallBacks = TRUE;//when set, loaded callback is paused.
+ mPauseLoadedCallBacks = true;//when set, loaded callback is paused.
resetTextureStats();
- mSaveRawImage = FALSE;
+ mSaveRawImage = false;
}
}
@@ -2445,7 +2438,7 @@ bool LLViewerFetchedTexture::doLoadedCallbacks()
LLLoadedCallbackEntry *entryp = *iter++;
// We never finished loading the image. Indicate failure.
// Note: this allows mLoadedCallbackUserData to be cleaned up.
- entryp->mCallback(FALSE, this, NULL, NULL, 0, TRUE, entryp->mUserData);
+ entryp->mCallback(false, this, NULL, NULL, 0, true, entryp->mUserData);
delete entryp;
}
mLoadedCallbackList.clear();
@@ -2540,20 +2533,6 @@ bool LLViewerFetchedTexture::doLoadedCallbacks()
}
//
- // Do a readback if required, OR start off a texture decode
- //
- if (need_readback && (getMaxDiscardLevel() > gl_discard))
- {
- // Do a readback to get the GL data into the raw image
- // We have GL data.
-
- destroyRawImage();
- reloadRawImage(mLoadedCallbackDesiredDiscardLevel);
- llassert(mRawImage.notNull());
- llassert(!mNeedsAux || mAuxRawImage.notNull());
- }
-
- //
// Run raw/auxiliary data callbacks
//
if (run_raw_callbacks && mIsRawImageValid && (mRawDiscardLevel <= getMaxDiscardLevel()))
@@ -2578,11 +2557,11 @@ bool LLViewerFetchedTexture::doLoadedCallbacks()
{
LL_WARNS() << "Raw Image with no Aux Data for callback" << LL_ENDL;
}
- BOOL final = mRawDiscardLevel <= entryp->mDesiredDiscard ? TRUE : FALSE;
+ bool final = mRawDiscardLevel <= entryp->mDesiredDiscard;
//LL_INFOS() << "Running callback for " << getID() << LL_ENDL;
//LL_INFOS() << mRawImage->getWidth() << "x" << mRawImage->getHeight() << LL_ENDL;
entryp->mLastUsedDiscard = mRawDiscardLevel;
- entryp->mCallback(TRUE, this, mRawImage, mAuxRawImage, mRawDiscardLevel, final, entryp->mUserData);
+ entryp->mCallback(true, this, mRawImage, mAuxRawImage, mRawDiscardLevel, final, entryp->mUserData);
if (final)
{
iter = mLoadedCallbackList.erase(curiter);
@@ -2609,9 +2588,9 @@ bool LLViewerFetchedTexture::doLoadedCallbacks()
if (!entryp->mNeedsImageRaw && (entryp->mLastUsedDiscard > gl_discard))
{
mLastCallBackActiveTime = sCurrentTime;
- BOOL final = gl_discard <= entryp->mDesiredDiscard ? TRUE : FALSE;
+ bool final = gl_discard <= entryp->mDesiredDiscard;
entryp->mLastUsedDiscard = gl_discard;
- entryp->mCallback(TRUE, this, NULL, NULL, gl_discard, final, entryp->mUserData);
+ entryp->mCallback(true, this, NULL, NULL, gl_discard, final, entryp->mUserData);
if (final)
{
iter = mLoadedCallbackList.erase(curiter);
@@ -2636,7 +2615,7 @@ bool LLViewerFetchedTexture::doLoadedCallbacks()
{
//wait for long enough but no fetching request issued, force one.
forceToRefetchTexture(mLoadedCallbackDesiredDiscardLevel, 5.f);
- mForceCallbackFetch = FALSE; //fire once.
+ mForceCallbackFetch = false; //fire once.
}
return res;
@@ -2660,61 +2639,6 @@ void LLViewerFetchedTexture::forceImmediateUpdate()
return;
}
-LLImageRaw* LLViewerFetchedTexture::reloadRawImage(S8 discard_level)
-{
- llassert(mGLTexturep.notNull());
- llassert(discard_level >= 0);
- llassert(mComponents > 0);
-
- if (mRawImage.notNull())
- {
- //mRawImage is in use by somebody else, do not delete it.
- return NULL;
- }
-
- if(mSavedRawDiscardLevel >= 0 && mSavedRawDiscardLevel <= discard_level)
- {
- if (mSavedRawDiscardLevel != discard_level
- && mBoostLevel != BOOST_ICON
- && mBoostLevel != BOOST_THUMBNAIL)
- {
- mRawImage = new LLImageRaw(getWidth(discard_level), getHeight(discard_level), getComponents());
- mRawImage->copy(getSavedRawImage());
- }
- else
- {
- mRawImage = getSavedRawImage();
- }
- mRawDiscardLevel = discard_level;
- }
- else
- {
- //force to fetch raw image again if cached raw image is not good enough.
- if(mCachedRawDiscardLevel > discard_level)
- {
- mRawImage = mCachedRawImage;
- mRawDiscardLevel = mCachedRawDiscardLevel;
- }
- else //cached raw image is good enough, copy it.
- {
- if(mCachedRawDiscardLevel != discard_level)
- {
- mRawImage = new LLImageRaw(getWidth(discard_level), getHeight(discard_level), getComponents());
- mRawImage->copy(mCachedRawImage);
- }
- else
- {
- mRawImage = mCachedRawImage;
- }
- mRawDiscardLevel = discard_level;
- }
- }
- mIsRawImageValid = TRUE;
- sRawCount++;
-
- return mRawImage;
-}
-
bool LLViewerFetchedTexture::needsToSaveRawImage()
{
return mForceToSaveRawImage || mSaveRawImage;
@@ -2739,161 +2663,15 @@ void LLViewerFetchedTexture::destroyRawImage()
{
saveRawImage();
}
- setCachedRawImage();
}
mRawImage = NULL;
- mIsRawImageValid = FALSE;
+ mIsRawImageValid = false;
mRawDiscardLevel = INVALID_DISCARD_LEVEL;
}
}
-//use the mCachedRawImage to (re)generate the gl texture.
-//virtual
-void LLViewerFetchedTexture::switchToCachedImage()
-{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
- if(mCachedRawImage.notNull() &&
- !mNeedsCreateTexture) // <--- texture creation is pending, don't step on it
- {
- mRawImage = mCachedRawImage;
-
- if (getComponents() != mRawImage->getComponents())
- {
- // We've changed the number of components, so we need to move any
- // objects using this pool to a different pool.
- mComponents = mRawImage->getComponents();
- mGLTexturep->setComponents(mComponents);
- gTextureList.dirtyImage(this);
- }
-
- mIsRawImageValid = TRUE;
- mRawDiscardLevel = mCachedRawDiscardLevel;
-
- scheduleCreateTexture();
- }
-}
-
-//cache the imageraw forcefully.
-//virtual
-void LLViewerFetchedTexture::setCachedRawImage(S32 discard_level, LLImageRaw* imageraw)
-{
- if(imageraw != mRawImage.get())
- {
- if (mBoostLevel == LLGLTexture::BOOST_ICON)
- {
- S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENSIONS;
- S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENSIONS;
- if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)
- {
- mCachedRawImage = new LLImageRaw(expected_width, expected_height, imageraw->getComponents());
- mCachedRawImage->copyScaled(imageraw);
- }
- else
- {
- mCachedRawImage = imageraw;
- }
- }
- else if (mBoostLevel == LLGLTexture::BOOST_THUMBNAIL)
- {
- S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_THUMBNAIL_DIMENSIONS;
- S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_THUMBNAIL_DIMENSIONS;
- if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)
- {
- mCachedRawImage = new LLImageRaw(expected_width, expected_height, imageraw->getComponents());
- mCachedRawImage->copyScaled(imageraw);
- }
- else
- {
- mCachedRawImage = imageraw;
- }
- }
- else
- {
- mCachedRawImage = imageraw;
- }
- mCachedRawDiscardLevel = discard_level;
- mCachedRawImageReady = TRUE;
- }
-}
-
-void LLViewerFetchedTexture::setCachedRawImage()
-{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
- if(mRawImage == mCachedRawImage)
- {
- return;
- }
- if(!mIsRawImageValid)
- {
- return;
- }
-
- if(mCachedRawImageReady)
- {
- return;
- }
-
- if(mCachedRawDiscardLevel < 0 || mCachedRawDiscardLevel > mRawDiscardLevel)
- {
- S32 i = 0;
- S32 w = mRawImage->getWidth();
- S32 h = mRawImage->getHeight();
-
- S32 max_size = MAX_CACHED_RAW_IMAGE_AREA;
- if(LLGLTexture::BOOST_TERRAIN == mBoostLevel)
- {
- max_size = MAX_CACHED_RAW_TERRAIN_IMAGE_AREA;
- }
- if(mForSculpt)
- {
- max_size = MAX_CACHED_RAW_SCULPT_IMAGE_AREA;
- mCachedRawImageReady = !mRawDiscardLevel;
- }
- else
- {
- mCachedRawImageReady = (!mRawDiscardLevel || ((w * h) >= max_size));
- }
-
- while(((w >> i) * (h >> i)) > max_size)
- {
- ++i;
- }
-
- if(i)
- {
- if(!(w >> i) || !(h >> i))
- {
- --i;
- }
-
- {
- //make a duplicate in case somebody else is using this raw image
- mRawImage = mRawImage->scaled(w >> i, h >> i);
- }
- }
- mCachedRawImage = mRawImage;
- mRawDiscardLevel += i;
- mCachedRawDiscardLevel = mRawDiscardLevel;
- }
-}
-
-void LLViewerFetchedTexture::checkCachedRawSculptImage()
-{
- if(mCachedRawImageReady && mCachedRawDiscardLevel > 0)
- {
- if(getDiscardLevel() != 0)
- {
- mCachedRawImageReady = FALSE;
- }
- else if(isForSculptOnly())
- {
- resetTextureStats(); //do not update this image any more.
- }
- }
-}
-
void LLViewerFetchedTexture::saveRawImage()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
@@ -2902,6 +2680,8 @@ void LLViewerFetchedTexture::saveRawImage()
return;
}
+ LLImageDataSharedLock lock(mRawImage);
+
mSavedRawDiscardLevel = mRawDiscardLevel;
if (mBoostLevel == LLGLTexture::BOOST_ICON)
{
@@ -2931,6 +2711,20 @@ void LLViewerFetchedTexture::saveRawImage()
mSavedRawImage = new LLImageRaw(mRawImage->getData(), mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents());
}
}
+ else if (mBoostLevel == LLGLTexture::BOOST_SCULPTED)
+ {
+ S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : sMaxSculptRez;
+ S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : sMaxSculptRez;
+ if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)
+ {
+ mSavedRawImage = new LLImageRaw(expected_width, expected_height, mRawImage->getComponents());
+ mSavedRawImage->copyScaled(mRawImage);
+ }
+ else
+ {
+ mSavedRawImage = new LLImageRaw(mRawImage->getData(), mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents());
+ }
+ }
else
{
mSavedRawImage = new LLImageRaw(mRawImage->getData(), mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents());
@@ -2938,7 +2732,7 @@ void LLViewerFetchedTexture::saveRawImage()
if(mForceToSaveRawImage && mSavedRawDiscardLevel <= mDesiredSavedRawDiscardLevel)
{
- mForceToSaveRawImage = FALSE;
+ mForceToSaveRawImage = false;
}
mLastReferencedSavedRawImageTime = sCurrentTime;
@@ -2954,7 +2748,7 @@ void LLViewerFetchedTexture::forceToRefetchTexture(S32 desired_discard, F32 kept
}
//trigger a new fetch.
- mForceToSaveRawImage = TRUE ;
+ mForceToSaveRawImage = true ;
mDesiredSavedRawDiscardLevel = desired_discard ;
mKeptSavedRawImageTime = kept_time ;
mLastReferencedSavedRawImageTime = sCurrentTime ;
@@ -2974,22 +2768,25 @@ void LLViewerFetchedTexture::forceToSaveRawImage(S32 desired_discard, F32 kept_t
if(!mForceToSaveRawImage || mDesiredSavedRawDiscardLevel < 0 || mDesiredSavedRawDiscardLevel > desired_discard)
{
- mForceToSaveRawImage = TRUE;
+ mForceToSaveRawImage = true;
mDesiredSavedRawDiscardLevel = desired_discard;
+ }
+}
- //copy from the cached raw image if exists.
- if(mCachedRawImage.notNull() && mRawImage.isNull() )
- {
- mRawImage = mCachedRawImage;
- mRawDiscardLevel = mCachedRawDiscardLevel;
-
- saveRawImage();
+void LLViewerFetchedTexture::readbackRawImage()
+{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
- mRawImage = NULL;
- mRawDiscardLevel = INVALID_DISCARD_LEVEL;
+ if (mGLTexturep.notNull() && mGLTexturep->getTexName() != 0 && mRawImage.isNull())
+ {
+ mRawImage = new LLImageRaw();
+ if (!mGLTexturep->readBackRaw(-1, mRawImage, false))
+ {
+ mRawImage = nullptr;
}
}
}
+
void LLViewerFetchedTexture::destroySavedRawImage()
{
if(mLastReferencedSavedRawImageTime < mKeptSavedRawImageTime)
@@ -2997,14 +2794,14 @@ void LLViewerFetchedTexture::destroySavedRawImage()
return; //keep the saved raw image.
}
- mForceToSaveRawImage = FALSE;
- mSaveRawImage = FALSE;
+ mForceToSaveRawImage = false;
+ mSaveRawImage = false;
clearCallbackEntryList();
mSavedRawImage = NULL ;
- mForceToSaveRawImage = FALSE ;
- mSaveRawImage = FALSE ;
+ mForceToSaveRawImage = false ;
+ mSaveRawImage = false ;
mSavedRawDiscardLevel = -1 ;
mDesiredSavedRawDiscardLevel = -1 ;
mLastReferencedSavedRawImageTime = 0.0f ;
@@ -3024,7 +2821,12 @@ LLImageRaw* LLViewerFetchedTexture::getSavedRawImage()
return mSavedRawImage;
}
-BOOL LLViewerFetchedTexture::hasSavedRawImage() const
+const LLImageRaw* LLViewerFetchedTexture::getSavedRawImage() const
+{
+ return mSavedRawImage;
+}
+
+bool LLViewerFetchedTexture::hasSavedRawImage() const
{
return mSavedRawImage.notNull();
}
@@ -3041,21 +2843,21 @@ F32 LLViewerFetchedTexture::getElapsedLastReferencedSavedRawImageTime() const
//----------------------------------------------------------------------------------------------
//start of LLViewerLODTexture
//----------------------------------------------------------------------------------------------
-LLViewerLODTexture::LLViewerLODTexture(const LLUUID& id, FTType f_type, const LLHost& host, BOOL usemipmaps)
+LLViewerLODTexture::LLViewerLODTexture(const LLUUID& id, FTType f_type, const LLHost& host, bool usemipmaps)
: LLViewerFetchedTexture(id, f_type, host, usemipmaps)
{
- init(TRUE);
+ init(true);
}
-LLViewerLODTexture::LLViewerLODTexture(const std::string& url, FTType f_type, const LLUUID& id, BOOL usemipmaps)
+LLViewerLODTexture::LLViewerLODTexture(const std::string& url, FTType f_type, const LLUUID& id, bool usemipmaps)
: LLViewerFetchedTexture(url, f_type, id, usemipmaps)
{
- init(TRUE);
+ init(true);
}
void LLViewerLODTexture::init(bool firstinit)
{
- mTexelsPerImage = 64.f*64.f;
+ mTexelsPerImage = 64*64;
mDiscardVirtualSize = 0.f;
mCalculatedDiscardLevel = -1.f;
}
@@ -3078,6 +2880,8 @@ void LLViewerLODTexture::processTextureStats()
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
updateVirtualSize();
+ bool did_downscale = false;
+
static LLCachedControl<bool> textures_fullres(gSavedSettings,"TextureLoadFullRes", false);
{ // restrict texture resolution to download based on RenderMaxTextureResolution
@@ -3135,10 +2939,7 @@ void LLViewerLODTexture::processTextureStats()
mDiscardVirtualSize = mMaxVirtualSize;
mCalculatedDiscardLevel = discard_level;
}
- if (mBoostLevel < LLGLTexture::BOOST_SCULPTED)
- {
- discard_level *= sDesiredDiscardScale; // scale (default 1.1f)
- }
+
discard_level = floorf(discard_level);
F32 min_discard = 0.f;
@@ -3164,10 +2965,9 @@ void LLViewerLODTexture::processTextureStats()
//
S32 current_discard = getDiscardLevel();
- if (mBoostLevel < LLGLTexture::BOOST_AVATAR_BAKED &&
- current_discard >= 0)
+ if (mBoostLevel < LLGLTexture::BOOST_AVATAR_BAKED)
{
- if (current_discard < (mDesiredDiscardLevel-1) && !mForceToSaveRawImage)
+ if (current_discard < mDesiredDiscardLevel && !mForceToSaveRawImage)
{ // should scale down
scaleDown();
}
@@ -3187,9 +2987,6 @@ void LLViewerLODTexture::processTextureStats()
mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, (S8)mDesiredSavedRawDiscardLevel);
}
- // decay max virtual size over time
- mMaxVirtualSize *= 0.8f;
-
// selection manager will immediately reset BOOST_SELECTED but never unsets it
// unset it immediately after we consume it
if (getBoostLevel() == BOOST_SELECTED)
@@ -3198,22 +2995,24 @@ void LLViewerLODTexture::processTextureStats()
}
}
+extern LLGLSLShader gCopyProgram;
+
bool LLViewerLODTexture::scaleDown()
{
- if(hasGLTexture() && mCachedRawDiscardLevel > getDiscardLevel())
+ if (mGLTexturep.isNull() || !mGLTexturep->getHasGLTexture())
{
- switchToCachedImage();
-
- LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName);
- if (tester)
- {
- tester->setStablizingTime();
- }
+ return false;
+ }
- return true;
+ if (!mDownScalePending)
+ {
+ mDownScalePending = true;
+ gTextureList.mDownScaleQueue.push(this);
}
- return false;
+
+ return true;
}
+
//----------------------------------------------------------------------------------------------
//end of LLViewerLODTexture
//----------------------------------------------------------------------------------------------
@@ -3284,7 +3083,7 @@ LLViewerMediaTexture* LLViewerMediaTexture::findMediaTexture(const LLUUID& media
return media_tex;
}
-LLViewerMediaTexture::LLViewerMediaTexture(const LLUUID& id, BOOL usemipmaps, LLImageGL* gl_image)
+LLViewerMediaTexture::LLViewerMediaTexture(const LLUUID& id, bool usemipmaps, LLImageGL* gl_image)
: LLViewerTexture(id, usemipmaps),
mMediaImplp(NULL),
mUpdateVirtualSizeTime(0)
@@ -3300,9 +3099,9 @@ LLViewerMediaTexture::LLViewerMediaTexture(const LLUUID& id, BOOL usemipmaps, LL
mGLTexturep->setAllowCompression(false);
- mGLTexturep->setNeedsAlphaAndPickMask(FALSE);
+ mGLTexturep->setNeedsAlphaAndPickMask(false);
- mIsPlaying = FALSE;
+ mIsPlaying = false;
setMediaImpl();
@@ -3325,17 +3124,17 @@ LLViewerMediaTexture::~LLViewerMediaTexture()
}
}
-void LLViewerMediaTexture::reinit(BOOL usemipmaps /* = TRUE */)
+void LLViewerMediaTexture::reinit(bool usemipmaps /* = true */)
{
llassert(mGLTexturep.notNull());
mUseMipMaps = usemipmaps;
getLastReferencedTimer()->reset();
mGLTexturep->setUseMipMaps(mUseMipMaps);
- mGLTexturep->setNeedsAlphaAndPickMask(FALSE);
+ mGLTexturep->setNeedsAlphaAndPickMask(false);
}
-void LLViewerMediaTexture::setUseMipMaps(BOOL mipmap)
+void LLViewerMediaTexture::setUseMipMaps(bool mipmap)
{
mUseMipMaps = mipmap;
@@ -3367,11 +3166,11 @@ void LLViewerMediaTexture::setMediaImpl()
//return true if all faces to reference to this media texture are found
//Note: mMediaFaceList is valid only for the current instant
// because it does not check the face validity after the current frame.
-BOOL LLViewerMediaTexture::findFaces()
+bool LLViewerMediaTexture::findFaces()
{
mMediaFaceList.clear();
- BOOL ret = TRUE;
+ bool ret = true;
LLViewerTexture* tex = gTextureList.findImage(mID, TEX_LIST_STANDARD);
if(tex) //this media is a parcel media for tex.
@@ -3392,7 +3191,7 @@ BOOL LLViewerMediaTexture::findFaces()
if(!mMediaImplp)
{
- return TRUE;
+ return true;
}
//for media on a face.
@@ -3408,13 +3207,13 @@ BOOL LLViewerMediaTexture::findFaces()
// If this happens, viewer is likely to crash
llassert(0);
LL_WARNS() << "Dead object in mMediaImplp's object list" << LL_ENDL;
- ret = FALSE;
+ ret = false;
continue;
}
if (obj->mDrawable.isNull() || obj->mDrawable->isDead())
{
- ret = FALSE;
+ ret = false;
continue;
}
@@ -3429,7 +3228,7 @@ BOOL LLViewerMediaTexture::findFaces()
}
else
{
- ret = FALSE;
+ ret = false;
}
}
}
@@ -3478,9 +3277,9 @@ void LLViewerMediaTexture::removeMediaFromFace(LLFace* facep)
return; //no need to remove the face because the media is not in playing.
}
- mIsPlaying = FALSE; //set to remove the media from the face.
+ mIsPlaying = false; //set to remove the media from the face.
switchTexture(LLRender::DIFFUSE_MAP, facep);
- mIsPlaying = TRUE; //set the flag back.
+ mIsPlaying = true; //set the flag back.
if(getTotalNumFaces() < 1) //no face referencing to this media
{
@@ -3563,12 +3362,12 @@ void LLViewerMediaTexture::removeFace(U32 ch, LLFace* facep)
return;
}
- S32 end = te_list.size();
+ auto end = te_list.size();
for(std::list< LLPointer<LLViewerTexture> >::iterator iter = mTextureList.begin();
iter != mTextureList.end(); ++iter)
{
- S32 i = 0;
+ size_t i = 0;
for(i = 0; i < end; i++)
{
@@ -3611,7 +3410,7 @@ void LLViewerMediaTexture::stopPlaying()
// {
// mMediaImplp->stop();
// }
- mIsPlaying = FALSE;
+ mIsPlaying = false;
}
void LLViewerMediaTexture::switchTexture(U32 ch, LLFace* facep)
@@ -3652,7 +3451,7 @@ void LLViewerMediaTexture::switchTexture(U32 ch, LLFace* facep)
}
}
-void LLViewerMediaTexture::setPlaying(BOOL playing)
+void LLViewerMediaTexture::setPlaying(bool playing)
{
if(!mMediaImplp)
{
@@ -3674,7 +3473,7 @@ void LLViewerMediaTexture::setPlaying(BOOL playing)
if(findFaces())
{
//about to update all faces.
- mMediaImplp->setUpdated(FALSE);
+ mMediaImplp->setUpdated(false);
}
if(mMediaFaceList.empty())//no face pointing to this media
@@ -3685,7 +3484,19 @@ void LLViewerMediaTexture::setPlaying(BOOL playing)
for(std::list< LLFace* >::iterator iter = mMediaFaceList.begin(); iter!= mMediaFaceList.end(); ++iter)
{
- switchTexture(LLRender::DIFFUSE_MAP, *iter);
+ LLFace* facep = *iter;
+ const LLTextureEntry* te = facep->getTextureEntry();
+ if (te->getGLTFMaterial())
+ {
+ // PBR material, switch emissive and basecolor
+ switchTexture(LLRender::EMISSIVE_MAP, *iter);
+ switchTexture(LLRender::BASECOLOR_MAP, *iter);
+ }
+ else
+ {
+ // blinn-phong material, switch diffuse map only
+ switchTexture(LLRender::DIFFUSE_MAP, *iter);
+ }
}
}
else //stop playing this media
@@ -3712,7 +3523,7 @@ F32 LLViewerMediaTexture::getMaxVirtualSize()
if(!mMaxVirtualSizeResetCounter)
{
- addTextureStats(0.f, FALSE);//reset
+ addTextureStats(0.f, false);//reset
}
if(mIsPlaying) //media is playing
@@ -3807,13 +3618,13 @@ void LLTexturePipelineTester::update()
//start a new fetching session
reset();
mStartFetchingTime = LLImageGL::sLastFrameTime;
- mPause = FALSE;
+ mPause = false;
}
//update total gray time
if(mUsingDefaultTexture)
{
- mUsingDefaultTexture = FALSE;
+ mUsingDefaultTexture = false;
mTotalGrayTime = LLImageGL::sLastFrameTime - mStartFetchingTime;
}
@@ -3825,7 +3636,7 @@ void LLTexturePipelineTester::update()
else if(!mPause)
{
//stop the current fetching session
- mPause = TRUE;
+ mPause = true;
outputTestResults();
reset();
}
@@ -3833,9 +3644,9 @@ void LLTexturePipelineTester::update()
void LLTexturePipelineTester::reset()
{
- mPause = TRUE;
+ mPause = true;
- mUsingDefaultTexture = FALSE;
+ mUsingDefaultTexture = false;
mStartStablizingTime = 0.0f;
mEndStablizingTime = 0.0f;
@@ -3886,7 +3697,7 @@ void LLTexturePipelineTester::updateTextureBindingStats(const LLViewerTexture* i
}
}
-void LLTexturePipelineTester::updateTextureLoadingStats(const LLViewerFetchedTexture* imagep, const LLImageRaw* raw_imagep, BOOL from_cache)
+void LLTexturePipelineTester::updateTextureLoadingStats(const LLViewerFetchedTexture* imagep, const LLImageRaw* raw_imagep, bool from_cache)
{
U32Bytes data_size = (U32Bytes)raw_imagep->getDataSize();
mTotalBytesLoaded += data_size;
@@ -3915,7 +3726,7 @@ void LLTexturePipelineTester::updateTextureLoadingStats(const LLViewerFetchedTex
void LLTexturePipelineTester::updateGrayTextureBinding()
{
- mUsingDefaultTexture = TRUE;
+ mUsingDefaultTexture = true;
}
void LLTexturePipelineTester::setStablizingTime()
@@ -4042,7 +3853,7 @@ LLMetricPerformanceTesterWithSession::LLTestSession* LLTexturePipelineTester::lo
//load a session
std::string currentLabel = getCurrentLabelName();
- BOOL in_log = (*log).has(currentLabel);
+ bool in_log = (*log).has(currentLabel);
while (in_log)
{
LLSD::String label = currentLabel;
@@ -4053,8 +3864,8 @@ LLMetricPerformanceTesterWithSession::LLTestSession* LLTexturePipelineTester::lo
}
//time
- F32 start_time = (*log)[label]["StartFetchingTime"].asReal();
- F32 cur_time = (*log)[label]["Time"].asReal();
+ F32 start_time = (F32)(*log)[label]["StartFetchingTime"].asReal();
+ F32 cur_time = (F32)(*log)[label]["Time"].asReal();
if(start_time - start_fetching_time > F_ALMOST_ZERO) //fetching has paused for a while
{
sessionp->mTotalGrayTime += total_gray_time;
@@ -4070,13 +3881,13 @@ LLMetricPerformanceTesterWithSession::LLTestSession* LLTexturePipelineTester::lo
}
else
{
- total_gray_time = (*log)[label]["TotalGrayTime"].asReal();
- total_stablizing_time = (*log)[label]["TotalStablizingTime"].asReal();
+ total_gray_time = (F32)(*log)[label]["TotalGrayTime"].asReal();
+ total_stablizing_time = (F32)(*log)[label]["TotalStablizingTime"].asReal();
- total_loading_sculpties_time = (*log)[label]["EndTimeLoadingSculpties"].asReal() - (*log)[label]["StartTimeLoadingSculpties"].asReal();
+ total_loading_sculpties_time = (F32)(*log)[label]["EndTimeLoadingSculpties"].asReal() - (F32)(*log)[label]["StartTimeLoadingSculpties"].asReal();
if(start_fetching_sculpties_time < 0.f && total_loading_sculpties_time > 0.f)
{
- start_fetching_sculpties_time = (*log)[label]["StartTimeLoadingSculpties"].asReal();
+ start_fetching_sculpties_time = (F32)(*log)[label]["StartTimeLoadingSculpties"].asReal();
}
}
@@ -4092,7 +3903,7 @@ LLMetricPerformanceTesterWithSession::LLTestSession* LLTexturePipelineTester::lo
sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedForLargeImagePerSecond +=
(*log)[label]["TotalBytesBoundForLargeImage"].asInteger();
sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAveragePercentageBytesUsedPerSecond +=
- (*log)[label]["PercentageBytesBound"].asReal();
+ (F32)(*log)[label]["PercentageBytesBound"].asReal();
frame_count++;
if(cur_time - last_time >= 1.0f)
{