[sldev] Issues with TextureBuffer size

Nicholaz Beresford nicholaz at blueflash.cc
Sat May 19 06:45:51 PDT 2007


I have identified two issues with the texture buffer size being too 
large on some systems and too little on other.

Please review, comment and/or vote for
https://jira.secondlife.com/browse/VWR-733
and
https://jira.secondlife.com/browse/VWR-778

I'm attaching a patch for 1.15.1.3 which addresses both


There's also an issue with sMaxTotalTexture being of type S32
which will cause problems with systems with >2GB memory
(this is not yet fully addressed in this patch)




-------------- next part --------------

XP [W:\sl1.15.1.3]c:\cygwin\bin\udiff -u linden-orig\indra\newview\llviewerimage.cpp linden\indra\newview\llviewerimage.cpp 
--- linden-orig\indra\newview\llviewerimage.cpp	2007-05-14 16:47:26.000000000 +0200
+++ linden\indra\newview\llviewerimage.cpp	2007-05-19 15:13:58.734375000 +0200
@@ -121,7 +121,6 @@
  	sDefaultImagep = gImageList.getImage(IMG_DEFAULT, TRUE, TRUE);
 #endif
  	sSmokeImagep = gImageList.getImage(IMG_SMOKE, TRUE, TRUE);
-
 }
 
 // static
@@ -138,7 +137,6 @@
 // tuning params
 const F32 discard_bias_delta = .05f;
 const F32 discard_delta_time = 0.5f;
-const S32 min_non_tex_system_mem = (128<<20); // 128 MB
 // non-const (used externally
 F32 texmem_lower_bound_scale = 0.85f;
 F32 texmem_middle_bound_scale = 0.925f;
@@ -149,18 +147,67 @@
 	sBoundTextureMemory = LLImageGL::sBoundTextureMemory;
 	sTotalTextureMemory = LLImageGL::sGlobalTextureMemory;
 	sMaxBoundTextureMem = gImageList.getMaxResidentTexMem();
-	
+
+
+	// PATCH [Nicholas Beresford]
+	//
+
+	// this is the size calculation a la LindenLab version 1.14/1.15
 	sMaxTotalTextureMem = sMaxBoundTextureMem * 2;
-	if (sMaxBoundTextureMem > 64000000)
+	if (sMaxBoundTextureMem > 64000000) // 64mB
 	{
 		sMaxTotalTextureMem -= sMaxBoundTextureMem/4;
 	}
+
+
+	// limit texture cache to leave enough memory for program and operating system and 
+	// avoid excess virtual memory swapping (issue VWR-733)
+
+	const S32 megabytes= (1<<20);
+	S32 min_non_tex_system_mem = 128*megabytes;	// absolute minimum 128MB, leave this much memory for operating system and SL-viewer
+	S64 system_memory= gSysMemory.getPhysicalMemory();
+	#define SYSMEM_EQUAL_OR_HIGHER(x) (system_memory >= (U64)((F32)(x)*0.9f))
+
+
+	// system memory reports slightly less than the ideal numbers, so use a factor of 0.9 to approx the value
+	// (this is safe because board memory is usually upgraded in larger increments and even in case of an 
+	// error, just more memory will be left to the system rather than being used for texturing)
 	
-	if (sMaxTotalTextureMem > (S32)gSysMemory.getPhysicalMemory() - min_non_tex_system_mem)
+	if (SYSMEM_EQUAL_OR_HIGHER(768*megabytes)) 	// systems with 768GB and more 
+	{
+		min_non_tex_system_mem= 512*megabytes;	// caps tex-mem to 256 on 768MB and 512 on 1GB machines
+	}
+	else
+	if (SYSMEM_EQUAL_OR_HIGHER(512*megabytes)) 	// systems with 512MB up to 768GB 
+	{
+		min_non_tex_system_mem= 384*megabytes;	// caps tex-mem to 128MB on 512MB machines
+	}
+	else 	// systems with less than 512MB (256MB, 384MB, etc.)
+	{
+		min_non_tex_system_mem= 192*megabytes;	// absolute minimum (caps tex-mem to 64MB on 256MB machines)
+	}
+
+
+	// 
+	//	cap sMaxTotalTextureMem with system memory but allow at least 48MB (first cap upper, then cap lower)
+	// 
+	if (sMaxTotalTextureMem > (S32)(system_memory - min_non_tex_system_mem))	// PATCH: chged sysmem from (S32) to (S64)
 	{
-		sMaxTotalTextureMem = (S32)gSysMemory.getPhysicalMemory() - min_non_tex_system_mem;
+		sMaxTotalTextureMem = (S32)(system_memory - min_non_tex_system_mem);	// PATCH: chged sysmem from (S32) to (S64)
 	}
 	
+	if (sMaxTotalTextureMem < 64*megabytes) // give them at least 64MB (bit more buffering for 16MB ram cards)
+	{										// (results in vastly improved visual performance on low end cards)
+		sMaxTotalTextureMem = 64*megabytes;	
+	}
+	
+	// TODO:  sMaxTotalTexture memory sooner or later needs to be upgraded to S64 because
+	//        it will fail eventually if video boards have near 2GB memory
+
+	//
+	// ~PATCH
+	
+	
 	if (sBoundTextureMemory >= sMaxBoundTextureMem ||
 		sTotalTextureMemory >= sMaxTotalTextureMem)
 	{


More information about the SLDev mailing list