From 5d6aadb2680595a938223a0a6ec38817c334c571 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Wed, 19 Oct 2011 09:53:44 -0500 Subject: [PATCH] Prevent estimated vram value from being clobbered if glGetIntegerv memory query returns something too small. --- indra/llrender/llgl.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 712582540..48fea8e87 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -545,6 +545,8 @@ bool LLGLManager::initGL() // This is called here because it depends on the setting of mIsGF2or4MX, and sets up mHasMultitexture. initExtensions(); + S32 old_vram = mVRAM; + if (mHasATIMemInfo) { //ask the gl how much vram is free at startup and attempt to use no more than half of that S32 meminfo[4]; @@ -559,6 +561,16 @@ bool LLGLManager::initGL() mVRAM = dedicated_memory/1024; } + if (mVRAM < 256) + { //something likely went wrong using the above extensions, fall back to old method + mVRAM = old_vram; + } + if (mHasFragmentShader) + { + GLint num_tex_image_units; + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &num_tex_image_units); + mNumTextureImageUnits = llmin(num_tex_image_units, 32); + } if (mHasMultitexture) { GLint num_tex_units; @@ -578,12 +590,6 @@ bool LLGLManager::initGL() return false; } - if (mHasFragmentShader) - { - GLint num_tex_image_units; - glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &num_tex_image_units); - mNumTextureImageUnits = llmin(num_tex_image_units, 32); - } if (mHasTextureMultisample) { @@ -1314,9 +1320,6 @@ void LLGLState::initClass() sStateMap[GL_MULTISAMPLE_ARB] = GL_FALSE; glDisable(GL_MULTISAMPLE_ARB); - sStateMap[GL_MULTISAMPLE_ARB] = GL_FALSE; - glDisable(GL_MULTISAMPLE_ARB); - glEnableClientState(GL_VERTEX_ARRAY); }