summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2018-06-01 23:32:30 +0100
committerGraham Linden <graham@lindenlab.com>2018-06-01 23:32:30 +0100
commit8cfdc07e790a557e881fadaa1b6258e5b16751f4 (patch)
treea792d0e6f03886f4a3d8f064811fdcbbf2ce1a61 /indra/llrender
parent8dd85013865cc5b426234cd71b605d7208bcfe01 (diff)
Code cleanup and move to using typedefs of S64Seconds/F64Seconds for ease in sync w/ sim side which has not llunits types.
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/llglslshader.cpp332
-rw-r--r--indra/llrender/llglslshader.h33
-rw-r--r--indra/llrender/llrender.cpp2
-rw-r--r--indra/llrender/llrender.h7
-rw-r--r--indra/llrender/llshadermgr.cpp4
-rw-r--r--indra/llrender/llshadermgr.h5
-rw-r--r--indra/llrender/llvertexbuffer.cpp2
7 files changed, 219 insertions, 166 deletions
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index b027a24017..37bcf0c163 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -157,7 +157,8 @@ void LLGLSLShader::clearStats()
mSamplesDrawn = 0;
mDrawCalls = 0;
mTextureStateFetched = false;
- mTextureMagMinFilter.clear();
+ mTextureMagFilter.clear();
+ mTextureMinFilter.clear();
}
void LLGLSLShader::dumpStats()
@@ -170,16 +171,14 @@ void LLGLSLShader::dumpStats()
{
LL_INFOS() << mShaderFiles[i].first << LL_ENDL;
}
- for (uniforms_index_t::iterator it = mTexture.begin(); it != mTexture.end(); ++it)
+ for (U32 i = 0; i < mTexture.size(); ++i)
{
- S32 i = (*it).first;
- GLint idx = (*it).second;
+ GLint idx = mTexture[i];
if (idx >= 0)
{
GLint uniform_idx = getUniformLocation(i);
- magmin_filter_t::iterator it = mTextureMagMinFilter.find(i);
- LL_INFOS() << mUniformNameMap[uniform_idx] << " - " << std::hex << (*it).second.second << "/" << (*it).second.first << std::dec << LL_ENDL;
+ LL_INFOS() << mUniformNameMap[uniform_idx] << " - " << std::hex << mTextureMagFilter[i] << "/" << mTextureMinFilter[i] << std::dec << LL_ENDL;
}
}
LL_INFOS() << "=============================================" << LL_ENDL;
@@ -236,13 +235,14 @@ void LLGLSLShader::placeProfileQuery()
if (!mTextureStateFetched)
{
mTextureStateFetched = true;
+ mTextureMagFilter.resize(mTexture.size());
+ mTextureMinFilter.resize(mTexture.size());
U32 cur_active = gGL.getCurrentTexUnitIndex();
- for (uniforms_index_t::iterator it = mTexture.begin(); it != mTexture.end(); ++it)
+ for (U32 i = 0; i < mTexture.size(); ++i)
{
- S32 i = (*it).first;
- GLint idx = (*it).second;
+ GLint idx = mTexture[i];
if (idx >= 0)
{
@@ -256,7 +256,8 @@ void LLGLSLShader::placeProfileQuery()
glGetTexParameteriv(type, GL_TEXTURE_MAG_FILTER, (GLint*) &mag);
glGetTexParameteriv(type, GL_TEXTURE_MIN_FILTER, (GLint*) &min);
- mTextureMagMinFilter[i] = magmin_values_t(mag, min);
+ mTextureMagFilter[i] = mag;
+ mTextureMinFilter[i] = min;
}
}
@@ -414,7 +415,7 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes,
for ( ; fileIter != mShaderFiles.end(); fileIter++ )
{
GLhandleARB shaderhandle = LLShaderMgr::instance()->loadShaderFile((*fileIter).first, mShaderLevel, (*fileIter).second, &mDefines, mFeatures.mIndexedTextureChannels);
- LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << " shaderhandle=" << shaderhandle << LL_ENDL;
+ LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << LL_ENDL;
if (shaderhandle)
{
attachObject(shaderhandle);
@@ -477,14 +478,13 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes,
}
S32 cur_tex = channel_count; //adjust any texture channels that might have been overwritten
- for (uniforms_index_t::iterator it = mTexture.begin(); it != mTexture.end(); ++it)
+ for (U32 i = 0; i < mTexture.size(); i++)
{
- int i = (*it).first;
- if (((*it).second >= 0) && ((*it).second < channel_count))
+ if (mTexture[i] > -1 && mTexture[i] < channel_count)
{
llassert(cur_tex < gGLManager.mNumTextureImageUnits);
uniform1i(i, cur_tex);
- (*it).second = cur_tex++;
+ mTexture[i] = cur_tex++;
}
}
unbind();
@@ -545,7 +545,11 @@ BOOL LLGLSLShader::mapAttributes(const std::vector<LLStaticHashedString> * attri
mAttribute.clear();
U32 numAttributes = (attributes == NULL) ? 0 : attributes->size();
+#if LL_RELEASE_WITH_DEBUG_INFO
+ mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size() + numAttributes, { -1, NULL });
+#else
mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size() + numAttributes, -1);
+#endif
if (res)
{ //read back channel locations
@@ -559,7 +563,11 @@ BOOL LLGLSLShader::mapAttributes(const std::vector<LLStaticHashedString> * attri
S32 index = glGetAttribLocationARB(mProgramObject, (const GLcharARB *)name);
if (index != -1)
{
+#if LL_RELEASE_WITH_DEBUG_INFO
+ mAttribute[i] = { index, name };
+#else
mAttribute[i] = index;
+#endif
mAttributeMask |= 1 << i;
LL_DEBUGS("ShaderLoading") << "Attribute " << name << " assigned to channel " << index << LL_ENDL;
}
@@ -659,20 +667,17 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString> *
mUniformMap[hashedName] = location;
LL_DEBUGS("ShaderLoading") << "Uniform " << name << " is at location " << location << LL_ENDL;
-
+
//find the index of this uniform
for (S32 i = 0; i < (S32) LLShaderMgr::instance()->mReservedUniforms.size(); i++)
{
- if (LLShaderMgr::instance()->mReservedUniforms[i] == name)
+ if ( (mUniform[i] == -1)
+ && (LLShaderMgr::instance()->mReservedUniforms[i] == name))
{
- std::pair<uniforms_index_t::iterator, bool> result;
-
- result = mUniform.insert(uniforms_index_t::value_type(i, location));
- if (result.second)
- {
- mTexture[i] = mapUniformTextureChannel(location, type);
- return;
- }
+ //found it
+ mUniform[i] = location;
+ mTexture[i] = mapUniformTextureChannel(location, type);
+ return;
}
}
@@ -680,17 +685,13 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString> *
{
for (U32 i = 0; i < uniforms->size(); i++)
{
- std::pair<uniforms_index_t::iterator, bool> result;
- S32 index = i + LLShaderMgr::instance()->mReservedUniforms.size();
-
- if ((*uniforms)[i] == hashedName)
+ if ( (mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] == -1)
+ && ((*uniforms)[i].String() == name))
{
- result = mUniform.insert(uniforms_index_t::value_type(index, location));
- if (result.second)
- {
- mTexture[index] = mapUniformTextureChannel(location, type);
- return;
- }
+ //found it
+ mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] = location;
+ mTexture[i+LLShaderMgr::instance()->mReservedUniforms.size()] = mapUniformTextureChannel(location, type);
+ return;
}
}
}
@@ -730,6 +731,10 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)
mUniformNameMap.clear();
mTexture.clear();
mValue.clear();
+ //initialize arrays
+ U32 numUniforms = (uniforms == NULL) ? 0 : uniforms->size();
+ mUniform.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1);
+ mTexture.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1);
bind();
@@ -929,14 +934,20 @@ S32 LLGLSLShader::bindTexture(const std::string &uniform, LLTexture *texture, LL
S32 LLGLSLShader::bindTexture(S32 uniform, LLTexture *texture, LLTexUnit::eTextureType mode)
{
- GLint channel = getTexChannelForIndex(uniform);
+ if (uniform < 0 || uniform >= (S32)mTexture.size())
+ {
+ UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL;
+ return -1;
+ }
- if (channel > -1)
+ uniform = mTexture[uniform];
+
+ if (uniform > -1)
{
- gGL.getTexUnit(channel)->bind(texture, mode);
+ gGL.getTexUnit(uniform)->bind(texture, mode);
}
- return channel;
+ return uniform;
}
S32 LLGLSLShader::unbindTexture(const std::string &uniform, LLTexUnit::eTextureType mode)
@@ -949,64 +960,82 @@ S32 LLGLSLShader::unbindTexture(const std::string &uniform, LLTexUnit::eTextureT
S32 LLGLSLShader::unbindTexture(S32 uniform, LLTexUnit::eTextureType mode)
{
- GLint channel = getTexChannelForIndex(uniform);
-
- if (channel > -1)
+ if (uniform < 0 || uniform >= (S32)mTexture.size())
{
- gGL.getTexUnit(channel)->unbind(mode);
+ UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL;
+ return -1;
+ }
+
+ uniform = mTexture[uniform];
+
+ if (uniform > -1)
+ {
+ gGL.getTexUnit(uniform)->unbind(mode);
}
- return channel;
+ return uniform;
}
S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode)
{
- GLint channel = getTexChannelForIndex(uniform);
-
- if (channel != -1)
+ if (uniform < 0 || uniform >= (S32)mTexture.size())
+ {
+ UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL;
+ return -1;
+ }
+ S32 index = mTexture[uniform];
+ if (index != -1)
{
- gGL.getTexUnit(channel)->activate();
- gGL.getTexUnit(channel)->enable(mode);
+ gGL.getTexUnit(index)->activate();
+ gGL.getTexUnit(index)->enable(mode);
}
- return channel;
+ return index;
}
S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode)
{
- GLint channel = getTexChannelForIndex(uniform);
-
- if (channel != -1 && gGL.getTexUnit(channel)->getCurrType() != LLTexUnit::TT_NONE)
+ if (uniform < 0 || uniform >= (S32)mTexture.size())
+ {
+ UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL;
+ return -1;
+ }
+ S32 index = mTexture[uniform];
+ if (index != -1 && gGL.getTexUnit(index)->getCurrType() != LLTexUnit::TT_NONE)
{
- if (gDebugGL && gGL.getTexUnit(channel)->getCurrType() != mode)
+ if (gDebugGL && gGL.getTexUnit(index)->getCurrType() != mode)
{
if (gDebugSession)
{
- gFailLog << "Texture channel " << channel << " texture type corrupted." << std::endl;
+ gFailLog << "Texture channel " << index << " texture type corrupted." << std::endl;
ll_fail("LLGLSLShader::disableTexture failed");
}
else
{
- LL_ERRS() << "Texture channel " << channel << " texture type corrupted." << LL_ENDL;
+ LL_ERRS() << "Texture channel " << index << " texture type corrupted." << LL_ENDL;
}
}
- gGL.getTexUnit(channel)->disable();
+ gGL.getTexUnit(index)->disable();
}
- return channel;
+ return index;
}
void LLGLSLShader::uniform1i(U32 index, GLint x)
{
if (mProgramObject)
{
- GLint location = getLocationForIndex(index);
+ if (mUniform.size() <= index)
+ {
+ UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+ return;
+ }
- if (location >= 0)
+ if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
if (iter == mValue.end() || iter->second.mV[0] != x)
{
- glUniform1iARB(location, x);
- mValue[location] = LLVector4(x,0.f,0.f,0.f);
+ glUniform1iARB(mUniform[index], x);
+ mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f);
}
}
}
@@ -1016,15 +1045,19 @@ void LLGLSLShader::uniform1f(U32 index, GLfloat x)
{
if (mProgramObject)
{
- GLint location = getLocationForIndex(index);
+ if (mUniform.size() <= index)
+ {
+ UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+ return;
+ }
- if (location >= 0)
+ if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
if (iter == mValue.end() || iter->second.mV[0] != x)
{
- glUniform1fARB(location, x);
- mValue[location] = LLVector4(x,0.f,0.f,0.f);
+ glUniform1fARB(mUniform[index], x);
+ mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f);
}
}
}
@@ -1034,16 +1067,20 @@ void LLGLSLShader::uniform2f(U32 index, GLfloat x, GLfloat y)
{
if (mProgramObject)
{
- GLint location = getLocationForIndex(index);
+ if (mUniform.size() <= index)
+ {
+ UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+ return;
+ }
- if (location >= 0)
+ if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
LLVector4 vec(x,y,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
- glUniform2fARB(location, x, y);
- mValue[location] = vec;
+ glUniform2fARB(mUniform[index], x, y);
+ mValue[mUniform[index]] = vec;
}
}
}
@@ -1053,16 +1090,20 @@ void LLGLSLShader::uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z)
{
if (mProgramObject)
{
- GLint location = getLocationForIndex(index);
+ if (mUniform.size() <= index)
+ {
+ UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+ return;
+ }
- if (location >= 0)
+ if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
LLVector4 vec(x,y,z,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
- glUniform3fARB(location, x, y, z);
- mValue[location] = vec;
+ glUniform3fARB(mUniform[index], x, y, z);
+ mValue[mUniform[index]] = vec;
}
}
}
@@ -1072,16 +1113,20 @@ void LLGLSLShader::uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat
{
if (mProgramObject)
{
- GLint location = getLocationForIndex(index);
+ if (mUniform.size() <= index)
+ {
+ UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+ return;
+ }
- if (location >= 0)
+ if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
LLVector4 vec(x,y,z,w);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
- glUniform4fARB(location, x, y, z, w);
- mValue[location] = vec;
+ glUniform4fARB(mUniform[index], x, y, z, w);
+ mValue[mUniform[index]] = vec;
}
}
}
@@ -1091,16 +1136,20 @@ void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v)
{
if (mProgramObject)
{
- GLint location = getLocationForIndex(index);
+ if (mUniform.size() <= index)
+ {
+ UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+ return;
+ }
- if (location >= 0)
+ if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ std::map<GLint, LLVector4>::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(location, count, v);
- mValue[location] = vec;
+ glUniform1ivARB(mUniform[index], count, v);
+ mValue[mUniform[index]] = vec;
}
}
}
@@ -1110,16 +1159,20 @@ void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v)
{
if (mProgramObject)
{
- GLint location = getLocationForIndex(index);
+ if (mUniform.size() <= index)
+ {
+ UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+ return;
+ }
- if (location >= 0)
+ if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ std::map<GLint, LLVector4>::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(location, count, v);
- mValue[location] = vec;
+ glUniform1fvARB(mUniform[index], count, v);
+ mValue[mUniform[index]] = vec;
}
}
}
@@ -1129,16 +1182,20 @@ void LLGLSLShader::uniform2fv(U32 index, U32 count, const GLfloat* v)
{
if (mProgramObject)
{
- GLint location = getLocationForIndex(index);
+ if (mUniform.size() <= index)
+ {
+ UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+ return;
+ }
- if (location >= 0)
+ if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ std::map<GLint, LLVector4>::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(location, count, v);
- mValue[location] = vec;
+ glUniform2fvARB(mUniform[index], count, v);
+ mValue[mUniform[index]] = vec;
}
}
}
@@ -1148,16 +1205,20 @@ void LLGLSLShader::uniform3fv(U32 index, U32 count, const GLfloat* v)
{
if (mProgramObject)
{
- GLint location = getLocationForIndex(index);
+ if (mUniform.size() <= index)
+ {
+ UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+ return;
+ }
- if (location >= 0)
+ if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ std::map<GLint, LLVector4>::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(location, count, v);
- mValue[location] = vec;
+ glUniform3fvARB(mUniform[index], count, v);
+ mValue[mUniform[index]] = vec;
}
}
}
@@ -1167,16 +1228,20 @@ void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v)
{
if (mProgramObject)
{
- GLint location = getLocationForIndex(index);
+ if (mUniform.size() <= index)
+ {
+ UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+ return;
+ }
- if (location >= 0)
+ if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ std::map<GLint, LLVector4>::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(location, count, v);
- mValue[location] = vec;
+ glUniform4fvARB(mUniform[index], count, v);
+ mValue[mUniform[index]] = vec;
}
}
}
@@ -1186,11 +1251,15 @@ void LLGLSLShader::uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, c
{
if (mProgramObject)
{
- GLint location = getLocationForIndex(index);
+ if (mUniform.size() <= index)
+ {
+ UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+ return;
+ }
- if (location >= 0)
+ if (mUniform[index] >= 0)
{
- glUniformMatrix2fvARB(location, count, transpose, v);
+ glUniformMatrix2fvARB(mUniform[index], count, transpose, v);
}
}
}
@@ -1199,11 +1268,15 @@ void LLGLSLShader::uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, c
{
if (mProgramObject)
{
- GLint location = getLocationForIndex(index);
+ if (mUniform.size() <= index)
+ {
+ UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+ return;
+ }
- if (location >= 0)
+ if (mUniform[index] >= 0)
{
- glUniformMatrix3fvARB(location, count, transpose, v);
+ glUniformMatrix3fvARB(mUniform[index], count, transpose, v);
}
}
}
@@ -1212,11 +1285,15 @@ void LLGLSLShader::uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose,
{
if (mProgramObject)
{
- GLint location = getLocationForIndex(index);
+ if (mUniform.size() <= index)
+ {
+ UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+ return;
+ }
- if (location >= 0)
+ if (mUniform[index] >= 0)
{
- glUniformMatrix3x4fv(location, count, transpose, v);
+ glUniformMatrix3x4fv(mUniform[index], count, transpose, v);
}
}
}
@@ -1225,10 +1302,15 @@ void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, c
{
if (mProgramObject)
{
- GLint location = getLocationForIndex(index);
- if (location >= 0)
+ if (mUniform.size() <= index)
+ {
+ UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+ return;
+ }
+
+ if (mUniform[index] >= 0)
{
- glUniformMatrix4fvARB(location, count, transpose, v);
+ glUniformMatrix4fvARB(mUniform[index], count, transpose, v);
}
}
}
@@ -1259,8 +1341,14 @@ GLint LLGLSLShader::getUniformLocation(const LLStaticHashedString& uniform)
GLint LLGLSLShader::getUniformLocation(U32 index)
{
- /*TODO: flatten this... change calls to gUL(U32) */
- return getLocationForIndex(index);
+ GLint ret = -1;
+ if (mProgramObject)
+ {
+ llassert(index < mUniform.size());
+ return mUniform[index];
+ }
+
+ return ret;
}
GLint LLGLSLShader::getAttribLocation(U32 attrib)
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index 59edd7b36f..0934ceba30 100644
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -169,11 +169,6 @@ public:
U32 mMatHash[LLRender::NUM_MATRIX_MODES];
U32 mLightHash;
- typedef std::map<S32, GLint> uniforms_index_t;
- typedef std::pair<U32, U32> magmin_values_t;
-
- typedef std::map < S32, magmin_values_t> magmin_filter_t;
-
GLhandleARB mProgramObject;
#if LL_RELEASE_WITH_DEBUG_INFO
struct attr_name
@@ -188,12 +183,11 @@ public:
std::vector<GLint> mAttribute; //lookup table of attribute enum to attribute channel
#endif
U32 mAttributeMask; //mask of which reserved attributes are set (lines up with LLVertexBuffer::getTypeMask())
- uniforms_index_t mUniform;
- uniforms_index_t mTexture;
-
+ std::vector<GLint> mUniform; //lookup table of uniform enum to uniform location
LLStaticStringTable<GLint> mUniformMap; //lookup map of uniform name to uniform location
std::map<GLint, std::string> mUniformNameMap; //lookup map of uniform location to uniform name
std::map<GLint, LLVector4> mValue; //lookup map of uniform location to last known value
+ std::vector<GLint> mTexture;
S32 mTotalUniformSize;
S32 mActiveTextureChannels;
S32 mShaderLevel;
@@ -217,32 +211,13 @@ public:
static U32 sTotalDrawCalls;
bool mTextureStateFetched;
- magmin_filter_t mTextureMagMinFilter;
+ std::vector<U32> mTextureMagFilter;
+ std::vector<U32> mTextureMinFilter;
GLhandleARB mExtraLinkObject = 0;
private:
void unloadInternal();
-
- inline GLint getLocationForIndex(S32 index)
- {
- if (!mProgramObject)
- return -1;
- uniforms_index_t::iterator it = mUniform.find(index);
- if (it == mUniform.end())
- return -1;
- return (*it).second;
- }
-
- inline GLint getTexChannelForIndex(S32 index)
- {
- if (!mProgramObject)
- return -1;
- uniforms_index_t::iterator it = mTexture.find(index);
- if (it == mTexture.end())
- return -1;
- return (*it).second;
- }
};
//UI shader (declared here so llui_libtest will link properly)
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 9067a17baf..5e16aded30 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -1267,7 +1267,7 @@ void LLRender::syncMatrices()
}
shader->uniformMatrix4fv(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX, 1, GL_FALSE, cached_mvp.m);
- }
+ }
}
i = MM_PROJECTION;
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index ceebc7000b..1bc5e89eac 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -446,7 +446,7 @@ public:
static U32 sUICalls;
static U32 sUIVerts;
static bool sGLCoreProfile;
- static bool sNsightDebugSupport;
+ static bool sNsightDebugSupport;
private:
friend class LLLightState;
@@ -503,11 +503,6 @@ const F32 OGL_TO_CFR_ROTATION[16] = { 0.f, 0.f, -1.f, 0.f, // -Z becomes X
0.f, 1.f, 0.f, 0.f, // Y becomes Z
0.f, 0.f, 0.f, 1.f };
-const F32 XYZ_TO_OGL_ROTATION[16] = { 1.f, 0.f, 0.f, 0.f, // X stays X
- 0.f, 0.f, -1.f, 0.f, // Z becomes -Y
- 0.f, 1.f, 0.f, 0.f, // Y becomes Z
- 0.f, 0.f, 0.f, 1.f };
-
glh::matrix4f copy_matrix(F32* src);
glh::matrix4f get_current_modelview();
glh::matrix4f get_current_projection();
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index 544a4f00aa..1eb1cb56a8 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -985,7 +985,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
// Add shader file to map
mShaderObjects[filename] = ret;
shader_level = try_gpu_class;
- }
+ }
else
{
if (shader_level > 1)
@@ -1150,7 +1150,7 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("cloud_noise_texture");
mReservedUniforms.push_back("fullbright");
mReservedUniforms.push_back("lightnorm");
- mReservedUniforms.push_back("sunlight_color");
+ mReservedUniforms.push_back("sunlight_color_copy");
mReservedUniforms.push_back("ambient");
mReservedUniforms.push_back("blue_horizon");
mReservedUniforms.push_back("blue_density");
diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h
index fa2a9f03be..9919dbe31a 100644
--- a/indra/llrender/llshadermgr.h
+++ b/indra/llrender/llshadermgr.h
@@ -30,11 +30,6 @@
#include "llgl.h"
#include "llglslshader.h"
-/*RIDER: TODO:
- * This should use the LL Singleton<> template... but not a quick conversion.
- * (llviewershadermgr derives from this)
- */
-
class LLShaderMgr
{
public:
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index a33f84518f..e3e605d040 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -198,7 +198,7 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed)
}
else
{ //always use a true hint of static draw when allocating non-client-backed buffers
- glBufferDataARB(mType, size, 0, GL_STATIC_DRAW_ARB);
+ glBufferDataARB(mType, size, 0, GL_STATIC_DRAW_ARB);
}
glBindBufferARB(mType, 0);