diff --git a/indra/llcommon/llstat.cpp b/indra/llcommon/llstat.cpp index 3c2289649..bbb2b30d7 100644 --- a/indra/llcommon/llstat.cpp +++ b/indra/llcommon/llstat.cpp @@ -113,8 +113,8 @@ void LLStat::addValue(const F32 value) } // Increment the bin counters. - mCurBin = ++mCurBin % mNumBins; - mNextBin = ++mNextBin % mNumBins; + mCurBin = (mCurBin+1) % mNumBins; + mNextBin = (mNextBin+1) % mNumBins; mBins[mCurBin].mValue = value; if (mUseFrameTimer) diff --git a/indra/llmath/llperlin.h b/indra/llmath/llperlin.h index 8f9f68bbe..c6e49178a 100644 --- a/indra/llmath/llperlin.h +++ b/indra/llmath/llperlin.h @@ -35,15 +35,7 @@ class LLPerlinNoise { public: - template - static F32 noise(const T& x, U32 wrap_at); - template - static F32 noise(const T& x) - { - return noise(x, 256); - } - template<> - static F32 noise(const F32& x, U32 wrap_at) + static F32 noise(const F32& x, U32 wrap_at = 256) { U8 b[1][2]; F32 r[1][2], s[1], u, v; @@ -55,8 +47,7 @@ public: return lerp(u, v, s[VX]); } - template <> - static F32 noise(const LLVector2& vec, U32 wrap_at) + static F32 noise(const LLVector2& vec, U32 wrap_at = 256) { U8 b[2][2]; F32 r[2][2], s[2], u, v, A, B; @@ -73,8 +64,7 @@ public: return lerp(A, B, s[VY]); } - template <> - static F32 noise(const LLVector3& vec, U32 wrap_at) + static F32 noise(const LLVector3& vec, U32 wrap_at = 256) { U8 b[3][2]; F32 r[3][2], s[3], u, v, A, B, C, D; @@ -101,7 +91,7 @@ public: D = lerp(A, B, s[VY]); - return lerp(C, D, s[VZ]); + return lerp(C, D, s[VZ]) * 0.77f; } template static F32 turbulence(const T& vec, F32 freq, U32 wrap_at = 256) @@ -169,7 +159,7 @@ private: const U32 limit = llclamp(wrap_at, U32(1), U32(256)); for (U32 i = 0; i < N; ++i) { - const S32 t_S32 = lltrunc(vec[i]); + const S32 t_S32 = llfloor(vec[i]); b[i][0] = (t_S32) % limit; b[i][1] = (t_S32 + 1) % limit; r[i][0] = vec[i] - F32(t_S32); diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 19c2722e7..7e11ffcf0 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -38,12 +38,6 @@ #include "OpenGL/OpenGL.h" #endif -#ifdef LL_RELEASE_FOR_DOWNLOAD -#define UNIFORM_ERRS LL_WARNS_ONCE("Shader") -#else -#define UNIFORM_ERRS LL_ERRS("Shader") -#endif - // Lots of STL stuff in here, using namespace std to keep things more readable using std::vector; using std::pair; @@ -431,7 +425,6 @@ void LLGLSLShader::mapUniform(GLint index, const vector * } LLStaticHashedString hashedName(name); - mUniformNameMap[location] = name; mUniformMap[hashedName] = location; LL_DEBUGS("ShaderLoading") << "Uniform " << name << " is at location " << location << LL_ENDL; @@ -496,9 +489,10 @@ BOOL LLGLSLShader::mapUniforms(const vector * uniforms) mActiveTextureChannels = 0; mUniform.clear(); mUniformMap.clear(); - mUniformNameMap.clear(); mTexture.clear(); - mValue.clear(); + mValueVec4.clear(); + mValueMat3.clear(); + mValueMat4.clear(); //initialize arrays U32 numUniforms = (uniforms == NULL) ? 0 : uniforms->size(); mUniform.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1); @@ -671,326 +665,6 @@ S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode) return index; } -void LLGLSLShader::uniform1i(U32 index, GLint x) -{ - if (mProgramObject > 0) - { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } - - if (mUniform[index] >= 0) - { - std::map::iterator iter = mValue.find(mUniform[index]); - if (iter == mValue.end() || iter->second.mV[0] != x) - { - glUniform1iARB(mUniform[index], x); - mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f); - } - } - } -} - -void LLGLSLShader::uniform1f(U32 index, GLfloat x) -{ - if (mProgramObject > 0) - { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } - - if (mUniform[index] >= 0) - { - std::map::iterator iter = mValue.find(mUniform[index]); - if (iter == mValue.end() || iter->second.mV[0] != x) - { - glUniform1fARB(mUniform[index], x); - mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f); - } - } - } -} - -void LLGLSLShader::uniform2f(U32 index, GLfloat x, GLfloat y) -{ - if (mProgramObject > 0) - { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } - - if (mUniform[index] >= 0) - { - std::map::iterator iter = mValue.find(mUniform[index]); - LLVector4 vec(x,y,0.f,0.f); - if (iter == mValue.end() || shouldChange(iter->second,vec)) - { - glUniform2fARB(mUniform[index], x, y); - mValue[mUniform[index]] = vec; - } - } - } -} - -void LLGLSLShader::uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z) -{ - if (mProgramObject > 0) - { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } - - if (mUniform[index] >= 0) - { - std::map::iterator iter = mValue.find(mUniform[index]); - LLVector4 vec(x,y,z,0.f); - if (iter == mValue.end() || shouldChange(iter->second,vec)) - { - glUniform3fARB(mUniform[index], x, y, z); - mValue[mUniform[index]] = vec; - } - } - } -} - -void LLGLSLShader::uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - if (mProgramObject > 0) - { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } - - if (mUniform[index] >= 0) - { - std::map::iterator iter = mValue.find(mUniform[index]); - LLVector4 vec(x,y,z,w); - if (iter == mValue.end() || shouldChange(iter->second,vec)) - { - glUniform4fARB(mUniform[index], x, y, z, w); - mValue[mUniform[index]] = vec; - } - } - } -} - -void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v) -{ - if (mProgramObject > 0) - { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } - - if (mUniform[index] >= 0) - { - std::map::iterator iter = mValue.find(mUniform[index]); - LLVector4 vec(v[0],0.f,0.f,0.f); - if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) - { - glUniform1ivARB(mUniform[index], count, v); - mValue[mUniform[index]] = vec; - } - } - } -} - -void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v) -{ - if (mProgramObject > 0) - { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } - - if (mUniform[index] >= 0) - { - std::map::iterator iter = mValue.find(mUniform[index]); - LLVector4 vec(v[0],0.f,0.f,0.f); - if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) - { - glUniform1fvARB(mUniform[index], count, v); - mValue[mUniform[index]] = vec; - } - } - } -} - -void LLGLSLShader::uniform2fv(U32 index, U32 count, const GLfloat* v) -{ - if (mProgramObject > 0) - { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } - - if (mUniform[index] >= 0) - { - std::map::iterator iter = mValue.find(mUniform[index]); - LLVector4 vec(v[0],v[1],0.f,0.f); - if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) - { - glUniform2fvARB(mUniform[index], count, v); - mValue[mUniform[index]] = vec; - } - } - } -} - -void LLGLSLShader::uniform3fv(U32 index, U32 count, const GLfloat* v) -{ - if (mProgramObject > 0) - { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } - - if (mUniform[index] >= 0) - { - std::map::iterator iter = mValue.find(mUniform[index]); - LLVector4 vec(v[0],v[1],v[2],0.f); - if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) - { - glUniform3fvARB(mUniform[index], count, v); - mValue[mUniform[index]] = vec; - } - } - } -} - -void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v) -{ - if (mProgramObject > 0) - { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } - - if (mUniform[index] >= 0) - { - std::map::iterator iter = mValue.find(mUniform[index]); - LLVector4 vec(v[0],v[1],v[2],v[3]); - if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) - { - glUniform4fvARB(mUniform[index], count, v); - mValue[mUniform[index]] = vec; - } - } - } -} - -void LLGLSLShader::uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v) -{ - if (mProgramObject > 0) - { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } - - if (mUniform[index] >= 0) - { - glUniformMatrix2fvARB(mUniform[index], count, transpose, v); - } - } -} - -void LLGLSLShader::uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v) -{ - if (mProgramObject > 0) - { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } - - if (mUniform[index] >= 0) - { - glUniformMatrix3fvARB(mUniform[index], count, transpose, v); - } - } -} - -void LLGLSLShader::uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v) -{ - if (mProgramObject > 0) - { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } - - if (mUniform[index] >= 0) - { - glUniformMatrix3x4fv(mUniform[index], count, transpose, v); - } - } -} - -void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v) -{ - if (mProgramObject > 0) - { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } - - if (mUniform[index] >= 0) - { - glUniformMatrix4fvARB(mUniform[index], count, transpose, v); - } - } -} - -GLint LLGLSLShader::getUniformLocation(const LLStaticHashedString& uniform) -{ - GLint ret = -1; - if (mProgramObject > 0) - { - LLStaticStringTable::iterator iter = mUniformMap.find(uniform); - if (iter != mUniformMap.end()) - { - if (gDebugGL) - { - stop_glerror(); - if (iter->second != glGetUniformLocationARB(mProgramObject, uniform.String().c_str())) - { - llerrs << "Uniform does not match." << llendl; - } - stop_glerror(); - } - ret = iter->second; - } - } - - return ret; -} - GLint LLGLSLShader::getUniformLocation(U32 index) { GLint ret = -1; @@ -1015,167 +689,6 @@ GLint LLGLSLShader::getAttribLocation(U32 attrib) } } -void LLGLSLShader::uniform1i(const LLStaticHashedString& uniform, GLint v) -{ - GLint location = getUniformLocation(uniform); - - if (location >= 0) - { - std::map::iterator iter = mValue.find(location); - LLVector4 vec(v,0.f,0.f,0.f); - if (iter == mValue.end() || shouldChange(iter->second,vec)) - { - glUniform1iARB(location, v); - mValue[location] = vec; - } - } -} - -void LLGLSLShader::uniform2i(const LLStaticHashedString& uniform, GLint i, GLint j) -{ - GLint location = getUniformLocation(uniform); - - if (location >= 0) - { - std::map::iterator iter = mValue.find(location); - LLVector4 vec(i,j,0.f,0.f); - if (iter == mValue.end() || shouldChange(iter->second,vec)) - { - glUniform2iARB(location, i, j); - mValue[location] = vec; - } - } -} - - -void LLGLSLShader::uniform1f(const LLStaticHashedString& uniform, GLfloat v) -{ - GLint location = getUniformLocation(uniform); - - if (location >= 0) - { - std::map::iterator iter = mValue.find(location); - LLVector4 vec(v,0.f,0.f,0.f); - if (iter == mValue.end() || shouldChange(iter->second,vec)) - { - glUniform1fARB(location, v); - mValue[location] = vec; - } - } -} - -void LLGLSLShader::uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y) -{ - GLint location = getUniformLocation(uniform); - - if (location >= 0) - { - std::map::iterator iter = mValue.find(location); - LLVector4 vec(x,y,0.f,0.f); - if (iter == mValue.end() || shouldChange(iter->second,vec)) - { - glUniform2fARB(location, x,y); - mValue[location] = vec; - } - } - -} - -void LLGLSLShader::uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z) -{ - GLint location = getUniformLocation(uniform); - - if (location >= 0) - { - std::map::iterator iter = mValue.find(location); - LLVector4 vec(x,y,z,0.f); - if (iter == mValue.end() || shouldChange(iter->second,vec)) - { - glUniform3fARB(location, x,y,z); - mValue[location] = vec; - } - } -} - -void LLGLSLShader::uniform1fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v) -{ - GLint location = getUniformLocation(uniform); - - if (location >= 0) - { - std::map::iterator iter = mValue.find(location); - LLVector4 vec(v[0],0.f,0.f,0.f); - if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) - { - glUniform1fvARB(location, count, v); - mValue[location] = vec; - } - } -} - -void LLGLSLShader::uniform2fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v) -{ - GLint location = getUniformLocation(uniform); - - if (location >= 0) - { - std::map::iterator iter = mValue.find(location); - LLVector4 vec(v[0],v[1],0.f,0.f); - if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) - { - glUniform2fvARB(location, count, v); - mValue[location] = vec; - } - } -} - -void LLGLSLShader::uniform3fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v) -{ - GLint location = getUniformLocation(uniform); - - if (location >= 0) - { - std::map::iterator iter = mValue.find(location); - LLVector4 vec(v[0],v[1],v[2],0.f); - if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) - { - glUniform3fvARB(location, count, v); - mValue[location] = vec; - } - } -} - -void LLGLSLShader::uniform4fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v) -{ - GLint location = getUniformLocation(uniform); - - if (location >= 0) - { - LLVector4 vec(v); - std::map::iterator iter = mValue.find(location); - if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) - { - stop_glerror(); - glUniform4fvARB(location, count, v); - stop_glerror(); - mValue[location] = vec; - } - } -} - -void LLGLSLShader::uniformMatrix4fv(const LLStaticHashedString& uniform, U32 count, GLboolean transpose, const GLfloat* v) -{ - GLint location = getUniformLocation(uniform); - - if (location >= 0) - { - stop_glerror(); - glUniformMatrix4fvARB(location, count, transpose, v); - stop_glerror(); - } -} - - void LLGLSLShader::vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { if (mAttribute[index] > 0) @@ -1184,14 +697,6 @@ void LLGLSLShader::vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GL } } -void LLGLSLShader::vertexAttrib4fv(U32 index, GLfloat* v) -{ - if (mAttribute[index] > 0) - { - glVertexAttrib4fvARB(mAttribute[index], v); - } -} - void LLGLSLShader::setMinimumAlpha(F32 minimum) { gGL.flush(); diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index a530d2658..c5fc3abca 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -30,6 +30,11 @@ #include "llgl.h" #include "llrender.h" #include "llstaticstringtable.h" +#ifdef LL_RELEASE_FOR_DOWNLOAD +#define UNIFORM_ERRS LL_WARNS_ONCE("Shader") +#else +#define UNIFORM_ERRS LL_ERRS("Shader") +#endif class LLShaderFeatures { @@ -87,38 +92,256 @@ public: BOOL mapAttributes(const std::vector * attributes); BOOL mapUniforms(const std::vector *); void mapUniform(GLint index, const std::vector *); - void uniform1i(U32 index, GLint i); - void uniform1f(U32 index, GLfloat v); - void uniform2f(U32 index, GLfloat x, GLfloat y); - void uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z); - void uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - void uniform1iv(U32 index, U32 count, const GLint* i); - void uniform1fv(U32 index, U32 count, const GLfloat* v); - void uniform2fv(U32 index, U32 count, const GLfloat* v); - void uniform3fv(U32 index, U32 count, const GLfloat* v); - void uniform4fv(U32 index, U32 count, const GLfloat* v); - void uniform2i(const LLStaticHashedString& uniform, GLint i, GLint j); - void uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); - void uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); - void uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); - void uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); - void uniform1i(const LLStaticHashedString& uniform, GLint i); - void uniform1f(const LLStaticHashedString& uniform, GLfloat v); - void uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y); - void uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z); - void uniform1fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v); - void uniform2fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v); - void uniform3fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v); - void uniform4fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v); - void uniformMatrix4fv(const LLStaticHashedString& uniform, U32 count, GLboolean transpose, const GLfloat *v); + S32 getUniformFromIndex(const U32 index) + { + if (mUniform.size() <= index) + { + UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + return -1; + } + return mUniform[index]; + } + template + S32 updateUniform(std::vector >& cache, S32 uniform, const F32* val) + { + if (mProgramObject > 0) + { + if (uniform >= 0) + { + std::vector >::iterator iter = std::find_if(cache.begin(), cache.end(), boost::bind(&std::pair::first, _1) == uniform); + if (iter == cache.end()) + { + T tmp; + memcpy(&tmp, val, sizeof(F32)*N); + cache.push_back(std::make_pair(uniform, tmp)); + return true; + } + else if (memcmp(&iter->second, val, sizeof(F32)*N)) + { + memcpy(&iter->second, val, sizeof(F32)*N); + return true; + } + } + } + return false; + } + void uniform1i(U32 index, GLint x) + { + F32 val = x; + if (updateUniform(mValueVec4, getUniformFromIndex(index), &val)) + { + glUniform1iARB(mUniform[index], x); + } + } + void uniform1f(U32 index, GLfloat x) + { + if (updateUniform(mValueVec4, getUniformFromIndex(index), &x)) + { + glUniform1fARB(mUniform[index], x); + } + } + void uniform2f(U32 index, GLfloat x, GLfloat y) + { + F32 val[] = { x, y }; + if (updateUniform(mValueVec4, getUniformFromIndex(index), val)) + { + glUniform2fARB(mUniform[index], x, y); + } + } + void uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z) + { + F32 val[] = { x, y, z }; + if (updateUniform(mValueVec4, getUniformFromIndex(index), val)) + { + glUniform3fARB(mUniform[index], x, y, z); + } + } + void uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) + { + F32 val[] = { x, y, z, w }; + if (updateUniform(mValueVec4, getUniformFromIndex(index), val)) + { + glUniform4fARB(mUniform[index], x, y, z, w); + } + } + void uniform1iv(U32 index, U32 count, const GLint* v) + { + F32 val[] = { v[0] }; + if (updateUniform(mValueVec4, getUniformFromIndex(index), val) || count > 1) + { + glUniform1ivARB(mUniform[index], count, v); + } + } + void uniform1fv(U32 index, U32 count, const GLfloat* v) + { + if (updateUniform(mValueVec4, getUniformFromIndex(index), v) || count > 1) + { + glUniform1fvARB(mUniform[index], count, v); + } + } + void uniform2fv(U32 index, U32 count, const GLfloat* v) + { + if (updateUniform(mValueVec4, getUniformFromIndex(index), v) || count > 1) + { + glUniform2fvARB(mUniform[index], count, v); + } + } + void uniform3fv(U32 index, U32 count, const GLfloat* v) + { + if (updateUniform(mValueVec4, getUniformFromIndex(index), v) || count > 1) + { + glUniform3fvARB(mUniform[index], count, v); + } + } + void uniform4fv(U32 index, U32 count, const GLfloat* v) + { + if (updateUniform(mValueVec4, getUniformFromIndex(index), v) || count > 1) + { + glUniform4fvARB(mUniform[index], count, v); + } + } + void uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v) + { + if (updateUniform(mValueMat3, getUniformFromIndex(index), v) || count > 1) + { + glUniformMatrix3fvARB(mUniform[index], count, transpose, v); + } + } + void uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v) + { + if (updateUniform(mValueMat4, getUniformFromIndex(index), v) || count > 1) + { + glUniformMatrix3x4fv(mUniform[index], count, transpose, v); + } + } + void uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v) + { + if (updateUniform(mValueMat4, getUniformFromIndex(index), v) || count > 1) + { + glUniformMatrix4fvARB(mUniform[index], count, transpose, v); + } + } + void uniform1i(const LLStaticHashedString& uniform, GLint i) + { + GLint location = getUniformLocation(uniform); + if (location < 0) + return; + F32 val = i; + if (updateUniform(mValueVec4, getUniformLocation(uniform), &val)) + { + glUniform1iARB(location, i); + } + } + void uniform1f(const LLStaticHashedString& uniform, GLfloat v) + { + GLint location = getUniformLocation(uniform); + if (location < 0) + return; + if (updateUniform(mValueVec4, location, &v)) + { + glUniform1fARB(location, v); + } + } + void uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y) + { + GLint location = getUniformLocation(uniform); + if (location < 0) + return; + F32 val[] = { x, y }; + if (updateUniform(mValueVec4, location, val)) + { + glUniform2fARB(location, x, y); + } + } + void uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z) + { + GLint location = getUniformLocation(uniform); + if (location < 0) + return; + F32 val[] = { x, y, z }; + if (updateUniform(mValueVec4, location, val)) + { + glUniform3fARB(location, x, y, z); + } + } + void uniform1fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v) + { + GLint location = getUniformLocation(uniform); + if (location < 0) + return; + if (updateUniform(mValueVec4, location, v)) + { + glUniform1fvARB(location, count, v); + } + } + void uniform2fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v) + { + GLint location = getUniformLocation(uniform); + if (location < 0) + return; + if (updateUniform(mValueVec4, location, v)) + { + glUniform2fvARB(location, count, v); + } + } + void uniform3fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v) + { + GLint location = getUniformLocation(uniform); + if (location < 0) + return; + if (updateUniform(mValueVec4, location, v)) + { + glUniform3fvARB(location, count, v); + } + } + void uniform4fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v) + { + GLint location = getUniformLocation(uniform); + if (location < 0) + return; + if (updateUniform(mValueVec4, location, v)) + { + glUniform4fvARB(location, count, v); + } + } + void uniformMatrix4fv(const LLStaticHashedString& uniform, U32 count, GLboolean transpose, const GLfloat *v) + { + GLint location = getUniformLocation(uniform); + if (location < 0) + return; + if (updateUniform(mValueMat4, location, v)) + { + glUniformMatrix4fvARB(location, count, transpose, v); + } + } void setMinimumAlpha(F32 minimum); void vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - void vertexAttrib4fv(U32 index, GLfloat* v); - //GLint getUniformLocation(const std::string& uniform); - GLint getUniformLocation(const LLStaticHashedString& uniform); + GLint getUniformLocation(const LLStaticHashedString& uniform) + { + GLint ret = -1; + if (mProgramObject > 0) + { + LLStaticStringTable::iterator iter = mUniformMap.find(uniform); + if (iter != mUniformMap.end()) + { + if (gDebugGL) + { + stop_glerror(); + if (iter->second != glGetUniformLocationARB(mProgramObject, uniform.String().c_str())) + { + llerrs << "Uniform does not match." << llendl; + } + stop_glerror(); + } + ret = iter->second; + } + } + + return ret; + } GLint getUniformLocation(U32 index); GLint getAttribLocation(U32 attrib); @@ -156,9 +379,12 @@ public: U32 mAttributeMask; //mask of which reserved attributes are set (lines up with LLVertexBuffer::getTypeMask()) std::vector mUniform; //lookup table of uniform enum to uniform location LLStaticStringTable mUniformMap; //lookup map of uniform name to uniform location - std::map mUniformNameMap; //lookup map of uniform location to uniform name - std::map mValue; //lookup map of uniform location to last known value - std::vector mTexture; + //There are less naive ways to do this than just having several vectors for the differing types, but this method is of least complexity and has some inherent type-safety. + std::vector > mValueVec4; //lookup map of uniform location to last known value + std::vector > mValueMat3; //lookup map of uniform location to last known value + std::vector > mValueMat4; //lookup map of uniform location to last known value + + std::vector mTexture; //lookup table of texture uniform enum to texture channel S32 mTotalUniformSize; S32 mActiveTextureChannels; S32 mShaderClass; diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index a5fb16ee0..cda75e761 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -333,8 +333,8 @@ void LLImageGL::destroyGL(BOOL save_state) gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE); } - int stored_count = 0; sAllowReadBackRaw = true ; + std::set stored_images; for (std::set::iterator iter = sImageList.begin(); iter != sImageList.end(); iter++) { @@ -346,20 +346,21 @@ void LLImageGL::destroyGL(BOOL save_state) glimage->mSaveData = new LLImageRaw; if(!glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData, false)) //necessary, keep it. { - glimage->mSaveData = NULL ; + delete glimage; } else { glimage->mSaveDiscardLevel = glimage->mCurrentDiscardLevel; - stored_count++; + stored_images.insert(glimage); + glimage->destroyGLTexture(); } } - - glimage->destroyGLTexture(); + stop_glerror(); } } - llinfos << "Storing " << stored_count << " images..." << llendl; + sImageList = stored_images; + llinfos << "Storing " << stored_images.size() << " images..." << llendl; sAllowReadBackRaw = false ; } @@ -367,7 +368,7 @@ void LLImageGL::destroyGL(BOOL save_state) void LLImageGL::restoreGL() { - int recovered_count = 0; + std::set restored_images; for (std::set::iterator iter = sImageList.begin(); iter != sImageList.end(); iter++) { @@ -376,19 +377,22 @@ void LLImageGL::restoreGL() { llerrs << "tex name is not 0." << llendl ; } - if (glimage->mSaveData.notNull()) + if (glimage->mSaveData.notNull() && glimage->getComponents() && + glimage->mSaveData->getComponents() && + glimage->mSaveDiscardLevel >= 0 && + glimage->createGLTexture(glimage->mSaveDiscardLevel, glimage->mSaveData, 0, TRUE, glimage->getCategory())) { - if (glimage->getComponents() && glimage->mSaveData->getComponents() && glimage->mSaveDiscardLevel >= 0) - { - glimage->createGLTexture(glimage->mSaveDiscardLevel, glimage->mSaveData, 0, TRUE, glimage->getCategory()); stop_glerror(); - recovered_count++; - } - glimage->mSaveData = NULL; // deletes data - glimage->mSaveDiscardLevel = -1; + restored_images.insert(glimage); + } + else + { + delete glimage; } } - llinfos << "Restored " << recovered_count << " images" << llendl; + + restored_images = restored_images; + llinfos << "Restored " << restored_images.size() << " images" << llendl; } //static diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 5190f91ab..78de9749d 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1096,15 +1096,7 @@ void LLRender::init() glBindVertexArray(ret); #endif } - - llassert_always(mBuffer.isNull()) ; - stop_glerror(); - mBuffer = new LLVertexBuffer(immediate_mask, 0); - mBuffer->allocateBuffer(4096, 0, TRUE); - mBuffer->getVertexStrider(mVerticesp); - mBuffer->getTexCoord0Strider(mTexcoordsp); - mBuffer->getColorStrider(mColorsp); - stop_glerror(); + restoreVertexBuffers(); } void LLRender::shutdown() @@ -1148,6 +1140,23 @@ void LLRender::refreshState(void) mDirty = false; } +void LLRender::resetVertexBuffers() +{ + mBuffer = NULL; +} + +void LLRender::restoreVertexBuffers() +{ + llassert_always(mBuffer.isNull()); + stop_glerror(); + mBuffer = new LLVertexBuffer(immediate_mask, 0); + mBuffer->allocateBuffer(4096, 0, TRUE); + mBuffer->getVertexStrider(mVerticesp); + mBuffer->getTexCoord0Strider(mTexcoordsp); + mBuffer->getColorStrider(mColorsp); + stop_glerror(); +} + void LLRender::syncLightState() { LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 82e212370..cdadd5b03 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -346,6 +346,9 @@ public: // Needed when the render context has changed and invalidated the current state void refreshState(void); + void resetVertexBuffers(); + void restoreVertexBuffers(); + LLMatrix4a genRot(const GLfloat& a, const LLVector4a& axis) const; LLMatrix4a genRot(const GLfloat& a, const GLfloat& x, const GLfloat& y, const GLfloat& z) const { return genRot(a,LLVector4a(x,y,z)); } LLMatrix4a genOrtho(const GLfloat& left, const GLfloat& right, const GLfloat& bottom, const GLfloat& top, const GLfloat& znear, const GLfloat& zfar) const; diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index d23c520c7..b447813df 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -1056,6 +1056,10 @@ LLSpatialPartition* LLDrawable::getSpatialPartition() { setSpatialBridge(new LLHUDBridge(this)); } + else if (mVObjp->isAttachment()) + { + setSpatialBridge(new LLAttachmentBridge(this)); + } else { setSpatialBridge(new LLVolumeBridge(this)); @@ -1663,12 +1667,18 @@ void LLDrawable::updateFaceSize(S32 idx) LLBridgePartition::LLBridgePartition() : LLSpatialPartition(0, FALSE, 0) { - mDrawableType = LLPipeline::RENDER_TYPE_AVATAR; + mDrawableType = LLPipeline::RENDER_TYPE_VOLUME; mPartitionType = LLViewerRegion::PARTITION_BRIDGE; mLODPeriod = 16; mSlopRatio = 0.25f; } +LLAttachmentPartition::LLAttachmentPartition() +: LLBridgePartition() +{ + mDrawableType = LLPipeline::RENDER_TYPE_AVATAR; +} + LLHUDBridge::LLHUDBridge(LLDrawable* drawablep) : LLVolumeBridge(drawablep) { diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 3cacdce81..8d562db67 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -792,6 +792,7 @@ void LLSpatialGroup::shift(const LLVector4a &offset) if (!mSpatialPartition->mRenderByGroup && mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TREE && mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TERRAIN && + mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_ATTACHMENT && mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_BRIDGE) { setState(GEOM_DIRTY); @@ -2174,6 +2175,10 @@ public: for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i) { LLDrawable* drawable = *i; + if (drawable->getVObj().notNull()) + { + drawable->getVObj()->resetVertexBuffers(); + } if (drawable->getVObj().notNull() && !group->mSpatialPartition->mRenderByGroup) { gPipeline.markRebuild(drawable, LLDrawable::REBUILD_ALL, TRUE); diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 29f86656a..d47055057 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -737,6 +737,12 @@ public: virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count) { LLVolumeGeometryManager::addGeometryCount(group, vertex_count, index_count); } }; +class LLAttachmentBridge : public LLVolumeBridge +{ +public: + LLAttachmentBridge(LLDrawable* drawable); +}; + class LLHUDBridge : public LLVolumeBridge { public: @@ -754,11 +760,18 @@ public: virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count) { } }; +//spatial partition that holds nothing but spatial bridges +class LLAttachmentPartition : public LLBridgePartition +{ +public: + LLAttachmentPartition(); +}; + class LLHUDPartition : public LLBridgePartition { public: LLHUDPartition(); - virtual void shift(const LLVector4a &offset); + virtual void shift(const LLVector4a &offset) { } //HUD objects don't shift with region crossing. That would be silly. }; extern const F32 SG_BOX_SIDE; diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp index 0b855dcd3..1edfe1dd7 100644 --- a/indra/newview/llviewerjoystick.cpp +++ b/indra/newview/llviewerjoystick.cpp @@ -1162,7 +1162,7 @@ void LLViewerJoystick::moveFlycam(bool reset) // ----------------------------------------------------------------------------- bool LLViewerJoystick::toggleFlycam() { - if (gRlvHandler.hasBehaviour(RLV_BHVR_CAMDISTMAX) || (gRlvHandler.hasBehaviour(RLV_BHVR_CAMUNLOCK) // [RLVa:LF] - @camdistmax and @camunlock mean no going away! + if (gRlvHandler.hasBehaviour(RLV_BHVR_CAMDISTMAX) || gRlvHandler.hasBehaviour(RLV_BHVR_CAMUNLOCK) // [RLVa:LF] - @camdistmax and @camunlock mean no going away! || !gSavedSettings.getBOOL("JoystickEnabled") || !gSavedSettings.getBOOL("JoystickFlycamEnabled")) { mOverrideCamera = false; diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index d0f86260f..4b498507e 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -133,6 +133,7 @@ public: LLViewerObject(const LLUUID &id, const LLPCode type, LLViewerRegion *regionp, BOOL is_global = FALSE); + virtual void resetVertexBuffers() {} virtual void markDead(); // Mark this object as dead, and clean up its references BOOL isDead() const {return mDead;} BOOL isOrphaned() const { return mOrphaned; } diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index c502eab4f..aae1fc4bb 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -380,6 +380,7 @@ void LLViewerRegion::initPartitions() mImpl->mObjectPartition.push_back(new LLGrassPartition()); //PARTITION_GRASS mImpl->mObjectPartition.push_back(new LLVolumePartition()); //PARTITION_VOLUME mImpl->mObjectPartition.push_back(new LLBridgePartition()); //PARTITION_BRIDGE + mImpl->mObjectPartition.push_back(new LLAttachmentPartition()); //PARTITION_ATTACHMENT mImpl->mObjectPartition.push_back(new LLHUDParticlePartition());//PARTITION_HUD_PARTICLE mImpl->mObjectPartition.push_back(NULL); //PARTITION_NONE } diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 07d4fcca4..c74d9bc5a 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -99,6 +99,7 @@ public: PARTITION_GRASS, PARTITION_VOLUME, PARTITION_BRIDGE, + PARTITION_ATTACHMENT, PARTITION_HUD_PARTICLE, PARTITION_NONE, NUM_PARTITIONS diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 77530b9f8..8fa766d29 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1737,7 +1737,6 @@ LLViewerWindow::LLViewerWindow( } LLVertexBuffer::initClass(gSavedSettings.getBOOL("RenderVBOEnable"), gSavedSettings.getBOOL("RenderVBOMappingDisable")); LL_INFOS("RenderInit") << "LLVertexBuffer initialization done." << LL_ENDL ; - gGL.init() ; LLImageGL::initClass(LLViewerTexture::MAX_GL_IMAGE_CATEGORY) ; if (LLFeatureManager::getInstance()->isSafe() @@ -5307,6 +5306,8 @@ void LLViewerWindow::stopGL(BOOL save_state) gGLManager.mIsDisabled = TRUE; stop_glerror(); + + gGL.resetVertexBuffers(); llinfos << "Remaining allocated texture memory: " << LLImageGL::sGlobalTextureMemoryInBytes << " bytes" << llendl; } @@ -5323,6 +5324,7 @@ void LLViewerWindow::restoreGL(const std::string& progress_message) llinfos << "Restoring GL..." << llendl; gGLManager.mIsDisabled = FALSE; + gGL.init(); initGLDefaults(); gGL.refreshState(); //Singu Note: Call immediately. Cached states may have prevented initGLDefaults from actually applying changes. LLGLState::restoreGL(); diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index ec38349f9..25e554a8a 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -9029,7 +9029,7 @@ void LLVOAvatar::updateSoftwareSkinnedVertices(const LLMeshSkinInfo* skin, const U32 LLVOAvatar::getPartitionType() const { // Avatars merely exist as drawables in the bridge partition - return LLViewerRegion::PARTITION_BRIDGE; + return LLViewerRegion::PARTITION_ATTACHMENT; } //static diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 83f8d9388..48095c205 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -1516,10 +1516,10 @@ BOOL LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 f, cons *indicesp++ = index_offset + 2; *indicesp++ = index_offset + 3; - *(colorsp++) = LLColor4::white; - *(colorsp++) = LLColor4::white; - *(colorsp++) = LLColor4::white; - *(colorsp++) = LLColor4::white; + *(colorsp++) = LLColor4U::white; + *(colorsp++) = LLColor4U::white; + *(colorsp++) = LLColor4U::white; + *(colorsp++) = LLColor4U::white; facep->getVertexBuffer()->flush(); diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index 844562644..a10eadf14 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -550,6 +550,11 @@ const S32 LEAF_VERTICES = 16; static LLFastTimer::DeclareTimer FTM_UPDATE_TREE("Update Tree"); +void LLVOTree::resetVertexBuffers() +{ + mReferenceBuffer = NULL; +} + BOOL LLVOTree::updateGeometry(LLDrawable *drawable) { LLFastTimer ftm(FTM_UPDATE_TREE); diff --git a/indra/newview/llvotree.h b/indra/newview/llvotree.h index 7fc46e0b9..482434a57 100644 --- a/indra/newview/llvotree.h +++ b/indra/newview/llvotree.h @@ -77,6 +77,7 @@ public: /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); /*virtual*/ void updateSpatialExtents(LLVector4a &min, LLVector4a &max); + void resetVertexBuffers(); virtual U32 getPartitionType() const; void updateRadius(); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index e25bc88b1..6b4453d26 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4000,6 +4000,10 @@ U32 LLVOVolume::getPartitionType() const { return LLViewerRegion::PARTITION_HUD; } + else if (isAttachment()) + { + return LLViewerRegion::PARTITION_ATTACHMENT; + } return LLViewerRegion::PARTITION_VOLUME; } @@ -4028,6 +4032,12 @@ LLVolumeBridge::LLVolumeBridge(LLDrawable* drawablep) mSlopRatio = 0.25f; } +LLAttachmentBridge::LLAttachmentBridge(LLDrawable* drawablep) + : LLVolumeBridge(drawablep) +{ + mPartitionType = LLViewerRegion::PARTITION_ATTACHMENT; +} + bool can_batch_texture(const LLFace* facep) { static const LLCachedControl alt_batching("SHAltBatching",true); @@ -5209,29 +5219,22 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) //PROCESS NON-ALPHA FACES U32 simple_mask = LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR; U32 alpha_mask = simple_mask | 0x80000000; //hack to give alpha verts their own VBO - U32 bump_mask = simple_mask | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TANGENT; + U32 bump_mask = simple_mask | LLVertexBuffer::MAP_TEXCOORD1; U32 fullbright_mask = LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR; U32 norm_mask = simple_mask | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TANGENT; U32 normspec_mask = norm_mask | LLVertexBuffer::MAP_TEXCOORD2; U32 spec_mask = simple_mask | LLVertexBuffer::MAP_TEXCOORD2; - if (emissive) - { //emissive faces are present, include emissive byte to preserve batching - simple_mask = simple_mask | LLVertexBuffer::MAP_EMISSIVE; - alpha_mask = alpha_mask | LLVertexBuffer::MAP_EMISSIVE; - bump_mask = bump_mask | LLVertexBuffer::MAP_EMISSIVE; - fullbright_mask = fullbright_mask | LLVertexBuffer::MAP_EMISSIVE; - norm_mask = norm_mask | LLVertexBuffer::MAP_EMISSIVE; - normspec_mask = normspec_mask | LLVertexBuffer::MAP_EMISSIVE; - spec_mask = spec_mask | LLVertexBuffer::MAP_EMISSIVE; - } - BOOL batch_textures = LLGLSLShader::sNoFixedFunction; U32 additional_flags = 0x0; if(batch_textures) additional_flags |= LLVertexBuffer::MAP_TEXTURE_INDEX; + if (LLPipeline::sRenderDeferred) + bump_mask = norm_mask; + + //emissive faces are present, include emissive byte to preserve batching if(emissive) additional_flags |= LLVertexBuffer::MAP_EMISSIVE; @@ -6390,9 +6393,4 @@ LLHUDPartition::LLHUDPartition() mLODPeriod = 1; } -void LLHUDPartition::shift(const LLVector4a &offset) -{ - //HUD objects don't shift with region crossing. That would be silly. -} - diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f58a7faf7..a5c727df9 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -491,6 +491,8 @@ void LLPipeline::init() gSavedSettings.getControl("RenderFSAASamples")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings)); //gSavedSettings.getControl("RenderAvatarVP")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings)); //Already registered to handleSetShaderChanged //gSavedSettings.getControl("WindLightUseAtmosShaders")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings)); //Already registered to handleSetShaderChanged + + gGL.init(); } LLPipeline::~LLPipeline() @@ -1206,10 +1208,7 @@ void LLPipeline::restoreGL() { assertInitialized(); - if (LLGLSLShader::sNoFixedFunction) - { - LLViewerShaderMgr::instance()->setShaders(); - } + LLViewerShaderMgr::instance()->setShaders(); for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) @@ -1291,11 +1290,13 @@ S32 LLPipeline::setLightingDetail(S32 level) } level = llclamp(level, 0, getMaxLightingDetail()); //Bugfix: If setshaders was called with RenderLocalLights off then enabling RenderLocalLights later will not work. Reloading shaders fixes this. - if (level != mLightingDetail && LLGLSLShader::sNoFixedFunction) + if (level != mLightingDetail) { - LLViewerShaderMgr::instance()->setShaders(); + mLightingDetail = level; + if (LLGLSLShader::sNoFixedFunction) + LLViewerShaderMgr::instance()->setShaders(); } - mLightingDetail = level; + return mLightingDetail; } @@ -6495,6 +6496,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, for (U32 j = 0; j < LLViewerRegion::NUM_PARTITIONS; j++) { if ((j == LLViewerRegion::PARTITION_VOLUME) || + (j == LLViewerRegion::PARTITION_ATTACHMENT) || (j == LLViewerRegion::PARTITION_BRIDGE) || (j == LLViewerRegion::PARTITION_TERRAIN) || (j == LLViewerRegion::PARTITION_TREE) || @@ -6557,7 +6559,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, { LLViewerRegion* region = *iter; - LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_BRIDGE); + LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_ATTACHMENT); if (part && hasRenderType(part->mDrawableType)) { LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, face_hit, &position, tex_coord, normal, tangent); @@ -6743,6 +6745,8 @@ void LLPipeline::doResetVertexBuffers() //delete all name pool caches LLGLNamePool::cleanupPools(); + gGL.resetVertexBuffers(); + if (LLVertexBuffer::sGLCount > 0) { llwarns << "VBO wipe failed -- " << LLVertexBuffer::sGLCount << " buffers remaining." << llendl; @@ -6762,6 +6766,8 @@ void LLPipeline::doResetVertexBuffers() LLVertexBuffer::initClass(LLVertexBuffer::sEnableVBOs, LLVertexBuffer::sDisableVBOMapping); LLVOPartGroup::restoreGL(); + + gGL.restoreVertexBuffers(); } void LLPipeline::renderObjects(U32 type, U32 mask, BOOL texture, BOOL batch_texture)