Newer
Older
Graham Linden
committed
if (uniform < 0 || uniform >= (S32)mTexture.size())
{
LL_SHADER_UNIFORM_ERRS() << "Uniform out of range: " << uniform << LL_ENDL;
Graham Linden
committed
return -1;
}
S32 index = mTexture[uniform];
if (index != -1 && gGL.getTexUnit(index)->getCurrType() != LLTexUnit::TT_NONE)
if (gDebugGL && gGL.getTexUnit(index)->getCurrType() != mode && gGL.getTexUnit(index)->getCurrColorSpace() != space)
{
if (gDebugSession)
{
Graham Linden
committed
gFailLog << "Texture channel " << index << " texture type corrupted." << std::endl;
ll_fail("LLGLSLShader::disableTexture failed");
}
else
{
Graham Linden
committed
LL_ERRS() << "Texture channel " << index << " texture type corrupted." << LL_ENDL;
Graham Linden
committed
gGL.getTexUnit(index)->disable();
Graham Linden
committed
return index;
void LLGLSLShader::uniform1i(U32 index, GLint x)
{
Graham Linden
committed
if (mUniform.size() <= index)
{
LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL;
Graham Linden
committed
return;
}
Graham Linden
committed
if (mUniform[index] >= 0)
Graham Linden
committed
std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
if (iter == mValue.end() || iter->second.mV[0] != x)
{
Graham Linden
committed
mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f);
}
void LLGLSLShader::uniform1f(U32 index, GLfloat x)
{
Graham Linden
committed
if (mUniform.size() <= index)
{
LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL;
Graham Linden
committed
return;
}
Graham Linden
committed
if (mUniform[index] >= 0)
Graham Linden
committed
std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
if (iter == mValue.end() || iter->second.mV[0] != x)
{
Graham Linden
committed
mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f);
}
void LLGLSLShader::uniform2f(U32 index, GLfloat x, GLfloat y)
{
Graham Linden
committed
if (mUniform.size() <= index)
{
LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL;
Graham Linden
committed
return;
}
Graham Linden
committed
if (mUniform[index] >= 0)
Graham Linden
committed
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))
{
Graham Linden
committed
mValue[mUniform[index]] = vec;
}
void LLGLSLShader::uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z)
{
Graham Linden
committed
if (mUniform.size() <= index)
{
LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL;
Graham Linden
committed
return;
}
Graham Linden
committed
if (mUniform[index] >= 0)
Graham Linden
committed
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))
{
Graham Linden
committed
mValue[mUniform[index]] = vec;
}
void LLGLSLShader::uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
Graham Linden
committed
if (mUniform.size() <= index)
{
LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL;
Graham Linden
committed
return;
}
Graham Linden
committed
if (mUniform[index] >= 0)
Graham Linden
committed
std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
LLVector4 vec(x,y,z,w);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
Graham Linden
committed
mValue[mUniform[index]] = vec;
void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v)
{
Graham Linden
committed
if (mUniform.size() <= index)
{
LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL;
Graham Linden
committed
return;
}
Graham Linden
committed
if (mUniform[index] >= 0)
Graham Linden
committed
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)
{
Graham Linden
committed
mValue[mUniform[index]] = vec;
}
void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v)
{
Graham Linden
committed
if (mUniform.size() <= index)
{
LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL;
Graham Linden
committed
return;
}
Graham Linden
committed
if (mUniform[index] >= 0)
Graham Linden
committed
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)
{
Graham Linden
committed
mValue[mUniform[index]] = vec;
}
void LLGLSLShader::uniform2fv(U32 index, U32 count, const GLfloat* v)
{
Graham Linden
committed
if (mUniform.size() <= index)
{
LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL;
Graham Linden
committed
return;
}
Graham Linden
committed
if (mUniform[index] >= 0)
Graham Linden
committed
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)
{
Graham Linden
committed
mValue[mUniform[index]] = vec;
}
void LLGLSLShader::uniform3fv(U32 index, U32 count, const GLfloat* v)
{
Graham Linden
committed
if (mUniform.size() <= index)
{
LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL;
Graham Linden
committed
return;
}
Graham Linden
committed
if (mUniform[index] >= 0)
Graham Linden
committed
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)
{
Graham Linden
committed
mValue[mUniform[index]] = vec;
}
void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v)
{
Graham Linden
committed
if (mUniform.size() <= index)
{
LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL;
Graham Linden
committed
return;
}
Graham Linden
committed
if (mUniform[index] >= 0)
Graham Linden
committed
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)
{
Graham Linden
committed
mValue[mUniform[index]] = vec;
}
void LLGLSLShader::uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v)
{
Graham Linden
committed
if (mUniform.size() <= index)
{
LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL;
Graham Linden
committed
return;
}
Graham Linden
committed
if (mUniform[index] >= 0)
glUniformMatrix2fv(mUniform[index], count, transpose, v);
}
void LLGLSLShader::uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v)
{
Graham Linden
committed
if (mUniform.size() <= index)
{
LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL;
Graham Linden
committed
return;
}
Graham Linden
committed
if (mUniform[index] >= 0)
glUniformMatrix3fv(mUniform[index], count, transpose, v);
Brad Payne (Vir Linden)
committed
void LLGLSLShader::uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v)
{
if (mProgramObject)
{
if (mUniform.size() <= index)
{
LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL;
return;
}
if (mUniform[index] >= 0)
{
glUniformMatrix3x4fv(mUniform[index], count, transpose, v);
}
}
Brad Payne (Vir Linden)
committed
}
void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v)
{
Graham Linden
committed
if (mUniform.size() <= index)
{
LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL;
Graham Linden
committed
return;
}
if (mUniform[index] >= 0)
glUniformMatrix4fv(mUniform[index], count, transpose, v);
GLint LLGLSLShader::getUniformLocation(const LLStaticHashedString& uniform)
{
LLStaticStringTable<GLint>::iterator iter = mUniformMap.find(uniform);
if (iter != mUniformMap.end())
{
if (gDebugGL)
{
stop_glerror();
if (iter->second != glGetUniformLocation(mProgramObject, uniform.String().c_str()))
{
LL_ERRS() << "Uniform does not match." << LL_ENDL;
}
stop_glerror();
}
ret = iter->second;
}
}
return ret;
}
GLint LLGLSLShader::getUniformLocation(U32 index)
{
Graham Linden
committed
GLint ret = -1;
if (mProgramObject)
{
llassert(index < mUniform.size());
return mUniform[index];
}
return ret;
GLint LLGLSLShader::getAttribLocation(U32 attrib)
{
if (attrib < mAttribute.size())
{
return mAttribute[attrib];
}
else
{
return -1;
}
void LLGLSLShader::uniform1i(const LLStaticHashedString& uniform, GLint v)
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
LLVector4 vec(v,0.f,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
mValue[location] = vec;
}
}
}
David Parks
committed
void LLGLSLShader::uniform2i(const LLStaticHashedString& uniform, GLint i, GLint j)
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
LLVector4 vec(i,j,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
mValue[location] = vec;
}
}
void LLGLSLShader::uniform1f(const LLStaticHashedString& uniform, GLfloat v)
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
LLVector4 vec(v,0.f,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
mValue[location] = vec;
}
}
void LLGLSLShader::uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y)
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
LLVector4 vec(x,y,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
mValue[location] = vec;
}
}
void LLGLSLShader::uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z)
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
LLVector4 vec(x,y,z,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
mValue[location] = vec;
}
}
void LLGLSLShader::uniform1fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
std::map<GLint, LLVector4>::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)
{
mValue[location] = vec;
}
}
void LLGLSLShader::uniform2fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
std::map<GLint, LLVector4>::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)
{
mValue[location] = vec;
}
}
void LLGLSLShader::uniform3fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
std::map<GLint, LLVector4>::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)
{
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<GLint, LLVector4>::iterator iter = mValue.find(location);
if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
{
stop_glerror();
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();
glUniformMatrix4fv(location, count, transpose, v);
stop_glerror();
}
}
void LLGLSLShader::vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
if (mAttribute[index] > 0)
{
glVertexAttrib4f(mAttribute[index], x, y, z, w);
}
void LLGLSLShader::vertexAttrib4fv(U32 index, GLfloat* v)
{
if (mAttribute[index] > 0)
{
David Parks
committed
void LLGLSLShader::setMinimumAlpha(F32 minimum)
{
gGL.flush();
uniform1f(LLShaderMgr::MINIMUM_ALPHA, minimum);