summaryrefslogtreecommitdiff
path: root/indra/llrender/llglslshader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender/llglslshader.cpp')
-rw-r--r--indra/llrender/llglslshader.cpp231
1 files changed, 169 insertions, 62 deletions
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 4351f6e2c8..a52dcd5aa1 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -50,7 +50,6 @@ using std::string;
GLhandleARB LLGLSLShader::sCurBoundShader = 0;
LLGLSLShader* LLGLSLShader::sCurBoundShaderPtr = NULL;
S32 LLGLSLShader::sIndexedTextureChannels = 0;
-bool LLGLSLShader::sNoFixedFunction = false;
bool LLGLSLShader::sProfileEnabled = false;
std::set<LLGLSLShader*> LLGLSLShader::sInstances;
U64 LLGLSLShader::sTotalTimeElapsed = 0;
@@ -208,6 +207,7 @@ void LLGLSLShader::dumpStats()
//static
void LLGLSLShader::startProfile()
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
if (sProfileEnabled && sCurBoundShaderPtr)
{
sCurBoundShaderPtr->placeProfileQuery();
@@ -218,6 +218,7 @@ void LLGLSLShader::startProfile()
//static
void LLGLSLShader::stopProfile(U32 count, U32 mode)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
if (sProfileEnabled && sCurBoundShaderPtr)
{
sCurBoundShaderPtr->readProfileQuery(count, mode);
@@ -384,6 +385,8 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes,
U32 varying_count,
const char** varyings)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
unloadInternal();
sInstances.insert(this);
@@ -588,6 +591,8 @@ void LLGLSLShader::attachObjects(GLhandleARB* objects, S32 count)
BOOL LLGLSLShader::mapAttributes(const std::vector<LLStaticHashedString> * attributes)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
//before linking, make sure reserved attributes always have consistent locations
for (U32 i = 0; i < LLShaderMgr::instance()->mReservedAttribs.size(); i++)
{
@@ -649,6 +654,8 @@ BOOL LLGLSLShader::mapAttributes(const std::vector<LLStaticHashedString> * attri
void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString> * uniforms)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
if (index == -1)
{
return;
@@ -731,7 +738,7 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString> *
{
//found it
mUniform[i] = location;
- mTexture[i] = mapUniformTextureChannel(location, type);
+ mTexture[i] = mapUniformTextureChannel(location, type, size);
return;
}
}
@@ -745,7 +752,7 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString> *
{
//found it
mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] = location;
- mTexture[i+LLShaderMgr::instance()->mReservedUniforms.size()] = mapUniformTextureChannel(location, type);
+ mTexture[i+LLShaderMgr::instance()->mReservedUniforms.size()] = mapUniformTextureChannel(location, type, size);
return;
}
}
@@ -768,21 +775,46 @@ void LLGLSLShader::removePermutation(std::string name)
mDefines[name].erase();
}
-GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type)
+GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type, GLint size)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
if ((type >= GL_SAMPLER_1D_ARB && type <= GL_SAMPLER_2D_RECT_SHADOW_ARB) ||
type == GL_SAMPLER_2D_MULTISAMPLE)
{ //this here is a texture
- glUniform1iARB(location, mActiveTextureChannels);
- LL_DEBUGS("ShaderUniform") << "Assigned to texture channel " << mActiveTextureChannels << LL_ENDL;
- return mActiveTextureChannels++;
+ GLint ret = mActiveTextureChannels;
+ if (size == 1)
+ {
+ glUniform1iARB(location, mActiveTextureChannels);
+ LL_DEBUGS("ShaderUniform") << "Assigned to texture channel " << mActiveTextureChannels << LL_ENDL;
+ mActiveTextureChannels++;
+ }
+ else
+ {
+ //is array of textures, make sequential after this texture
+ GLint channel[32]; // <=== only support up to 32 texture channels
+ llassert(size <= 32);
+ size = llmin(size, 32);
+ for (int i = 0; i < size; ++i)
+ {
+ channel[i] = mActiveTextureChannels++;
+ }
+ glUniform1ivARB(location, size, channel);
+ LL_DEBUGS("ShaderUniform") << "Assigned to texture channel " <<
+ (mActiveTextureChannels-size) << " through " << (mActiveTextureChannels-1) << LL_ENDL;
+ }
+
+ llassert(mActiveTextureChannels <= 32); // too many textures (probably)
+ return ret;
}
return -1;
}
BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)
{
- BOOL res = TRUE;
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
+ BOOL res = TRUE;
mTotalUniformSize = 0;
mActiveTextureChannels = 0;
@@ -821,6 +853,9 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)
As example where this situation appear see: "Deferred Material Shader 28/29/30/31"
And tickets: MAINT-4165, MAINT-4839, MAINT-3568, MAINT-6437
+
+ --- davep TODO -- pretty sure the entire block here is superstitious and that the uniform index has nothing to do with the texture channel
+ texture channel should follow the uniform VALUE
*/
@@ -829,6 +864,7 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)
S32 bumpMap = glGetUniformLocationARB(mProgramObject, "bumpMap");
S32 altDiffuseMap = glGetUniformLocationARB(mProgramObject, "altDiffuseMap");
S32 environmentMap = glGetUniformLocationARB(mProgramObject, "environmentMap");
+ S32 reflectionMap = glGetUniformLocationARB(mProgramObject, "reflectionMap");
std::set<S32> skip_index;
@@ -871,6 +907,12 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)
continue;
}
+ if (-1 == reflectionMap && std::string(name) == "reflectionMap")
+ {
+ reflectionMap = i;
+ continue;
+ }
+
if (-1 == altDiffuseMap && std::string(name) == "altDiffuseMap")
{
altDiffuseMap = i;
@@ -881,8 +923,9 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)
bool specularDiff = specularMap < diffuseMap && -1 != specularMap;
bool bumpLessDiff = bumpMap < diffuseMap && -1 != bumpMap;
bool envLessDiff = environmentMap < diffuseMap && -1 != environmentMap;
+ bool refLessDiff = reflectionMap < diffuseMap && -1 != reflectionMap;
- if (specularDiff || bumpLessDiff || envLessDiff)
+ if (specularDiff || bumpLessDiff || envLessDiff || refLessDiff)
{
mapUniform(diffuseMap, uniforms);
skip_index.insert(diffuseMap);
@@ -901,6 +944,11 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)
mapUniform(environmentMap, uniforms);
skip_index.insert(environmentMap);
}
+
+ if (-1 != reflectionMap) {
+ mapUniform(reflectionMap, uniforms);
+ skip_index.insert(reflectionMap);
+ }
}
}
@@ -925,6 +973,8 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)
BOOL LLGLSLShader::link(BOOL suppress_errors)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
BOOL success = LLShaderMgr::instance()->linkProgramObject(mProgramObject, suppress_errors);
if (!success && !suppress_errors)
@@ -937,56 +987,65 @@ BOOL LLGLSLShader::link(BOOL suppress_errors)
void LLGLSLShader::bind()
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
gGL.flush();
- if (gGLManager.mHasShaderObjects)
+
+ if (sCurBoundShader != mProgramObject) // Don't re-bind current shader
{
LLVertexBuffer::unbind();
glUseProgramObjectARB(mProgramObject);
sCurBoundShader = mProgramObject;
sCurBoundShaderPtr = this;
- if (mUniformsDirty)
- {
- LLShaderMgr::instance()->updateShaderUniforms(this);
- mUniformsDirty = FALSE;
- }
+ }
+
+ if (mUniformsDirty)
+ {
+ LLShaderMgr::instance()->updateShaderUniforms(this);
+ mUniformsDirty = FALSE;
}
}
-void LLGLSLShader::unbind()
+void LLGLSLShader::bind(bool rigged)
{
- gGL.flush();
- if (gGLManager.mHasShaderObjects)
+ if (rigged)
{
- stop_glerror();
- if (gGLManager.mIsNVIDIA)
- {
- for (U32 i = 0; i < mAttribute.size(); ++i)
- {
- vertexAttrib4f(i, 0,0,0,1);
- stop_glerror();
- }
- }
- LLVertexBuffer::unbind();
- glUseProgramObjectARB(0);
- sCurBoundShader = 0;
- sCurBoundShaderPtr = NULL;
- stop_glerror();
+ llassert(mRiggedVariant);
+ mRiggedVariant->bind();
}
+ else
+ {
+ bind();
+ }
+}
+
+void LLGLSLShader::unbind()
+{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
+ gGL.flush();
+ stop_glerror();
+ LLVertexBuffer::unbind();
+ glUseProgramObjectARB(0);
+ sCurBoundShader = 0;
+ sCurBoundShaderPtr = NULL;
+ stop_glerror();
}
void LLGLSLShader::bindNoShader(void)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
LLVertexBuffer::unbind();
- if (gGLManager.mHasShaderObjects)
- {
- glUseProgramObjectARB(0);
- sCurBoundShader = 0;
- sCurBoundShaderPtr = NULL;
- }
+ glUseProgramObjectARB(0);
+ sCurBoundShader = 0;
+ sCurBoundShaderPtr = NULL;
}
S32 LLGLSLShader::bindTexture(const std::string &uniform, LLTexture *texture, LLTexUnit::eTextureType mode, LLTexUnit::eTextureColorSpace colorspace)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
S32 channel = 0;
channel = getUniformLocation(uniform);
@@ -995,6 +1054,8 @@ S32 LLGLSLShader::bindTexture(const std::string &uniform, LLTexture *texture, LL
S32 LLGLSLShader::bindTexture(S32 uniform, LLTexture *texture, LLTexUnit::eTextureType mode, LLTexUnit::eTextureColorSpace colorspace)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
if (uniform < 0 || uniform >= (S32)mTexture.size())
{
LL_SHADER_UNIFORM_ERRS() << "Uniform out of range: " << uniform << LL_ENDL;
@@ -1005,7 +1066,7 @@ S32 LLGLSLShader::bindTexture(S32 uniform, LLTexture *texture, LLTexUnit::eTextu
if (uniform > -1)
{
- gGL.getTexUnit(uniform)->bind(texture, mode);
+ gGL.getTexUnit(uniform)->bindFast(texture);
gGL.getTexUnit(uniform)->setTextureColorSpace(colorspace);
}
@@ -1014,6 +1075,8 @@ S32 LLGLSLShader::bindTexture(S32 uniform, LLTexture *texture, LLTexUnit::eTextu
S32 LLGLSLShader::unbindTexture(const std::string &uniform, LLTexUnit::eTextureType mode)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
S32 channel = 0;
channel = getUniformLocation(uniform);
@@ -1022,6 +1085,8 @@ S32 LLGLSLShader::unbindTexture(const std::string &uniform, LLTexUnit::eTextureT
S32 LLGLSLShader::unbindTexture(S32 uniform, LLTexUnit::eTextureType mode)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
if (uniform < 0 || uniform >= (S32)mTexture.size())
{
LL_SHADER_UNIFORM_ERRS() << "Uniform out of range: " << uniform << LL_ENDL;
@@ -1032,7 +1097,7 @@ S32 LLGLSLShader::unbindTexture(S32 uniform, LLTexUnit::eTextureType mode)
if (uniform > -1)
{
- gGL.getTexUnit(uniform)->unbind(mode);
+ gGL.getTexUnit(uniform)->unbindFast(mode);
}
return uniform;
@@ -1040,6 +1105,8 @@ S32 LLGLSLShader::unbindTexture(S32 uniform, LLTexUnit::eTextureType mode)
S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode, LLTexUnit::eTextureColorSpace space)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
if (uniform < 0 || uniform >= (S32)mTexture.size())
{
LL_SHADER_UNIFORM_ERRS() << "Uniform out of range: " << uniform << LL_ENDL;
@@ -1057,6 +1124,8 @@ S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode, LLTex
S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode, LLTexUnit::eTextureColorSpace space)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
if (uniform < 0 || uniform >= (S32)mTexture.size())
{
LL_SHADER_UNIFORM_ERRS() << "Uniform out of range: " << uniform << LL_ENDL;
@@ -1084,6 +1153,7 @@ S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode, LLTe
void LLGLSLShader::uniform1i(U32 index, GLint x)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER
if (mProgramObject)
{
if (mUniform.size() <= index)
@@ -1094,7 +1164,7 @@ void LLGLSLShader::uniform1i(U32 index, GLint x)
if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
+ const auto& iter = mValue.find(mUniform[index]);
if (iter == mValue.end() || iter->second.mV[0] != x)
{
glUniform1iARB(mUniform[index], x);
@@ -1106,6 +1176,7 @@ void LLGLSLShader::uniform1i(U32 index, GLint x)
void LLGLSLShader::uniform1f(U32 index, GLfloat x)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER
if (mProgramObject)
{
if (mUniform.size() <= index)
@@ -1116,7 +1187,7 @@ void LLGLSLShader::uniform1f(U32 index, GLfloat x)
if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
+ const auto& iter = mValue.find(mUniform[index]);
if (iter == mValue.end() || iter->second.mV[0] != x)
{
glUniform1fARB(mUniform[index], x);
@@ -1138,7 +1209,7 @@ void LLGLSLShader::uniform2f(U32 index, GLfloat x, GLfloat y)
if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
+ const auto& iter = mValue.find(mUniform[index]);
LLVector4 vec(x,y,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
@@ -1161,7 +1232,7 @@ void LLGLSLShader::uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z)
if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
+ const auto& iter = mValue.find(mUniform[index]);
LLVector4 vec(x,y,z,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
@@ -1184,7 +1255,7 @@ void LLGLSLShader::uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat
if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
+ const auto& iter = mValue.find(mUniform[index]);
LLVector4 vec(x,y,z,w);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
@@ -1207,7 +1278,7 @@ void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v)
if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
+ const auto& 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)
{
@@ -1230,7 +1301,7 @@ void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v)
if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
+ const auto& 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)
{
@@ -1253,7 +1324,7 @@ void LLGLSLShader::uniform2fv(U32 index, U32 count, const GLfloat* v)
if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
+ const auto& 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)
{
@@ -1276,7 +1347,7 @@ void LLGLSLShader::uniform3fv(U32 index, U32 count, const GLfloat* v)
if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
+ const auto& 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)
{
@@ -1299,10 +1370,11 @@ void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v)
if (mUniform[index] >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
+ const auto& 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)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
glUniform4fvARB(mUniform[index], count, v);
mValue[mUniform[index]] = vec;
}
@@ -1346,6 +1418,8 @@ void LLGLSLShader::uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, c
void LLGLSLShader::uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
if (mProgramObject)
{
if (mUniform.size() <= index)
@@ -1380,6 +1454,8 @@ void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, c
GLint LLGLSLShader::getUniformLocation(const LLStaticHashedString& uniform)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
GLint ret = -1;
if (mProgramObject)
{
@@ -1404,10 +1480,16 @@ GLint LLGLSLShader::getUniformLocation(const LLStaticHashedString& uniform)
GLint LLGLSLShader::getUniformLocation(U32 index)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
GLint ret = -1;
if (mProgramObject)
{
- llassert(index < mUniform.size());
+ if (index >= mUniform.size())
+ {
+ LL_WARNS_ONCE("Shader") << "Uniform index " << index << " out of bounds " << (S32)mUniform.size() << LL_ENDL;
+ return ret;
+ }
return mUniform[index];
}
@@ -1416,6 +1498,8 @@ GLint LLGLSLShader::getUniformLocation(U32 index)
GLint LLGLSLShader::getAttribLocation(U32 attrib)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+
if (attrib < mAttribute.size())
{
return mAttribute[attrib];
@@ -1432,7 +1516,7 @@ void LLGLSLShader::uniform1i(const LLStaticHashedString& uniform, GLint v)
if (location >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ const auto& iter = mValue.find(location);
LLVector4 vec(v,0.f,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
@@ -1448,7 +1532,7 @@ void LLGLSLShader::uniform2i(const LLStaticHashedString& uniform, GLint i, GLint
if (location >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ const auto& iter = mValue.find(location);
LLVector4 vec(i,j,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
@@ -1465,7 +1549,7 @@ void LLGLSLShader::uniform1f(const LLStaticHashedString& uniform, GLfloat v)
if (location >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ const auto& iter = mValue.find(location);
LLVector4 vec(v,0.f,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
@@ -1481,7 +1565,7 @@ void LLGLSLShader::uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLf
if (location >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ const auto& iter = mValue.find(location);
LLVector4 vec(x,y,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
@@ -1498,7 +1582,7 @@ void LLGLSLShader::uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLf
if (location >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ const auto& iter = mValue.find(location);
LLVector4 vec(x,y,z,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
@@ -1514,7 +1598,7 @@ void LLGLSLShader::uniform1fv(const LLStaticHashedString& uniform, U32 count, co
if (location >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ const auto& iter = mValue.find(location);
LLVector4 vec(v[0],0.f,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
{
@@ -1530,7 +1614,7 @@ void LLGLSLShader::uniform2fv(const LLStaticHashedString& uniform, U32 count, co
if (location >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ const auto& iter = mValue.find(location);
LLVector4 vec(v[0],v[1],0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
{
@@ -1546,7 +1630,7 @@ void LLGLSLShader::uniform3fv(const LLStaticHashedString& uniform, U32 count, co
if (location >= 0)
{
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ const auto& iter = mValue.find(location);
LLVector4 vec(v[0],v[1],v[2],0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
{
@@ -1563,12 +1647,11 @@ void LLGLSLShader::uniform4fv(const LLStaticHashedString& uniform, U32 count, co
if (location >= 0)
{
LLVector4 vec(v);
- std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ const auto& iter = mValue.find(location);
if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
{
- stop_glerror();
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
glUniform4fvARB(location, count, v);
- stop_glerror();
mValue[location] = vec;
}
}
@@ -1608,3 +1691,27 @@ void LLGLSLShader::setMinimumAlpha(F32 minimum)
gGL.flush();
uniform1f(LLShaderMgr::MINIMUM_ALPHA, minimum);
}
+
+void LLShaderUniforms::apply(LLGLSLShader* shader)
+{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+ for (auto& uniform : mIntegers)
+ {
+ shader->uniform1i(uniform.mUniform, uniform.mValue);
+ }
+
+ for (auto& uniform : mFloats)
+ {
+ shader->uniform1f(uniform.mUniform, uniform.mValue);
+ }
+
+ for (auto& uniform : mVectors)
+ {
+ shader->uniform4fv(uniform.mUniform, 1, uniform.mValue.mV);
+ }
+
+ for (auto& uniform : mVector3s)
+ {
+ shader->uniform3fv(uniform.mUniform, 1, uniform.mValue.mV);
+ }
+}