aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llglslshader.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-30 13:04:20 -0500
committerJacek Antonelli2009-04-30 13:07:16 -0500
commitca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch)
tree8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/llrender/llglslshader.cpp
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz
Second Life viewer sources 1.23.0-RC
Diffstat (limited to 'linden/indra/llrender/llglslshader.cpp')
-rw-r--r--linden/indra/llrender/llglslshader.cpp89
1 files changed, 84 insertions, 5 deletions
diff --git a/linden/indra/llrender/llglslshader.cpp b/linden/indra/llrender/llglslshader.cpp
index 6683916..08d6548 100644
--- a/linden/indra/llrender/llglslshader.cpp
+++ b/linden/indra/llrender/llglslshader.cpp
@@ -17,7 +17,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -255,6 +256,14 @@ void LLGLSLShader::mapUniform(GLint index, const vector<string> * uniforms)
255 S32 location = glGetUniformLocationARB(mProgramObject, name); 256 S32 location = glGetUniformLocationARB(mProgramObject, name);
256 if (location != -1) 257 if (location != -1)
257 { 258 {
259 //chop off "[0]" so we can always access the first element
260 //of an array by the array name
261 char* is_array = strstr(name, "[0]");
262 if (is_array)
263 {
264 is_array[0] = 0;
265 }
266
258 mUniformMap[name] = location; 267 mUniformMap[name] = location;
259 LL_DEBUGS("ShaderLoading") << "Uniform " << name << " is at location " << location << LL_ENDL; 268 LL_DEBUGS("ShaderLoading") << "Uniform " << name << " is at location " << location << LL_ENDL;
260 269
@@ -352,11 +361,17 @@ void LLGLSLShader::unbind()
352{ 361{
353 if (gGLManager.mHasShaderObjects) 362 if (gGLManager.mHasShaderObjects)
354 { 363 {
355 for (U32 i = 0; i < mAttribute.size(); ++i) 364 stop_glerror();
365 if (gGLManager.mIsNVIDIA)
356 { 366 {
357 vertexAttrib4f(i, 0,0,0,1); 367 for (U32 i = 0; i < mAttribute.size(); ++i)
368 {
369 vertexAttrib4f(i, 0,0,0,1);
370 stop_glerror();
371 }
358 } 372 }
359 glUseProgramObjectARB(0); 373 glUseProgramObjectARB(0);
374 stop_glerror();
360 } 375 }
361} 376}
362 377
@@ -389,14 +404,39 @@ S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode)
389 return -1; 404 return -1;
390 } 405 }
391 S32 index = mTexture[uniform]; 406 S32 index = mTexture[uniform];
392 if (index != -1) 407 if (index != -1 && gGL.getTexUnit(index)->getCurrType() != LLTexUnit::TT_NONE)
393 { 408 {
394 gGL.getTexUnit(index)->activate(); 409 if (gDebugGL && gGL.getTexUnit(index)->getCurrType() != mode)
410 {
411 llerrs << "Texture channel " << index << " texture type corrupted." << llendl;
412 }
395 gGL.getTexUnit(index)->disable(); 413 gGL.getTexUnit(index)->disable();
396 } 414 }
397 return index; 415 return index;
398} 416}
399 417
418void LLGLSLShader::uniform1i(U32 index, GLint x)
419{
420 if (mProgramObject > 0)
421 {
422 if (mUniform.size() <= index)
423 {
424 UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
425 return;
426 }
427
428 if (mUniform[index] >= 0)
429 {
430 std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
431 if (iter == mValue.end() || iter->second.mV[0] != x)
432 {
433 glUniform1iARB(mUniform[index], x);
434 mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f);
435 }
436 }
437 }
438}
439
400void LLGLSLShader::uniform1f(U32 index, GLfloat x) 440void LLGLSLShader::uniform1f(U32 index, GLfloat x)
401{ 441{
402 if (mProgramObject > 0) 442 if (mProgramObject > 0)
@@ -488,6 +528,29 @@ void LLGLSLShader::uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat
488 } 528 }
489} 529}
490 530
531void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v)
532{
533 if (mProgramObject > 0)
534 {
535 if (mUniform.size() <= index)
536 {
537 UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
538 return;
539 }
540
541 if (mUniform[index] >= 0)
542 {
543 std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
544 LLVector4 vec(v[0],0.f,0.f,0.f);
545 if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
546 {
547 glUniform1ivARB(mUniform[index], count, v);
548 mValue[mUniform[index]] = vec;
549 }
550 }
551 }
552}
553
491void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v) 554void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v)
492{ 555{
493 if (mProgramObject > 0) 556 if (mProgramObject > 0)
@@ -646,6 +709,22 @@ GLint LLGLSLShader::getUniformLocation(const string& uniform)
646 return -1; 709 return -1;
647} 710}
648 711
712void LLGLSLShader::uniform1i(const string& uniform, GLint v)
713{
714 GLint location = getUniformLocation(uniform);
715
716 if (location >= 0)
717 {
718 std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
719 LLVector4 vec(v,0.f,0.f,0.f);
720 if (iter == mValue.end() || shouldChange(iter->second,vec))
721 {
722 glUniform1iARB(location, v);
723 mValue[location] = vec;
724 }
725 }
726}
727
649void LLGLSLShader::uniform1f(const string& uniform, GLfloat v) 728void LLGLSLShader::uniform1f(const string& uniform, GLfloat v)
650{ 729{
651 GLint location = getUniformLocation(uniform); 730 GLint location = getUniformLocation(uniform);