aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewerimagelist.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llviewerimagelist.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llviewerimagelist.cpp')
-rw-r--r--linden/indra/newview/llviewerimagelist.cpp270
1 files changed, 76 insertions, 194 deletions
diff --git a/linden/indra/newview/llviewerimagelist.cpp b/linden/indra/newview/llviewerimagelist.cpp
index 99ac3a7..0e29f76 100644
--- a/linden/indra/newview/llviewerimagelist.cpp
+++ b/linden/indra/newview/llviewerimagelist.cpp
@@ -31,9 +31,8 @@
31 31
32#include "llviewerprecompiledheaders.h" 32#include "llviewerprecompiledheaders.h"
33 33
34#include <sys/stat.h>
35
36#include "llviewerimagelist.h" 34#include "llviewerimagelist.h"
35
37#include "imageids.h" 36#include "imageids.h"
38#include "llgl.h" // fot gathering stats from GL 37#include "llgl.h" // fot gathering stats from GL
39#include "llimagegl.h" 38#include "llimagegl.h"
@@ -42,7 +41,6 @@
42#include "llimagetga.h" 41#include "llimagetga.h"
43#include "llimagejpeg.h" 42#include "llimagejpeg.h"
44#include "llimagepng.h" 43#include "llimagepng.h"
45#include "llmediaengine.h"
46 44
47#include "llsdserialize.h" 45#include "llsdserialize.h"
48#include "llsys.h" 46#include "llsys.h"
@@ -56,10 +54,13 @@
56#include "lltexturefetch.h" 54#include "lltexturefetch.h"
57#include "llviewercontrol.h" 55#include "llviewercontrol.h"
58#include "llviewerimage.h" 56#include "llviewerimage.h"
57#include "llviewermedia.h"
59#include "llviewerregion.h" 58#include "llviewerregion.h"
60#include "pipeline.h" 59#include "pipeline.h"
61#include "llappviewer.h" 60#include "llappviewer.h"
62 61
62#include <sys/stat.h>
63
63//////////////////////////////////////////////////////////////////////////// 64////////////////////////////////////////////////////////////////////////////
64 65
65void (*LLViewerImageList::sUUIDCallback)(void **, const LLUUID&) = NULL; 66void (*LLViewerImageList::sUUIDCallback)(void **, const LLUUID&) = NULL;
@@ -85,12 +86,10 @@ LLStat LLViewerImageList::sFormattedMemStat(32, TRUE);
85/////////////////////////////////////////////////////////////////////////////// 86///////////////////////////////////////////////////////////////////////////////
86 87
87LLViewerImageList::LLViewerImageList() 88LLViewerImageList::LLViewerImageList()
88: LLImageProviderInterface(), 89 : LLImageProviderInterface(),
89mForceResetTextureStats(FALSE), 90 mForceResetTextureStats(FALSE),
90mUpdateStats(FALSE), 91 mUpdateStats(FALSE),
91mMaxResidentTexMem(0), 92 mMaxResidentTexMem(0)
92mVideoMemorySetting(0),
93mMovieImageHasMips(FALSE)
94{ 93{
95} 94}
96 95
@@ -98,7 +97,6 @@ void LLViewerImageList::init()
98{ 97{
99 sNumImages = 0; 98 sNumImages = 0;
100 mMaxResidentTexMem = 0; 99 mMaxResidentTexMem = 0;
101 mVideoMemorySetting = 0;
102 100
103 if (gNoRender) 101 if (gNoRender)
104 { 102 {
@@ -109,9 +107,7 @@ void LLViewerImageList::init()
109 mUpdateStats = TRUE; 107 mUpdateStats = TRUE;
110 108
111 // Update how much texture RAM we're allowed to use. 109 // Update how much texture RAM we're allowed to use.
112 updateMaxResidentTexMem(); 110 updateMaxResidentTexMem(0); // 0 = use current
113
114 mMovieImageHasMips = FALSE;
115 111
116 doPreloadImages(); 112 doPreloadImages();
117} 113}
@@ -166,14 +162,14 @@ void LLViewerImageList::doPreloadImages()
166 preloadUIImage("spin_up_out_blue.tga", LLUUID::null, FALSE); 162 preloadUIImage("spin_up_out_blue.tga", LLUUID::null, FALSE);
167 preloadUIImage("square_btn_32x128.tga", LLUUID::null, FALSE, LLRectf(.125f, 0.5f, .875f, 0.5f )); 163 preloadUIImage("square_btn_32x128.tga", LLUUID::null, FALSE, LLRectf(.125f, 0.5f, .875f, 0.5f ));
168 preloadUIImage("square_btn_selected_32x128.tga", LLUUID::null, FALSE, LLRectf(.125f, 0.5f, .875f, 0.5f )); 164 preloadUIImage("square_btn_selected_32x128.tga", LLUUID::null, FALSE, LLRectf(.125f, 0.5f, .875f, 0.5f ));
169 preloadUIImage("startup_logo.tga", LLUUID::null, FALSE); // <<<<<<< --- needed? 165 preloadUIImage("startup_logo.tga", LLUUID::null, FALSE); // -- needed?
170 preloadUIImage("tab_bottom_blue.tga", LLUUID::null, FALSE, LLRectf(0.109375f, 1.f - 0.4375f, 1.f - 0.109375f, 0.4375f)); 166 preloadUIImage("tab_bottom_blue.tga", LLUUID::null, FALSE, LLRectf(0.109375f, 1.f - 0.4375f, 1.f - 0.109375f, 0.4375f));
171 preloadUIImage("tab_bottom_selected_blue.tga", LLUUID::null, FALSE, LLRectf(0.109375f, 1.f - 0.4375f, 1.f - 0.109375f, 0.4375f)); 167 preloadUIImage("tab_bottom_selected_blue.tga", LLUUID::null, FALSE, LLRectf(0.109375f, 1.f - 0.4375f, 1.f - 0.109375f, 0.4375f));
172 preloadUIImage("tab_left.tga", LLUUID::null, FALSE, LLRectf(.125f, 0.5f, .875f, 0.5f )); 168 preloadUIImage("tab_left.tga", LLUUID::null, FALSE, LLRectf(.125f, 0.5f, .875f, 0.5f ));
173 preloadUIImage("tab_left_selected.tga", LLUUID::null, FALSE, LLRectf(.125f, 0.5f, .875f, 0.5f )); 169 preloadUIImage("tab_left_selected.tga", LLUUID::null, FALSE, LLRectf(.125f, 0.5f, .875f, 0.5f ));
174 preloadUIImage("tab_top_blue.tga", LLUUID::null, FALSE, LLRectf(0.109375f, 1.f - 0.4375f, 1.f - 0.109375f, 0.4375f)); 170 preloadUIImage("tab_top_blue.tga", LLUUID::null, FALSE, LLRectf(0.109375f, 1.f - 0.4375f, 1.f - 0.109375f, 0.4375f));
175 preloadUIImage("tab_top_selected_blue.tga", LLUUID::null, FALSE, LLRectf(0.109375f, 1.f - 0.4375f, 1.f - 0.109375f, 0.4375f)); 171 preloadUIImage("tab_top_selected_blue.tga", LLUUID::null, FALSE, LLRectf(0.109375f, 1.f - 0.4375f, 1.f - 0.109375f, 0.4375f));
176 172
177 decodeAllImages(2.f); // decode preloaded images 173 decodeAllImages(2.f); // decode preloaded images
178 174
179 // These images are queued for decode during the login sequence, when 175 // These images are queued for decode during the login sequence, when
@@ -190,6 +186,7 @@ void LLViewerImageList::doPreloadImages()
190 preloadUIImage("eyes.tga", LLUUID::null, TRUE); 186 preloadUIImage("eyes.tga", LLUUID::null, TRUE);
191 preloadUIImage("foot_shadow.tga", LLUUID::null, TRUE); 187 preloadUIImage("foot_shadow.tga", LLUUID::null, TRUE);
192 preloadUIImage("hair.tga", LLUUID::null, TRUE); 188 preloadUIImage("hair.tga", LLUUID::null, TRUE);
189 preloadUIImage("icon_diurnal.tga", LLUUID::null, TRUE);
193 preloadUIImage("icon_for_sale.tga", LLUUID::null, FALSE); 190 preloadUIImage("icon_for_sale.tga", LLUUID::null, FALSE);
194 preloadUIImage("icon_popular.tga", LLUUID::null, FALSE); 191 preloadUIImage("icon_popular.tga", LLUUID::null, FALSE);
195 preloadUIImage("icon_top_pick.tga", LLUUID::null, FALSE); 192 preloadUIImage("icon_top_pick.tga", LLUUID::null, FALSE);
@@ -334,10 +331,7 @@ void LLViewerImageList::doPreloadImages()
334 preloadUIImage("icn_voice-localchat.tga", LLUUID::null, FALSE); 331 preloadUIImage("icn_voice-localchat.tga", LLUUID::null, FALSE);
335 preloadUIImage("icn_voice-groupfocus.tga", LLUUID::null, FALSE); 332 preloadUIImage("icn_voice-groupfocus.tga", LLUUID::null, FALSE);
336 preloadUIImage("icn_voice-pvtfocus.tga", LLUUID::null, FALSE); 333 preloadUIImage("icn_voice-pvtfocus.tga", LLUUID::null, FALSE);
337 preloadUIImage("icn_media-pause.tga", LLUUID::null, FALSE); 334 // TODO: Add images for media remote
338 preloadUIImage("icn_media-play.tga", LLUUID::null, FALSE);
339 preloadUIImage("icn_music-play.tga", LLUUID::null, FALSE);
340 preloadUIImage("icn_music-pause.tga", LLUUID::null, FALSE);
341 preloadUIImage("icn_chatbar.tga", LLUUID::null, FALSE); 335 preloadUIImage("icn_chatbar.tga", LLUUID::null, FALSE);
342 preloadUIImage("btn_chatbar.tga", LLUUID::null, FALSE, LLRectf(0.5f, 0.5f, 0.5f, 0.5f)); 336 preloadUIImage("btn_chatbar.tga", LLUUID::null, FALSE, LLRectf(0.5f, 0.5f, 0.5f, 0.5f));
343 preloadUIImage("btn_chatbar_selected.tga", LLUUID::null, FALSE, LLRectf(0.5f, 0.5f, 0.5f, 0.5f)); 337 preloadUIImage("btn_chatbar_selected.tga", LLUUID::null, FALSE, LLRectf(0.5f, 0.5f, 0.5f, 0.5f));
@@ -714,38 +708,6 @@ void LLViewerImageList::deleteImage(LLViewerImage *image)
714 708
715/////////////////////////////////////////////////////////////////////////////// 709///////////////////////////////////////////////////////////////////////////////
716 710
717void LLViewerImageList::updateMovieImage(const LLUUID& uuid, BOOL active)
718{
719 // IF the media image hasn't changed, do nothing
720 if (mMovieImageUUID == uuid)
721 {
722 return;
723 }
724 // If we have changed media uuid, restore the old one
725 if (!mMovieImageUUID.isNull())
726 {
727 LLViewerImage* oldImage = getImage( mMovieImageUUID );
728 if (oldImage)
729 {
730 oldImage->reinit(mMovieImageHasMips);
731 oldImage->mIsMediaTexture = FALSE;
732 }
733 mMovieImageUUID.setNull();
734 }
735 // If the movie is playing, set the new media image
736 if (active && !uuid.isNull())
737 {
738 LLViewerImage* viewerImage = getImage( uuid );
739 if( viewerImage )
740 {
741 mMovieImageUUID = uuid;
742 // Can't use mipmaps for movies because they don't update the full image
743 mMovieImageHasMips = viewerImage->getUseMipMaps();
744 viewerImage->reinit(FALSE);
745 viewerImage->mIsMediaTexture = TRUE;
746 }
747 }
748}
749 711
750//////////////////////////////////////////////////////////////////////////// 712////////////////////////////////////////////////////////////////////////////
751 713
@@ -767,9 +729,9 @@ void LLViewerImageList::updateImages(F32 max_time)
767 729
768 updateImagesDecodePriorities(); 730 updateImagesDecodePriorities();
769 max_time -= updateImagesFetchTextures(max_time); 731 max_time -= updateImagesFetchTextures(max_time);
770 max_time = llmax(max_time, 0.001f); 732 max_time = llmin(llmax(max_time, 0.001f*10.f*gFrameIntervalSeconds), 0.001f);
771 max_time -= updateImagesCreateTextures(max_time); 733 max_time -= updateImagesCreateTextures(max_time);
772 max_time = llmax(max_time, 0.001f); 734 max_time = llmin(llmax(max_time, 0.001f*10.f*gFrameIntervalSeconds), 0.001f);
773 735
774 if (!mDirtyTextureList.empty()) 736 if (!mDirtyTextureList.empty())
775 { 737 {
@@ -779,7 +741,7 @@ void LLViewerImageList::updateImages(F32 max_time)
779 } 741 }
780 742
781 for (image_list_t::iterator iter = mCallbackList.begin(); 743 for (image_list_t::iterator iter = mCallbackList.begin();
782 iter != mCallbackList.end(); ) 744 iter != mCallbackList.end(); )
783 { 745 {
784 LLViewerImage* image = *iter++; 746 LLViewerImage* image = *iter++;
785 // Do stuff to handle callbacks, update priorities, etc. 747 // Do stuff to handle callbacks, update priorities, etc.
@@ -789,8 +751,13 @@ void LLViewerImageList::updateImages(F32 max_time)
789 break; // only actually do one callback per frame 751 break; // only actually do one callback per frame
790 } 752 }
791 } 753 }
754
792 755
793 updateImagesMediaStreams(); 756 if (!gNoRender && !gGLManager.mIsDisabled)
757 {
758 LLViewerMedia::updateImagesMediaStreams();
759 }
760
794 updateImagesUpdateStats(); 761 updateImagesUpdateStats();
795} 762}
796 763
@@ -798,7 +765,7 @@ void LLViewerImageList::updateImagesDecodePriorities()
798{ 765{
799 // Update the decode priority for N images each frame 766 // Update the decode priority for N images each frame
800 { 767 {
801 const size_t max_update_count = 256; 768 const size_t max_update_count = llmin((S32) (1024*gFrameIntervalSeconds) + 1, 32); //target 1024 textures per second
802 S32 update_counter = llmin(max_update_count, mUUIDMap.size()/10); 769 S32 update_counter = llmin(max_update_count, mUUIDMap.size()/10);
803 uuid_map_t::iterator iter = mUUIDMap.upper_bound(mLastUpdateUUID); 770 uuid_map_t::iterator iter = mUUIDMap.upper_bound(mLastUpdateUUID);
804 while(update_counter > 0) 771 while(update_counter > 0)
@@ -912,8 +879,8 @@ F32 LLViewerImageList::updateImagesFetchTextures(F32 max_time)
912 879
913 // Update the decode priority for N images each frame 880 // Update the decode priority for N images each frame
914 // Make a list with 32 high priority entries + 256 cycled entries 881 // Make a list with 32 high priority entries + 256 cycled entries
915 const size_t max_priority_count = 32; 882 const size_t max_priority_count = llmin((S32) (256*10.f*gFrameIntervalSeconds)+1, 32);
916 const size_t max_update_count = 256; 883 const size_t max_update_count = llmin((S32) (1024*10.f*gFrameIntervalSeconds)+1, 256);
917 884
918 // 32 high priority entries 885 // 32 high priority entries
919 std::set<LLViewerImage*> entries; 886 std::set<LLViewerImage*> entries;
@@ -957,74 +924,6 @@ F32 LLViewerImageList::updateImagesFetchTextures(F32 max_time)
957 return image_op_timer.getElapsedTimeF32(); 924 return image_op_timer.getElapsedTimeF32();
958} 925}
959 926
960void LLViewerImageList::updateImagesMediaStreams()
961{
962 if (gNoRender || gGLManager.mIsDisabled) return;
963
964 // update media stream if required
965 LLMediaEngine* media_engine = LLMediaEngine::getInstance();
966 if (media_engine)
967 {
968 if ( media_engine->update() )
969 {
970 LLUUID media_uuid = media_engine->getImageUUID();
971 updateMovieImage(media_uuid, TRUE);
972 if (!media_uuid.isNull())
973 {
974 LLViewerImage* viewerImage = getImage( media_uuid );
975 if( viewerImage )
976 {
977 LLMediaBase* renderer = media_engine->getMediaRenderer();
978 if ((renderer->getTextureWidth() != viewerImage->getWidth()) ||
979 (renderer->getTextureHeight() != viewerImage->getHeight()) ||
980 (renderer->getTextureDepth() != viewerImage->getComponents()) ||
981 (viewerImage->getHasGLTexture() == FALSE))
982 {
983 // destroy existing GL image
984 viewerImage->destroyGLTexture();
985
986 // set new size
987 viewerImage->setSize( renderer->getTextureWidth(),
988 renderer->getTextureHeight(),
989 renderer->getTextureDepth() );
990
991 LLPointer<LLImageRaw> raw = new LLImageRaw(renderer->getTextureWidth(),
992 renderer->getTextureHeight(),
993 renderer->getTextureDepth());
994 raw->clear(0x7f,0x7f,0x7f,0xff);
995 viewerImage->createGLTexture(0, raw);
996 }
997
998 // Set the explicit format the instance wants
999 viewerImage->setExplicitFormat(renderer->getTextureFormatInternal(),
1000 renderer->getTextureFormatPrimary(),
1001 renderer->getTextureFormatType(),
1002 renderer->getTextureFormatSwapBytes());
1003 // This should be redundant, but just in case:
1004 viewerImage->setUseMipMaps(FALSE);
1005
1006 LLImageRaw* rawImage = media_engine->getImageRaw();
1007 if ( rawImage )
1008 {
1009 viewerImage->setSubImage(rawImage, 0, 0,
1010 renderer->getMediaWidth(),
1011 renderer->getMediaHeight());
1012 }
1013 }
1014 else
1015 {
1016 llwarns << "MediaEngine update unable to get viewer image for GL texture" << llendl;
1017 }
1018 }
1019 }
1020 else
1021 {
1022 LLUUID media_uuid = media_engine->getImageUUID();
1023 updateMovieImage(media_uuid, FALSE);
1024 }
1025 }
1026}
1027
1028void LLViewerImageList::updateImagesUpdateStats() 927void LLViewerImageList::updateImagesUpdateStats()
1029{ 928{
1030 if (mUpdateStats) 929 if (mUpdateStats)
@@ -1094,7 +993,7 @@ void LLViewerImageList::decodeAllImages(F32 max_time)
1094 imagep->updateFetch(); 993 imagep->updateFetch();
1095 } 994 }
1096 max_time -= timer.getElapsedTimeF32(); 995 max_time -= timer.getElapsedTimeF32();
1097 max_time = llmax(max_time, .01f); 996 max_time = llmax(max_time, .001f);
1098 F32 create_time = updateImagesCreateTextures(max_time); 997 F32 create_time = updateImagesCreateTextures(max_time);
1099 998
1100 llinfos << "decodeAllImages() took " << timer.getElapsedTimeF32() << " seconds. " 999 llinfos << "decodeAllImages() took " << timer.getElapsedTimeF32() << " seconds. "
@@ -1220,97 +1119,80 @@ LLPointer<LLImageJ2C> LLViewerImageList::convertToUploadFile(LLPointer<LLImageRa
1220 return compressedImage; 1119 return compressedImage;
1221} 1120}
1222 1121
1122const S32 MIN_VIDEO_RAM = 32;
1123const S32 MAX_VIDEO_RAM = 2048;
1124
1125// Returns min setting for TextureMemory (in MB)
1126S32 LLViewerImageList::getMinVideoRamSetting()
1127{
1128 return MIN_VIDEO_RAM;
1129}
1130
1223//static 1131//static
1224S32 LLViewerImageList::getMaxVideoRamSetting(S32 max) 1132// Returns max setting for TextureMemory (in MB)
1133S32 LLViewerImageList::getMaxVideoRamSetting(bool get_recommended)
1225{ 1134{
1226 const U32 vram_settings[] = { 16, 32, 64, 128, 256, 512 }; 1135 S32 max_texmem;
1227 const S32 num_vram_settings = sizeof(vram_settings) / sizeof(vram_settings[0]);
1228
1229 U32 max_vram;
1230 if (gGLManager.mVRAM != 0) 1136 if (gGLManager.mVRAM != 0)
1231 { 1137 {
1232 max_vram = (llmax(gGLManager.mVRAM,16)) << 20; 1138 // Treat any card with < 32 MB (shudder) as having 32 MB
1139 // - it's going to be swapping constantly regardless
1140 S32 max_vram = gGLManager.mVRAM;
1141 max_vram = llmax(max_vram, getMinVideoRamSetting());
1142 max_texmem = max_vram;
1143 if (!get_recommended)
1144 max_texmem *= 2;
1233 } 1145 }
1234 else 1146 else
1235 { 1147 {
1236 if (max == -2) // max recommended setting 1148 if (get_recommended)
1237 { 1149 max_texmem = 128;
1238 max_vram = 128 << 20;
1239 }
1240 else 1150 else
1241 { 1151 max_texmem = 512;
1242 max_vram = 512 << 20; 1152 llwarns << "VRAM amount not detected, defaulting to " << max_texmem << " MB" << llendl;
1243 }
1244 llwarns << "VRAM amount not detected, defaulting to " << max_vram/(double)(1<<20) << " MB" << llendl;
1245 }
1246 U32 system_ram = gSysMemory.getPhysicalMemoryClamped();
1247 //llinfos << "*** DETECTED " << system_ram/(double)(1<<20) << " MB of system memory." << llendl; // TomY TESTING DNCI
1248 if (max == -2)
1249 {
1250 max_vram = llmin(max_vram, (U32)(system_ram/2)); // max recommended setting
1251 } 1153 }
1154
1155 S32 system_ram = (S32)(gSysMemory.getPhysicalMemoryClamped() >> 20); // In MB
1156 //llinfos << "*** DETECTED " << system_ram << " MB of system memory." << llendl;
1157 if (get_recommended)
1158 max_texmem = llmin(max_texmem, (S32)(system_ram/2));
1252 else 1159 else
1253 { 1160 max_texmem = llmin(max_texmem, (S32)(system_ram));
1254 max_vram = llmin(max_vram, (U32)((F32)system_ram/1.5f));
1255 }
1256
1257 S32 idx;
1258 for (idx=0; idx < num_vram_settings; idx++)
1259 {
1260 if (idx == max)
1261 break;
1262 if ((vram_settings[idx] << 20) > max_vram)
1263 {
1264 idx--;
1265 break;
1266 }
1267 }
1268 1161
1269 if( idx == num_vram_settings ) 1162 max_texmem = llclamp(max_texmem, MIN_VIDEO_RAM, MAX_VIDEO_RAM);
1270 {
1271 idx = num_vram_settings - 1;
1272 }
1273 1163
1274 return idx; 1164 return max_texmem;
1275} 1165}
1276 1166
1277const S32 VIDEO_CARD_MEM_SIZES[6] = { 0x1000000, // 16MB 1167const S32 VIDEO_CARD_FRAMEBUFFER_MEM = 12; // MB
1278 0x2000000, // 32MB
1279 0x4000000, // 64MB
1280 0x8000000, // 128MB
1281 0x10000000, // 256MB
1282 0x20000000, // 512MB
1283};
1284
1285const S32 VIDEO_CARD_FRAMEBUFFER_MEM = 0xC00000; // 12MB
1286 1168
1287void LLViewerImageList::updateMaxResidentTexMem(S32 max, U32 fudge) 1169void LLViewerImageList::updateMaxResidentTexMem(S32 mem)
1288{ 1170{
1289 // Initialize the image pipeline VRAM settings 1171 // Initialize the image pipeline VRAM settings
1290 S32 cur_setting = gSavedSettings.getS32("GraphicsCardMemorySetting"); 1172 S32 cur_mem = gSavedSettings.getS32("TextureMemory");
1291 S32 max_setting = getMaxVideoRamSetting(max); 1173 S32 default_mem = getMaxVideoRamSetting(true); // recommended default
1292 if (max >= 0 && max != cur_setting) 1174 if (mem == 0)
1293 { 1175 {
1294 S32 default_setting = getMaxVideoRamSetting(-2); // recommended default 1176 mem = cur_mem > 0 ? cur_mem : default_mem;
1295 if (cur_setting >= 0 || max_setting != default_setting)
1296 {
1297 gSavedSettings.setS32("GraphicsCardMemorySetting", max_setting);
1298 return; //listener will reenter this function
1299 }
1300 cur_setting = max_setting; // max_setting <= max
1301 } 1177 }
1302 else if (cur_setting < 0) 1178 else if (mem < 0)
1303 { 1179 {
1304 S32 default_setting = getMaxVideoRamSetting(-2); // recommended default 1180 mem = default_mem;
1305 cur_setting = default_setting;
1306 } 1181 }
1307 mVideoMemorySetting = cur_setting; 1182
1183 mem = llclamp(mem, getMinVideoRamSetting(), getMaxVideoRamSetting());
1184 if (mem != cur_mem)
1185 {
1186 gSavedSettings.setS32("TextureMemory", mem);
1187 return; //listener will re-enter this function
1188 }
1189
1308 // TODO: set available resident texture mem based on use by other subsystems 1190 // TODO: set available resident texture mem based on use by other subsystems
1309 // currently max(12MB, VRAM/4) assumed... 1191 // currently max(12MB, VRAM/4) assumed...
1310 1192
1311 S32 vram_amt = VIDEO_CARD_MEM_SIZES[cur_setting]; 1193 S32 vb_mem = mem;
1312 S32 fb_mem = llmax(VIDEO_CARD_FRAMEBUFFER_MEM, vram_amt/4); 1194 S32 fb_mem = llmax(VIDEO_CARD_FRAMEBUFFER_MEM, vb_mem/4);
1313 mMaxResidentTexMem = vram_amt - fb_mem - fudge; 1195 mMaxResidentTexMem = (vb_mem - fb_mem)<<20;
1314 1196
1315 // llinfos << "Graphics Card memory set to " << (VIDEO_CARD_MEM_SIZES[cur_setting]>>20) 1197 // llinfos << "Graphics Card memory set to " << (VIDEO_CARD_MEM_SIZES[cur_setting]>>20)
1316 // << " MB" << llendl; 1198 // << " MB" << llendl;