Skip to content
Snippets Groups Projects
Commit a8e22e11 authored by David Parks's avatar David Parks
Browse files

MAINT-2980 Rename "Texture Memory" to "Video Memory" in hardware floater and increase limit.

Limit should be however much vram is installed, but underneath the hood, fudge
how much memory is used for textures to avoid swapping.

Also, catch exceptions when attempting to build a GL context on windows and
display an error dialog instead of crashing.
parent bfe52038
No related branches found
No related tags found
No related merge requests found
......@@ -85,6 +85,18 @@ void show_window_creation_error(const std::string& title)
LL_WARNS("Window") << title << LL_ENDL;
}
HGLRC SafeCreateContext(HDC hdc)
{
__try
{
return wglCreateContext(hdc);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
return NULL;
}
}
//static
BOOL LLWindowWin32::sIsClassRegistered = FALSE;
......@@ -1166,14 +1178,15 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
return FALSE;
}
if (!(mhRC = wglCreateContext(mhDC)))
if (!(mhRC = SafeCreateContext(mhDC)))
{
close();
OSMessageBox(mCallbacks->translateString("MBGLContextErr"),
mCallbacks->translateString("MBError"), OSMB_OK);
return FALSE;
}
if (!wglMakeCurrent(mhDC, mhRC))
{
close();
......
......@@ -87,15 +87,30 @@ void LLFloaterHardwareSettings::refresh()
refreshEnabledState();
}
void LLFloaterHardwareSettings::onSetVRAM()
{
S32 vram = childGetValue("GraphicsCardTextureMemory").asInteger();
//give the texture system plenty of leeway to avoid swapping
vram /= 3;
gSavedSettings.setS32("TextureMemory", vram);
}
void LLFloaterHardwareSettings::refreshEnabledState()
{
F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple");
S32 min_tex_mem = LLViewerTextureList::getMinVideoRamSetting();
S32 max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(false, mem_multiplier);
S32 max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(true, mem_multiplier);
getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMinValue(min_tex_mem);
getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMaxValue(max_tex_mem);
S32 vram = gSavedSettings.getS32("TextureMemory");
vram = vram*3;
getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setValue(vram);
getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setCommitCallback(boost::bind(&LLFloaterHardwareSettings::onSetVRAM, this));
if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") ||
!gGLManager.mHasVertexBufferObject)
{
......
......@@ -64,6 +64,8 @@ public:
/// don't apply the changed values
void cancel();
void onSetVRAM();
/// refresh the enabled values
void refreshEnabledState();
......
......@@ -40,7 +40,7 @@
#include <list>
#define MIN_VIDEO_RAM_IN_MEGA_BYTES 32
#define MAX_VIDEO_RAM_IN_MEGA_BYTES 512 // 512MB max for performance reasons.
#define MAX_VIDEO_RAM_IN_MEGA_BYTES 4096
class LLImageGL ;
class LLImageRaw;
......
......@@ -1270,7 +1270,7 @@ S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended, float mem_m
// - it's going to be swapping constantly regardless
S32 max_vram = gGLManager.mVRAM;
if(gGLManager.mIsATI)
if(!get_recommended && gGLManager.mIsATI)
{
//shrink the availabe vram for ATI cards because some of them do not handel texture swapping well.
max_vram = (S32)(max_vram * 0.75f);
......@@ -1285,15 +1285,15 @@ S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended, float mem_m
{
if (!get_recommended)
{
max_texmem = 512;
max_texmem = 2048;
}
else if (gSavedSettings.getBOOL("NoHardwareProbe")) //did not do hardware detection at startup
{
max_texmem = 512;
max_texmem = 2048;
}
else
{
max_texmem = 128;
max_texmem = 512;
}
llwarns << "VRAM amount not detected, defaulting to " << max_texmem << " MB" << llendl;
......@@ -1301,10 +1301,7 @@ S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended, float mem_m
S32 system_ram = (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped()); // In MB
//llinfos << "*** DETECTED " << system_ram << " MB of system memory." << llendl;
if (get_recommended)
max_texmem = llmin(max_texmem, (S32)(system_ram/2));
else
max_texmem = llmin(max_texmem, (S32)(system_ram));
max_texmem = llmin(max_texmem, (S32)(system_ram));
// limit the texture memory to a multiple of the default if we've found some cards to behave poorly otherwise
max_texmem = llmin(max_texmem, (S32) (mem_multiplier * (F32) max_texmem));
......@@ -1334,7 +1331,7 @@ void LLViewerTextureList::updateMaxResidentTexMem(S32 mem)
mem = llclamp(mem, getMinVideoRamSetting(), getMaxVideoRamSetting(false, mem_multiplier));
if (mem != cur_mem)
{
gSavedSettings.setS32("TextureMemory", mem);
gSavedSettings.setS32("TextureMemory", mem/3);
return; //listener will re-enter this function
}
......
......@@ -155,13 +155,12 @@
tool_tip="Compresses textures in video memory, allowing for higher resolution textures to be loaded at the cost of some color quality."
width="315" />
<slider
control_name="TextureMemory"
decimal_digits="0"
follows="left|top"
height="20"
increment="16"
initial_value="32"
label="Texture Memory (MB):"
label="Video Memory (MB):"
label_width="195"
layout="topleft"
left="10"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment