diff options
Diffstat (limited to 'indra/llrender/llrender.cpp')
-rw-r--r-- | indra/llrender/llrender.cpp | 149 |
1 files changed, 72 insertions, 77 deletions
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 72cca1f2a2..c58fbe6c8e 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -69,8 +69,9 @@ static const U32 LL_NUM_LIGHT_UNITS = 8; static const GLenum sGLTextureType[] = { GL_TEXTURE_2D, - GL_TEXTURE_RECTANGLE_ARB, - GL_TEXTURE_CUBE_MAP_ARB, + GL_TEXTURE_RECTANGLE, + GL_TEXTURE_CUBE_MAP, + GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_3D }; @@ -122,7 +123,7 @@ void LLTexUnit::refreshState(void) gGL.flush(); - glActiveTextureARB(GL_TEXTURE0_ARB + mIndex); + glActiveTexture(GL_TEXTURE0 + mIndex); if (mCurrTexType != TT_NONE) { @@ -143,7 +144,7 @@ void LLTexUnit::activate(void) if ((S32)gGL.mCurrTextureUnitIndex != mIndex || gGL.mDirty) { gGL.flush(); - glActiveTextureARB(GL_TEXTURE0_ARB + mIndex); + glActiveTexture(GL_TEXTURE0 + mIndex); gGL.mCurrTextureUnitIndex = mIndex; } } @@ -187,7 +188,7 @@ void LLTexUnit::bindFast(LLTexture* texture) { LLImageGL* gl_tex = texture->getGLTexture(); - glActiveTextureARB(GL_TEXTURE0_ARB + mIndex); + glActiveTexture(GL_TEXTURE0 + mIndex); gGL.mCurrTextureUnitIndex = mIndex; mCurrTexture = gl_tex->getTexName(); if (!mCurrTexture) @@ -223,7 +224,7 @@ bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind) enable(gl_tex->getTarget()); mCurrTexture = gl_tex->getTexName(); glBindTexture(sGLTextureType[gl_tex->getTarget()], mCurrTexture); - if(gl_tex->updateBindStats(gl_tex->mTextureMemory)) + if(gl_tex->updateBindStats()) { texture->setActive() ; texture->updateBindStatsForTester() ; @@ -302,7 +303,7 @@ bool LLTexUnit::bind(LLImageGL* texture, bool for_rendering, bool forceBind, S32 mCurrTexture = texname; glBindTexture(sGLTextureType[texture->getTarget()], mCurrTexture); stop_glerror(); - texture->updateBindStats(texture->mTextureMemory); + texture->updateBindStats(); mHasMipMaps = texture->mHasMipMaps; if (texture->mTexOptionsDirty) { @@ -334,14 +335,14 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap) if (mCurrTexture != cubeMap->mImages[0]->getTexName()) { - if (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) + if (LLCubeMap::sUseCubeMaps) { activate(); enable(LLTexUnit::TT_CUBE_MAP); mCurrTexture = cubeMap->mImages[0]->getTexName(); - glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mCurrTexture); + glBindTexture(GL_TEXTURE_CUBE_MAP, mCurrTexture); mHasMipMaps = cubeMap->mImages[0]->mHasMipMaps; - cubeMap->mImages[0]->updateBindStats(cubeMap->mImages[0]->mTextureMemory); + cubeMap->mImages[0]->updateBindStats(); if (cubeMap->mImages[0]->mTexOptionsDirty) { cubeMap->mImages[0]->mTexOptionsDirty = false; @@ -469,7 +470,7 @@ void LLTexUnit::setTextureAddressMode(eTextureAddressMode mode) glTexParameteri (sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_T, sGLAddressMode[mode]); if (mCurrTexType == TT_CUBE_MAP) { - glTexParameteri (GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, sGLAddressMode[mode]); + glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, sGLAddressMode[mode]); } } @@ -515,22 +516,15 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio } } - if (gGLManager.mHasAnisotropic) + if (gGLManager.mGLVersion >= 4.59f) { if (LLImageGL::sGlobalUseAnisotropic && option == TFO_ANISOTROPIC) { - if (gGL.mMaxAnisotropy < 1.f) - { - glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gGL.mMaxAnisotropy); - - LL_INFOS() << "gGL.mMaxAnisotropy: " << gGL.mMaxAnisotropy << LL_ENDL ; - gGL.mMaxAnisotropy = llmax(1.f, gGL.mMaxAnisotropy) ; - } - glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY_EXT, gGL.mMaxAnisotropy); + glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY, gGLManager.mMaxAnisotropy); } else { - glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); + glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY, 1.f); } } } @@ -544,7 +538,7 @@ GLint LLTexUnit::getTextureSource(eTextureBlendSrc src) case TBS_PREV_ALPHA: case TBS_ONE_MINUS_PREV_COLOR: case TBS_ONE_MINUS_PREV_ALPHA: - return GL_PREVIOUS_ARB; + return GL_PREVIOUS; // All four cases should return the same value. case TBS_TEX_COLOR: @@ -558,18 +552,18 @@ GLint LLTexUnit::getTextureSource(eTextureBlendSrc src) case TBS_VERT_ALPHA: case TBS_ONE_MINUS_VERT_COLOR: case TBS_ONE_MINUS_VERT_ALPHA: - return GL_PRIMARY_COLOR_ARB; + return GL_PRIMARY_COLOR; // All four cases should return the same value. case TBS_CONST_COLOR: case TBS_CONST_ALPHA: case TBS_ONE_MINUS_CONST_COLOR: case TBS_ONE_MINUS_CONST_ALPHA: - return GL_CONSTANT_ARB; + return GL_CONSTANT; default: LL_WARNS() << "Unknown eTextureBlendSrc: " << src << ". Using Vertex Color instead." << LL_ENDL; - return GL_PRIMARY_COLOR_ARB; + return GL_PRIMARY_COLOR; } } @@ -638,10 +632,10 @@ void LLTexUnit::debugTextureUnit(void) if (mIndex < 0) return; GLint activeTexture; - glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &activeTexture); - if ((GL_TEXTURE0_ARB + mIndex) != activeTexture) + glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTexture); + if ((GL_TEXTURE0 + mIndex) != activeTexture) { - U32 set_unit = (activeTexture - GL_TEXTURE0_ARB); + U32 set_unit = (activeTexture - GL_TEXTURE0); LL_WARNS() << "Incorrect Texture Unit! Expected: " << set_unit << " Actual: " << mIndex << LL_ENDL; } } @@ -649,29 +643,6 @@ void LLTexUnit::debugTextureUnit(void) void LLTexUnit::setTextureColorSpace(eTextureColorSpace space) { mTexColorSpace = space; - -#if USE_SRGB_DECODE - if (gGLManager.mHasTexturesRGBDecode) - { - if (space == TCS_SRGB) - { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT); - } - else - { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); - } - - if (gDebugGL) - { - assert_glerror(); - } - } - else - { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); - } -#endif } LLLightState::LLLightState(S32 index) @@ -734,6 +705,24 @@ void LLLightState::setSunPrimary(bool v) } } +void LLLightState::setSize(F32 v) +{ + if (mSize != v) + { + ++gGL.mLightHash; + mSize = v; + } +} + +void LLLightState::setFalloff(F32 v) +{ + if (mFalloff != v) + { + ++gGL.mLightHash; + mFalloff = v; + } +} + void LLLightState::setAmbient(const LLColor4& ambient) { if (mAmbient != ambient) @@ -827,8 +816,7 @@ LLRender::LLRender() mCount(0), mQuadCycle(0), mMode(LLRender::TRIANGLES), - mCurrTextureUnitIndex(0), - mMaxAnisotropy(0.f) + mCurrTextureUnitIndex(0) { mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS); for (U32 i = 0; i < LL_NUM_TEXTURE_LAYERS; i++) @@ -874,9 +862,9 @@ void LLRender::init(bool needs_vertex_buffer) #if LL_WINDOWS if (gGLManager.mHasDebugOutput && gDebugGL) { //setup debug output callback - //glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW_ARB, 0, NULL, GL_TRUE); - glDebugMessageCallbackARB((GLDEBUGPROCARB) gl_debug_callback, NULL); - glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); + //glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW_ARB, 0, NULL, GL_TRUE); + glDebugMessageCallback((GLDEBUGPROC) gl_debug_callback, NULL); + glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); } #endif @@ -888,13 +876,14 @@ void LLRender::init(bool needs_vertex_buffer) glCullFace(GL_BACK); + // necessary for reflection maps + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + if (sGLCoreProfile && !LLVertexBuffer::sUseVAO) { //bind a dummy vertex array object so we're core profile compliant -#ifdef GL_ARB_vertex_array_object U32 ret; glGenVertexArrays(1, &ret); glBindVertexArray(ret); -#endif } if (needs_vertex_buffer) @@ -977,6 +966,7 @@ void LLRender::syncLightState() LLVector3 diffuse[LL_NUM_LIGHT_UNITS]; LLVector3 diffuse_b[LL_NUM_LIGHT_UNITS]; bool sun_primary[LL_NUM_LIGHT_UNITS]; + LLVector2 size[LL_NUM_LIGHT_UNITS]; for (U32 i = 0; i < LL_NUM_LIGHT_UNITS; i++) { @@ -988,17 +978,19 @@ void LLRender::syncLightState() diffuse[i].set(light->mDiffuse.mV); diffuse_b[i].set(light->mDiffuseB.mV); sun_primary[i] = light->mSunIsPrimary; + size[i].set(light->mSize, light->mFalloff); } shader->uniform4fv(LLShaderMgr::LIGHT_POSITION, LL_NUM_LIGHT_UNITS, position[0].mV); shader->uniform3fv(LLShaderMgr::LIGHT_DIRECTION, LL_NUM_LIGHT_UNITS, direction[0].mV); shader->uniform4fv(LLShaderMgr::LIGHT_ATTENUATION, LL_NUM_LIGHT_UNITS, attenuation[0].mV); + shader->uniform2fv(LLShaderMgr::LIGHT_DEFERRED_ATTENUATION, LL_NUM_LIGHT_UNITS, size[0].mV); shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, LL_NUM_LIGHT_UNITS, diffuse[0].mV); - shader->uniform4fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV); + shader->uniform3fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV); shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_primary[0] ? 1 : 0); - shader->uniform4fv(LLShaderMgr::AMBIENT, 1, mAmbientLightColor.mV); - shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV); - shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV); + shader->uniform3fv(LLShaderMgr::AMBIENT, 1, mAmbientLightColor.mV); + shader->uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV); + shader->uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV); } } @@ -1095,13 +1087,20 @@ void LLRender::syncMatrices() { //update projection matrix, normal, and MVP glh::matrix4f& mat = mMatrix[MM_PROJECTION][mMatIdx[MM_PROJECTION]]; - // it would be nice to have this automatically track the state of the proj matrix - // but certain render paths (deferred lighting) require it to be mismatched *sigh* - //if (shader->getUniformLocation(LLShaderMgr::INVERSE_PROJECTION_MATRIX)) - //{ - // glh::matrix4f inv_proj = mat.inverse(); - // shader->uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, inv_proj.m); - //} + // GZ: This was previously disabled seemingly due to a bug involving the deferred renderer's regular pushing and popping of mats. + // We're reenabling this and cleaning up the code around that - that would've been the appropriate course initially. + // Anything beyond the standard proj and inv proj mats are special cases. Please setup special uniforms accordingly in the future. + if (shader->getUniformLocation(LLShaderMgr::INVERSE_PROJECTION_MATRIX)) + { + glh::matrix4f inv_proj = mat.inverse(); + shader->uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, inv_proj.m); + } + + // Used by some full screen effects - such as full screen lights, glow, etc. + if (shader->getUniformLocation(LLShaderMgr::IDENTITY_MATRIX)) + { + shader->uniformMatrix4fv(LLShaderMgr::IDENTITY_MATRIX, 1, GL_FALSE, glh::matrix4f::identity().m); + } shader->uniformMatrix4fv(name[MM_PROJECTION], 1, GL_FALSE, mat.m); shader->mMatHash[MM_PROJECTION] = mMatHash[MM_PROJECTION]; @@ -1479,12 +1478,7 @@ void LLRender::blendFunc(eBlendFactor color_sfactor, eBlendFactor color_dfactor, llassert(color_dfactor < BF_UNDEF); llassert(alpha_sfactor < BF_UNDEF); llassert(alpha_dfactor < BF_UNDEF); - if (!gGLManager.mHasBlendFuncSeparate) - { - LL_WARNS_ONCE("render") << "no glBlendFuncSeparateEXT(), using color-only blend func" << LL_ENDL; - blendFunc(color_sfactor, color_dfactor); - return; - } + if (mCurrBlendColorSFactor != color_sfactor || mCurrBlendColorDFactor != color_dfactor || mCurrBlendAlphaSFactor != alpha_sfactor || mCurrBlendAlphaDFactor != alpha_dfactor) { @@ -1493,8 +1487,9 @@ void LLRender::blendFunc(eBlendFactor color_sfactor, eBlendFactor color_dfactor, mCurrBlendColorDFactor = color_dfactor; mCurrBlendAlphaDFactor = alpha_dfactor; flush(); - glBlendFuncSeparateEXT(sGLBlendFactor[color_sfactor], sGLBlendFactor[color_dfactor], - sGLBlendFactor[alpha_sfactor], sGLBlendFactor[alpha_dfactor]); + + glBlendFuncSeparate(sGLBlendFactor[color_sfactor], sGLBlendFactor[color_dfactor], + sGLBlendFactor[alpha_sfactor], sGLBlendFactor[alpha_dfactor]); } } |