diff options
Diffstat (limited to 'indra/llrender')
-rw-r--r-- | indra/llrender/llgl.cpp | 12 | ||||
-rw-r--r-- | indra/llrender/llgl.h | 1 | ||||
-rw-r--r-- | indra/llrender/llrender.cpp | 20 | ||||
-rw-r--r-- | indra/llrender/llrendertarget.cpp | 2 |
4 files changed, 29 insertions, 6 deletions
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 8d000d6fe3..68892453b7 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -335,6 +335,7 @@ LLGLManager::LLGLManager() : mHasShaderObjects(FALSE), mHasVertexShader(FALSE), mHasFragmentShader(FALSE), + mNumTextureImageUnits(0), mHasOcclusionQuery(FALSE), mHasOcclusionQuery2(FALSE), mHasPointParameters(FALSE), @@ -546,6 +547,13 @@ bool LLGLManager::initGL() return false; } + if (mHasFragmentShader) + { + GLint num_tex_image_units; + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &num_tex_image_units); + mNumTextureImageUnits = num_tex_image_units; + } + if (mHasTextureMultisample) { glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &mMaxColorTextureSamples); @@ -558,7 +566,7 @@ bool LLGLManager::initGL() { glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples); } - + setToDebugGPU(); initGLStates(); @@ -904,11 +912,13 @@ void LLGLManager::initExtensions() LL_INFOS("RenderInit") << "Disabling mip-map generation for Intel GPUs" << LL_ENDL; mHasMipMapGeneration = FALSE; } +#if !LL_DARWIN if (mIsATI && mHasMipMapGeneration) { LL_INFOS("RenderInit") << "Disabling mip-map generation for ATI GPUs (performance opt)" << LL_ENDL; mHasMipMapGeneration = FALSE; } +#endif // Misc glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, (GLint*) &mGLMaxVertexRange); diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index 7484196db5..3719b25557 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -92,6 +92,7 @@ public: BOOL mHasShaderObjects; BOOL mHasVertexShader; BOOL mHasFragmentShader; + S32 mNumTextureImageUnits; BOOL mHasOcclusionQuery; BOOL mHasOcclusionQuery2; BOOL mHasPointParameters; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index d5eb3979c3..049dd4346b 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -120,20 +120,29 @@ void LLTexUnit::refreshState(void) gGL.flush(); glActiveTextureARB(GL_TEXTURE0_ARB + mIndex); + + // + // Per apple spec, don't call glEnable/glDisable when index exceeds max texture units + // http://www.mailinglistarchive.com/html/mac-opengl@lists.apple.com/2008-07/msg00653.html + // + bool enableDisable = (mIndex < gGLManager.mNumTextureUnits) && mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE; + if (mCurrTexType != TT_NONE) { - if (mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE) + if (enableDisable) { glEnable(sGLTextureType[mCurrTexType]); } + glBindTexture(sGLTextureType[mCurrTexType], mCurrTexture); } else { - if (mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE) + if (enableDisable) { glDisable(GL_TEXTURE_2D); } + glBindTexture(GL_TEXTURE_2D, 0); } @@ -174,7 +183,8 @@ void LLTexUnit::enable(eTextureType type) mCurrTexType = type; gGL.flush(); - if (type != LLTexUnit::TT_MULTISAMPLE_TEXTURE) + if (type != LLTexUnit::TT_MULTISAMPLE_TEXTURE && + mIndex < gGLManager.mNumTextureUnits) { glEnable(sGLTextureType[type]); } @@ -190,10 +200,12 @@ void LLTexUnit::disable(void) activate(); unbind(mCurrTexType); gGL.flush(); - if (mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE) + if (mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE && + mIndex < gGLManager.mNumTextureUnits) { glDisable(sGLTextureType[mCurrTexType]); } + mCurrTexType = TT_NONE; } } diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index 53c85e6c64..64caf77b87 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -44,7 +44,7 @@ void check_framebuffer_status() case GL_FRAMEBUFFER_COMPLETE: break; default: - llwarns << "Bad framebuffer status: " << std::hex << status << llendl; + llwarns << "check_framebuffer_status failed -- " << std::hex << status << llendl; ll_fail("check_framebuffer_status failed"); break; } |