Tweak memory detection algorithm.
This commit is contained in:
@@ -100,10 +100,73 @@ void APIENTRY gl_debug_callback(GLenum source,
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_WARNS() << "----- GL WARNING -------" << LL_ENDL;
|
||||
if (severity == GL_DEBUG_SEVERITY_MEDIUM_ARB)
|
||||
{
|
||||
LL_WARNS() << "----- GL WARNING MEDIUM --------" << LL_ENDL;
|
||||
}
|
||||
else if (severity == GL_DEBUG_SEVERITY_LOW_ARB)
|
||||
{
|
||||
LL_WARNS() << "----- GL WARNING LOW --------" << LL_ENDL;
|
||||
}
|
||||
else if (severity == 0x826b && id == 0x20071 && type == GL_DEBUG_TYPE_OTHER_ARB && source == GL_DEBUG_SOURCE_API_ARB)
|
||||
{
|
||||
// Silence nvidia buffer detail info.
|
||||
return;
|
||||
}
|
||||
}
|
||||
LL_WARNS() << "Source: " << std::hex << source << std::dec << LL_ENDL;
|
||||
LL_WARNS() << "Type: " << std::hex << type << std::dec << LL_ENDL;
|
||||
|
||||
std::string sourcestr = "Unknown";
|
||||
switch (source)
|
||||
{
|
||||
case GL_DEBUG_SOURCE_API_ARB:
|
||||
sourcestr = "OpenGL";
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB:
|
||||
sourcestr = "Window manager";
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB:
|
||||
sourcestr = "Shader compiler";
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_THIRD_PARTY_ARB:
|
||||
sourcestr = "3rd party";
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_APPLICATION_ARB:
|
||||
sourcestr = "Application";
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_OTHER_ARB:
|
||||
sourcestr = "Other";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
std::string typestr = "Unknown";
|
||||
switch (type)
|
||||
{
|
||||
case GL_DEBUG_TYPE_ERROR_ARB:
|
||||
typestr = "Error";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB:
|
||||
typestr = "Deprecated behavior";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB:
|
||||
typestr = "Undefined behavior";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_PORTABILITY_ARB:
|
||||
typestr = "Portability";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_PERFORMANCE_ARB:
|
||||
typestr = "Performance";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_OTHER_ARB:
|
||||
typestr = "Other";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
LL_WARNS() << "Source: " << sourcestr << " (" << std::hex << source << std::dec << ")" << LL_ENDL;
|
||||
LL_WARNS() << "Type: " << typestr << " (" << std::hex << type << std::dec << ")" << LL_ENDL;
|
||||
LL_WARNS() << "ID: " << std::hex << id << std::dec<< LL_ENDL;
|
||||
LL_WARNS() << "Severity: " << std::hex << severity << std::dec << LL_ENDL;
|
||||
LL_WARNS() << "Message: " << message << LL_ENDL;
|
||||
|
||||
@@ -443,7 +443,7 @@ LLDXDevice *LLDXHardware::findDevice(const std::string &vendor, const std::strin
|
||||
}
|
||||
*/
|
||||
|
||||
BOOL LLDXHardware::getInfo(BOOL vram_only)
|
||||
BOOL LLDXHardware::getInfo(BOOL vram_only, S32Megabytes system_ram)
|
||||
{
|
||||
LLTimer hw_timer;
|
||||
BOOL ok = FALSE;
|
||||
@@ -543,6 +543,11 @@ BOOL LLDXHardware::getInfo(BOOL vram_only)
|
||||
// Dump the string as an int into the structure
|
||||
char *stopstring;
|
||||
mVRAM = strtol(ram_str.c_str(), &stopstring, 10);
|
||||
mVRAM -= ((S32)system_ram/2) + 1; // Ignore shared memory pool.
|
||||
if (mVRAM <= 0)
|
||||
{
|
||||
mVRAM = (S32)system_ram / 2; // Integrated graphics perhaps? Use half system ram.
|
||||
}
|
||||
LL_INFOS("AppInit") << "VRAM Detected: " << mVRAM << " DX9 string: " << ram_str << LL_ENDL;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
|
||||
// Returns TRUE on success.
|
||||
// vram_only TRUE does a "light" probe.
|
||||
BOOL getInfo(BOOL vram_only);
|
||||
BOOL getInfo(BOOL vram_only, S32Megabytes sytem_ram);
|
||||
|
||||
S32 getVRAM() const { return mVRAM; }
|
||||
|
||||
|
||||
@@ -527,7 +527,10 @@ bool LLAppViewerWin32::initHardwareTest()
|
||||
|
||||
LL_DEBUGS("AppInit") << "Attempting to poll DirectX for hardware info" << LL_ENDL;
|
||||
gDXHardware.setWriteDebugFunc(write_debug_dx);
|
||||
BOOL probe_ok = gDXHardware.getInfo(vram_only);
|
||||
|
||||
S32Megabytes system_ram = gSysMemory.getPhysicalMemoryKB();
|
||||
|
||||
BOOL probe_ok = gDXHardware.getInfo(vram_only, system_ram);
|
||||
|
||||
if (!probe_ok
|
||||
&& gSavedSettings.getWarning("AboutDirectX9"))
|
||||
@@ -572,6 +575,7 @@ bool LLAppViewerWin32::initHardwareTest()
|
||||
if (gGLManager.mVRAM == 0)
|
||||
{
|
||||
gGLManager.mVRAM = gDXHardware.getVRAM();
|
||||
LL_WARNS("AppInit") << "gGLManager.mVRAM: " << gGLManager.mVRAM << LL_ENDL;
|
||||
}
|
||||
|
||||
LL_INFOS("AppInit") << "Detected VRAM: " << gGLManager.mVRAM << LL_ENDL;
|
||||
|
||||
@@ -525,15 +525,15 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
|
||||
|
||||
sBoundTextureMemory = LLImageGL::sBoundTextureMemory;
|
||||
sTotalTextureMemory = LLImageGL::sGlobalTextureMemory;
|
||||
sMaxBoundTextureMemory = S32Megabytes(gTextureList.getMaxResidentTexMem());
|
||||
sMaxTotalTextureMem = S32Megabytes(gTextureList.getMaxTotalTextureMem());
|
||||
sMaxBoundTextureMemory = gTextureList.getMaxResidentTexMem();
|
||||
sMaxTotalTextureMem = gTextureList.getMaxTotalTextureMem();
|
||||
sMaxDesiredTextureMem = sMaxTotalTextureMem; //in Bytes, by default and when total used texture memory is small.
|
||||
|
||||
if (sBoundTextureMemory >= sMaxBoundTextureMemory ||
|
||||
sTotalTextureMemory >= sMaxTotalTextureMem)
|
||||
{
|
||||
//when texture memory overflows, lower down the threshold to release the textures more aggressively.
|
||||
sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, F32Bytes(gMaxVideoRam));
|
||||
sMaxDesiredTextureMem = llmin(F64Bytes(sMaxDesiredTextureMem) * 0.75f, F64Bytes(gMaxVideoRam));
|
||||
|
||||
// If we are using more texture memory than we should,
|
||||
// scale up the desired discard level
|
||||
|
||||
@@ -1285,6 +1285,7 @@ LLPointer<LLImageJ2C> LLViewerTextureList::convertToUploadFile(LLPointer<LLImage
|
||||
S32Megabytes LLViewerTextureList::getMinVideoRamSetting()
|
||||
{
|
||||
S32Megabytes system_ram = gSysMemory.getPhysicalMemoryKB();
|
||||
LL_INFOS() << system_ram << LL_ENDL;
|
||||
//min texture mem sets to 64M if total physical mem is more than 1.5GB
|
||||
return (system_ram > S32Megabytes(1500)) ? S32Megabytes(64) : gMinVideoRam ;
|
||||
}
|
||||
@@ -1329,6 +1330,9 @@ S32Megabytes LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended, fl
|
||||
}
|
||||
|
||||
S32Megabytes system_ram = gSysMemory.getPhysicalMemoryKB(); // In MB
|
||||
LL_INFOS() << "get_recommended: " << get_recommended << LL_ENDL;
|
||||
LL_INFOS() << "system_ram: " << system_ram << LL_ENDL;
|
||||
LL_INFOS() << "max_texmem: " << max_texmem << LL_ENDL;
|
||||
if (get_recommended)
|
||||
max_texmem = llmin(max_texmem, system_ram/2);
|
||||
else
|
||||
@@ -1342,58 +1346,42 @@ S32Megabytes LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended, fl
|
||||
return max_texmem;
|
||||
}
|
||||
|
||||
const S32Megabytes VIDEO_CARD_FRAMEBUFFER_MEM(12);
|
||||
const S32Megabytes VIDEO_CARD_FRAMEBUFFER_MEM_MIN(12);
|
||||
const S32Megabytes VIDEO_CARD_FRAMEBUFFER_MEM_MAX(512);
|
||||
const S32Megabytes MIN_MEM_FOR_NON_TEXTURE(512);
|
||||
void LLViewerTextureList::updateMaxResidentTexMem(S32Megabytes mem)
|
||||
{
|
||||
// Initialize the image pipeline VRAM settings
|
||||
S32Megabytes cur_mem(gSavedSettings.getS32("TextureMemory"));
|
||||
F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple");
|
||||
S32Megabytes default_mem = getMaxVideoRamSetting(true, mem_multiplier); // recommended default
|
||||
if (mem == (S32Bytes)0)
|
||||
const S32Megabytes cur_mem(gSavedSettings.getS32("TextureMemory"));
|
||||
const F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple");
|
||||
const S32Megabytes default_mem = getMaxVideoRamSetting(true, mem_multiplier); // recommended default
|
||||
const S32Megabytes max_mem = getMaxVideoRamSetting(false, mem_multiplier);
|
||||
const S32Megabytes min_mem = getMinVideoRamSetting();
|
||||
|
||||
if (mem == 0)
|
||||
{
|
||||
mem = cur_mem > (S32Bytes)0 ? cur_mem : default_mem;
|
||||
}
|
||||
else if (mem < (S32Bytes)0)
|
||||
else if (mem < 0)
|
||||
{
|
||||
mem = default_mem;
|
||||
}
|
||||
|
||||
mem = llclamp(mem, getMinVideoRamSetting(), getMaxVideoRamSetting(false, mem_multiplier));
|
||||
if (mem != cur_mem)
|
||||
S32Megabytes reported_mem = llclamp(mem, min_mem, max_mem);
|
||||
if (reported_mem != cur_mem)
|
||||
{
|
||||
gSavedSettings.setS32("TextureMemory", mem.value());
|
||||
gSavedSettings.setS32("TextureMemory", reported_mem.value());
|
||||
return; //listener will re-enter this function
|
||||
}
|
||||
|
||||
// TODO: set available resident texture mem based on use by other subsystems
|
||||
// currently max(12MB, VRAM/4) assumed...
|
||||
|
||||
S32Megabytes vb_mem = mem;
|
||||
S32Megabytes fb_mem = llmax(VIDEO_CARD_FRAMEBUFFER_MEM, vb_mem/4);
|
||||
mMaxResidentTexMemInMegaBytes = (vb_mem - fb_mem) ; //in MB
|
||||
|
||||
mMaxTotalTextureMemInMegaBytes = mMaxResidentTexMemInMegaBytes * 2;
|
||||
if (mMaxResidentTexMemInMegaBytes > (S32Megabytes)640)
|
||||
{
|
||||
mMaxTotalTextureMemInMegaBytes -= (mMaxResidentTexMemInMegaBytes / 4);
|
||||
}
|
||||
S32Megabytes fb_mem = llmin(llmax(VIDEO_CARD_FRAMEBUFFER_MEM_MIN, mem / 4), VIDEO_CARD_FRAMEBUFFER_MEM_MAX); // 25% for framebuffers.
|
||||
S32Megabytes misc_mem = llmax(MIN_MEM_FOR_NON_TEXTURE, mem / 5); // 20% for misc.
|
||||
|
||||
//system mem
|
||||
S32Megabytes system_ram = gSysMemory.getPhysicalMemoryKB();
|
||||
mMaxTotalTextureMemInMegaBytes = llmin(mem - misc_mem, max_mem);
|
||||
mMaxResidentTexMemInMegaBytes = llmin(mem - misc_mem - fb_mem, max_mem);
|
||||
|
||||
//minimum memory reserved for non-texture use.
|
||||
//if system_raw >= 1GB, reserve at least 512MB for non-texture use;
|
||||
//otherwise reserve half of the system_ram for non-texture use.
|
||||
S32Megabytes min_non_texture_mem = llmin(system_ram / 2, MIN_MEM_FOR_NON_TEXTURE) ;
|
||||
|
||||
if (mMaxTotalTextureMemInMegaBytes > system_ram - min_non_texture_mem)
|
||||
{
|
||||
mMaxTotalTextureMemInMegaBytes = system_ram - min_non_texture_mem ;
|
||||
}
|
||||
|
||||
LL_INFOS() << "Total Video Memory set to: " << vb_mem << " MB" << LL_ENDL;
|
||||
LL_INFOS() << "Available Texture Memory set to: " << (vb_mem - fb_mem) << " MB" << LL_ENDL;
|
||||
LL_INFOS() << "Available Texture Memory set to: " << mMaxResidentTexMemInMegaBytes << LL_ENDL;
|
||||
LL_INFOS() << "Total Texture Memory set to: " << mMaxTotalTextureMemInMegaBytes << LL_ENDL;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user