LL has played with texture discard priority/bias. Giving it a trial here.

This commit is contained in:
Shyotl
2012-06-11 07:04:02 -05:00
parent 945c663359
commit 349006637e
4 changed files with 104 additions and 50 deletions

View File

@@ -2,33 +2,26 @@
* @file llviewertexture.cpp * @file llviewertexture.cpp
* @brief Object which handles a received image (and associated texture(s)) * @brief Object which handles a received image (and associated texture(s))
* *
* $LicenseInfo:firstyear=2000&license=viewergpl$ * $LicenseInfo:firstyear=2000&license=viewerlgpl$
*
* Copyright (c) 2000-2010, Linden Research, Inc.
*
* Second Life Viewer Source Code * Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab * Copyright (C) 2010, Linden Research, Inc.
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlife.com/developers/opensource/gplv2
* *
* There are special exceptions to the terms and conditions of the GPL as * This library is free software; you can redistribute it and/or
* it is applied to this Source Code. View the full text of the exception * modify it under the terms of the GNU Lesser General Public
* in the file doc/FLOSS-exception.txt in this software distribution, or * License as published by the Free Software Foundation;
* online at * version 2.1 of the License only.
* http://secondlife.com/developers/opensource/flossexception
* *
* By copying, modifying or distributing this software, you acknowledge * This library is distributed in the hope that it will be useful,
* that you have read and understood your obligations described above, * but WITHOUT ANY WARRANTY; without even the implied warranty of
* and agree to abide by those obligations. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* *
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO * You should have received a copy of the GNU Lesser General Public
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, * License along with this library; if not, write to the Free Software
* COMPLETENESS OR PERFORMANCE. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$ * $/LicenseInfo$
*
*/ */
#include "llviewerprecompiledheaders.h" #include "llviewerprecompiledheaders.h"
@@ -100,6 +93,7 @@ S32 LLViewerTexture::sMaxBoundTextureMemInMegaBytes = 0;
S32 LLViewerTexture::sMaxTotalTextureMemInMegaBytes = 0; S32 LLViewerTexture::sMaxTotalTextureMemInMegaBytes = 0;
S32 LLViewerTexture::sMaxDesiredTextureMemInBytes = 0 ; S32 LLViewerTexture::sMaxDesiredTextureMemInBytes = 0 ;
S8 LLViewerTexture::sCameraMovingDiscardBias = 0 ; S8 LLViewerTexture::sCameraMovingDiscardBias = 0 ;
F32 LLViewerTexture::sCameraMovingBias = 0.0f ;
S32 LLViewerTexture::sMaxSculptRez = 128 ; //max sculpt image size S32 LLViewerTexture::sMaxSculptRez = 128 ; //max sculpt image size
const S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64 ; const 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_SCULPT_IMAGE_AREA = LLViewerTexture::sMaxSculptRez * LLViewerTexture::sMaxSculptRez ;
@@ -109,6 +103,9 @@ S32 LLViewerTexture::sMaxSmallImageSize = MAX_CACHED_RAW_IMAGE_AREA ;
BOOL LLViewerTexture::sFreezeImageScalingDown = FALSE ; BOOL LLViewerTexture::sFreezeImageScalingDown = FALSE ;
F32 LLViewerTexture::sCurrentTime = 0.0f ; F32 LLViewerTexture::sCurrentTime = 0.0f ;
//BOOL LLViewerTexture::sUseTextureAtlas = FALSE ; //BOOL LLViewerTexture::sUseTextureAtlas = FALSE ;
F32 LLViewerTexture::sTexelPixelRatio = 1.0f;
LLViewerTexture::EDebugTexels LLViewerTexture::sDebugTexelsMode = LLViewerTexture::DEBUG_TEXELS_OFF;
const F32 desired_discard_bias_min = -2.0f; // -max number of levels to improve image quality by const F32 desired_discard_bias_min = -2.0f; // -max number of levels to improve image quality by
const F32 desired_discard_bias_max = (F32)MAX_DISCARD_LEVEL; // max number of levels to reduce image quality by const F32 desired_discard_bias_max = (F32)MAX_DISCARD_LEVEL; // max number of levels to reduce image quality by
@@ -193,6 +190,11 @@ LLViewerTexture* LLViewerTextureManager::findTexture(const LLUUID& id)
return tex ; return tex ;
} }
LLViewerFetchedTexture* LLViewerTextureManager::findFetchedTexture(const LLUUID& id)
{
return gTextureList.findImage(id);
}
#if NEW_MEDIA_TEXTURE #if NEW_MEDIA_TEXTURE
LLViewerMediaTexture* LLViewerTextureManager::findMediaTexture(const LLUUID &media_id) LLViewerMediaTexture* LLViewerTextureManager::findMediaTexture(const LLUUID &media_id)
{ {
@@ -406,7 +408,7 @@ void LLViewerTextureManager::cleanup()
void LLViewerTexture::initClass() void LLViewerTexture::initClass()
{ {
LLImageGL::sDefaultGLTexture = LLViewerFetchedTexture::sDefaultImagep->getGLTexture() ; LLImageGL::sDefaultGLTexture = LLViewerFetchedTexture::sDefaultImagep->getGLTexture() ;
sTexelPixelRatio = gSavedSettings.getF32("TexelPixelRatio");
if(gAuditTexture) if(gAuditTexture)
{ {
LLImageGL::setHighlightTexture(LLViewerTexture::OTHER) ; LLImageGL::setHighlightTexture(LLViewerTexture::OTHER) ;
@@ -561,7 +563,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
F32 camera_moving_speed = LLViewerCamera::getInstance()->getAverageSpeed() ; F32 camera_moving_speed = LLViewerCamera::getInstance()->getAverageSpeed() ;
F32 camera_angular_speed = LLViewerCamera::getInstance()->getAverageAngularSpeed(); F32 camera_angular_speed = LLViewerCamera::getInstance()->getAverageAngularSpeed();
sCameraMovingDiscardBias = (S8)llmax(0.2f * camera_moving_speed, 2.0f * camera_angular_speed - 1) ; sCameraMovingBias = llmax(0.2f * camera_moving_speed, 2.0f * camera_angular_speed - 1);
sCameraMovingDiscardBias = (S8)(sCameraMovingBias);
LLViewerTexture::sFreezeImageScalingDown = (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < 0.75f * sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale) && LLViewerTexture::sFreezeImageScalingDown = (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < 0.75f * sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale) &&
(BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < 0.75f * sMaxTotalTextureMemInMegaBytes * texmem_middle_bound_scale) ; (BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < 0.75f * sMaxTotalTextureMemInMegaBytes * texmem_middle_bound_scale) ;
@@ -745,6 +748,7 @@ void LLViewerTexture::addTextureStats(F32 virtual_size, BOOL needs_gltexture) co
mNeedsGLTexture = TRUE ; mNeedsGLTexture = TRUE ;
} }
virtual_size *= sTexelPixelRatio;
if(!mMaxVirtualSizeResetCounter) if(!mMaxVirtualSizeResetCounter)
{ {
//flag to reset the values because the old values are used. //flag to reset the values because the old values are used.
@@ -1923,6 +1927,8 @@ S32 LLViewerFetchedTexture::getCurrentDiscardLevelForFetching()
bool LLViewerFetchedTexture::updateFetch() bool LLViewerFetchedTexture::updateFetch()
{ {
static LLCachedControl<bool> textures_decode_disabled(gSavedSettings,"TextureDecodeDisabled"); static LLCachedControl<bool> textures_decode_disabled(gSavedSettings,"TextureDecodeDisabled");
static LLCachedControl<F32> sCameraMotionThreshold(gSavedSettings,"TextureCameraMotionThreshold");
static LLCachedControl<S32> sCameraMotionBoost(gSavedSettings,"TextureCameraMotionBoost");
if(textures_decode_disabled) if(textures_decode_disabled)
{ {
return false ; return false ;
@@ -2091,14 +2097,18 @@ bool LLViewerFetchedTexture::updateFetch()
{ {
//load the texture progressively. //load the texture progressively.
S32 delta_level = (mBoostLevel > LLViewerTexture::BOOST_NONE) ? 2 : 1 ; S32 delta_level = (mBoostLevel > LLViewerTexture::BOOST_NONE) ? 2 : 1 ;
if(current_discard < 0) if (current_discard < 0)
{ {
desired_discard = llmax(desired_discard, getMaxDiscardLevel() - delta_level); desired_discard = llmax(desired_discard, getMaxDiscardLevel() - delta_level);
} }
else else if (LLViewerTexture::sCameraMovingBias < sCameraMotionThreshold)
{ {
desired_discard = llmax(desired_discard, current_discard - delta_level); desired_discard = llmax(desired_discard, current_discard - sCameraMotionBoost);
} }
else
{
desired_discard = llmax(desired_discard, current_discard - delta_level);
}
if (mIsFetching) if (mIsFetching)
{ {
@@ -2166,6 +2176,17 @@ bool LLViewerFetchedTexture::updateFetch()
return mIsFetching ? true : false; return mIsFetching ? true : false;
} }
void LLViewerFetchedTexture::forceToDeleteRequest()
{
if (mHasFetcher)
{
LLAppViewer::getTextureFetch()->deleteRequest(getID(), true);
mHasFetcher = FALSE;
mIsFetching = FALSE ;
resetTextureStats();
}
}
void LLViewerFetchedTexture::setIsMissingAsset() void LLViewerFetchedTexture::setIsMissingAsset()
{ {
if (mUrl.empty()) if (mUrl.empty())

View File

@@ -322,6 +322,7 @@ protected:
} LLGLTextureState; } LLGLTextureState;
LLGLTextureState mTextureState ; LLGLTextureState mTextureState ;
static F32 sTexelPixelRatio;
public: public:
static const U32 sCurrentFileVersion; static const U32 sCurrentFileVersion;
static S32 sImageCount; static S32 sImageCount;
@@ -336,6 +337,7 @@ public:
static S32 sMaxTotalTextureMemInMegaBytes; static S32 sMaxTotalTextureMemInMegaBytes;
static S32 sMaxDesiredTextureMemInBytes ; static S32 sMaxDesiredTextureMemInBytes ;
static S8 sCameraMovingDiscardBias; static S8 sCameraMovingDiscardBias;
static F32 sCameraMovingBias;
static S32 sMaxSculptRez ; static S32 sMaxSculptRez ;
static S32 sMinLargeImageSize ; static S32 sMinLargeImageSize ;
static S32 sMaxSmallImageSize ; static S32 sMaxSmallImageSize ;
@@ -343,6 +345,16 @@ public:
static F32 sCurrentTime ; static F32 sCurrentTime ;
//static BOOL sUseTextureAtlas ; //static BOOL sUseTextureAtlas ;
enum EDebugTexels
{
DEBUG_TEXELS_OFF,
DEBUG_TEXELS_CURRENT,
DEBUG_TEXELS_DESIRED,
DEBUG_TEXELS_FULL
};
static EDebugTexels sDebugTexelsMode;
static LLPointer<LLViewerTexture> sNullImagep; // Null texture for non-textured objects. static LLPointer<LLViewerTexture> sNullImagep; // Null texture for non-textured objects.
static LLPointer<LLViewerTexture> sBlackImagep; // Texture to show NOTHING (pure black) static LLPointer<LLViewerTexture> sBlackImagep; // Texture to show NOTHING (pure black)
}; };
@@ -491,6 +503,7 @@ public:
BOOL hasFetcher() const { return mHasFetcher;} BOOL hasFetcher() const { return mHasFetcher;}
void setCanUseHTTP(bool can_use_http) {mCanUseHTTP = can_use_http;} void setCanUseHTTP(bool can_use_http) {mCanUseHTTP = can_use_http;}
void forceToDeleteRequest();
protected: protected:
/*virtual*/ void switchToCachedImage(); /*virtual*/ void switchToCachedImage();
S32 getCurrentDiscardLevelForFetching() ; S32 getCurrentDiscardLevelForFetching() ;
@@ -710,6 +723,7 @@ public:
//"find-texture" just check if the texture exists, if yes, return it, otherwise return null. //"find-texture" just check if the texture exists, if yes, return it, otherwise return null.
// //
static LLViewerTexture* findTexture(const LLUUID& id) ; static LLViewerTexture* findTexture(const LLUUID& id) ;
static LLViewerFetchedTexture* findFetchedTexture(const LLUUID& id) ;
#if NEW_MEDIA_TEXTURE #if NEW_MEDIA_TEXTURE
static LLViewerMediaTexture* findMediaTexture(const LLUUID& id) ; static LLViewerMediaTexture* findMediaTexture(const LLUUID& id) ;

View File

@@ -64,6 +64,7 @@
#include "llviewerstats.h" #include "llviewerstats.h"
#include "pipeline.h" #include "pipeline.h"
#include "llappviewer.h" #include "llappviewer.h"
#include "llagent.h"
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@@ -622,6 +623,11 @@ static LLFastTimer::DeclareTimer FTM_IMAGE_MEDIA("Media");
void LLViewerTextureList::updateImages(F32 max_time) void LLViewerTextureList::updateImages(F32 max_time)
{ {
if(gAgent.getTeleportState() != LLAgent::TELEPORT_NONE)
{
clearFetchingRequests();
return;
}
LLAppViewer::getTextureFetch()->setTextureBandwidth(LLViewerStats::getInstance()->mTextureKBitStat.getMeanPerSec()); LLAppViewer::getTextureFetch()->setTextureBandwidth(LLViewerStats::getInstance()->mTextureKBitStat.getMeanPerSec());
S32 global_raw_memory; S32 global_raw_memory;
@@ -693,6 +699,24 @@ void LLViewerTextureList::updateImages(F32 max_time)
} }
} }
void LLViewerTextureList::clearFetchingRequests()
{
if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
{
return;
}
for (image_priority_list_t::iterator iter = mImageList.begin();
iter != mImageList.end(); ++iter)
{
LLViewerFetchedTexture* image = *iter;
if(image->hasFetcher())
{
image->forceToDeleteRequest() ;
}
}
}
void LLViewerTextureList::updateImagesDecodePriorities() void LLViewerTextureList::updateImagesDecodePriorities()
{ {
// Update the decode priority for N images each frame // Update the decode priority for N images each frame

View File

@@ -2,33 +2,26 @@
* @file llviewertexturelist.h * @file llviewertexturelist.h
* @brief Object for managing the list of images within a region * @brief Object for managing the list of images within a region
* *
* $LicenseInfo:firstyear=2000&license=viewergpl$ * $LicenseInfo:firstyear=2000&license=viewerlgpl$
*
* Copyright (c) 2000-2010, Linden Research, Inc.
*
* Second Life Viewer Source Code * Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab * Copyright (C) 2010, Linden Research, Inc.
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlife.com/developers/opensource/gplv2
* *
* There are special exceptions to the terms and conditions of the GPL as * This library is free software; you can redistribute it and/or
* it is applied to this Source Code. View the full text of the exception * modify it under the terms of the GNU Lesser General Public
* in the file doc/FLOSS-exception.txt in this software distribution, or * License as published by the Free Software Foundation;
* online at * version 2.1 of the License only.
* http://secondlife.com/developers/opensource/flossexception
* *
* By copying, modifying or distributing this software, you acknowledge * This library is distributed in the hope that it will be useful,
* that you have read and understood your obligations described above, * but WITHOUT ANY WARRANTY; without even the implied warranty of
* and agree to abide by those obligations. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* *
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO * You should have received a copy of the GNU Lesser General Public
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, * License along with this library; if not, write to the Free Software
* COMPLETENESS OR PERFORMANCE. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$ * $/LicenseInfo$
*
*/ */
#ifndef LL_LLVIEWERTEXTURELIST_H #ifndef LL_LLVIEWERTEXTURELIST_H
@@ -116,6 +109,8 @@ public:
void doPreloadImages(); void doPreloadImages();
void doPrefetchImages(); void doPrefetchImages();
void clearFetchingRequests();
static S32 getMinVideoRamSetting(); static S32 getMinVideoRamSetting();
static S32 getMaxVideoRamSetting(bool get_recommended = false); static S32 getMaxVideoRamSetting(bool get_recommended = false);