[sldev] Issues with TextureBuffer size
Nicholaz Beresford
nicholaz at blueflash.cc
Sat May 19 15:05:25 PDT 2007
Here is another patch for llviewerimage.cpp which addresses
https://jira.secondlife.com/browse/VWR-733
https://jira.secondlife.com/browse/VWR-778
https://jira.secondlife.com/browse/VWR-207
VWR-733 was tested by a couple of people with 512MB machines with good
results
VWR-778 was tested by a friend on a unique 16MB vid ram machine with
excellent results
VWR207 I did test the large memory size in the debugger with a 3GB
memory and
3GB video size and it seemed to work.
Patch now also has linux filenames (based on 1.15.1.3)
-------------- next part --------------
--- linden-orig/indra/newview/llviewerimage.cpp 2007-05-14 16:47:26.000000000 +0200
+++ linden/indra/newview/llviewerimage.cpp 2007-05-19 23:54:06.578125000 +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,17 +147,77 @@
sBoundTextureMemory = LLImageGL::sBoundTextureMemory;
sTotalTextureMemory = LLImageGL::sGlobalTextureMemory;
sMaxBoundTextureMem = gImageList.getMaxResidentTexMem();
+
+
+ // PATCH [Nicholas Beresford]
+ //
+
- sMaxTotalTextureMem = sMaxBoundTextureMem * 2;
- if (sMaxBoundTextureMem > 64000000)
+ // this is the size calculation a la LindenLab version 1.14/1.15
+ // (used against a temporary S64 maxtotal variable to adjust to large
+ // system memory sizes ... VWR-207)
+ S64 maxtotaltexturemem = sMaxBoundTextureMem * 2;
+ if (sMaxBoundTextureMem > 64000000) // 64mB
{
- sMaxTotalTextureMem -= sMaxBoundTextureMem/4;
+ maxtotaltexturemem -= sMaxBoundTextureMem/4;
}
-
- if (sMaxTotalTextureMem > (S32)gSysMemory.getPhysicalMemory() - min_non_tex_system_mem)
+
+
+ //
+ // limit texture cache to leave enough memory for program and operating system and
+ // avoid excess virtual memory swapping
+ // 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(); // system_memory as S64 (was cast to S32 previously - VWR-207)
+
+ system_memory= 3*1024*(S64)megabytes;
+
+ // 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)
+ #define SYSMEM_EQUAL_OR_HIGHER(x) (system_memory >= (U64)((F32)(x)*0.9f))
+
+ // calculate memory reserve depending on system memory
+ if (SYSMEM_EQUAL_OR_HIGHER(768*megabytes)) // systems with 768GB and more
{
- sMaxTotalTextureMem = (S32)gSysMemory.getPhysicalMemory() - min_non_tex_system_mem;
+ 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 maxtotaltexturemem with system memory
+ if (maxtotaltexturemem > (system_memory - min_non_tex_system_mem)) // PATCH: chged sysmem from (S32) to (S64)
+ {
+ maxtotaltexturemem = (system_memory - min_non_tex_system_mem); // PATCH: chged sysmem from (S32) to (S64)
+ }
+
+ // allow for at least 64MB (more buffering for 16MB ram cards than in previous implementation)
+ // which results in vastly improved visual performance on low end cards
+ // VWR-778
+ if (maxtotaltexturemem < 64*megabytes)
+ {
+ maxtotaltexturemem = 64*megabytes;
+ }
+
+
+ // make sure maxtotalmem fits in S32 (avoiding upgrading member sMaxTotalTexture
+ // to type S64 as texture buffer sizes of 2GB seem to be unlikely at the moment anyway)
+ // VWR-207
+ sMaxTotalTextureMem= (S32)llmin(maxtotaltexturemem, (S64)S32_MAX);
+
+ //
+ // ~PATCH
+
if (sBoundTextureMemory >= sMaxBoundTextureMem ||
sTotalTextureMemory >= sMaxTotalTextureMem)
More information about the SLDev
mailing list