diff options
Diffstat (limited to 'indra/llrender/llglslshader.cpp')
| -rw-r--r-- | indra/llrender/llglslshader.cpp | 289 | 
1 files changed, 204 insertions, 85 deletions
| diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 185c1450c8..27de7070ff 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -37,7 +37,7 @@  #include "OpenGL/OpenGL.h"  #endif -// Print-print list of shader included source files that are linked together via glAttachObjectARB() +// Print-print list of shader included source files that are linked together via glAttachShader()  // i.e. On macOS / OSX the AMD GLSL linker will display an error if a varying is left in an undefined state.  #define DEBUG_SHADER_INCLUDES 0 @@ -47,7 +47,7 @@ using std::pair;  using std::make_pair;  using std::string; -GLhandleARB LLGLSLShader::sCurBoundShader = 0; +GLuint LLGLSLShader::sCurBoundShader = 0;  LLGLSLShader* LLGLSLShader::sCurBoundShaderPtr = NULL;  S32 LLGLSLShader::sIndexedTextureChannels = 0;  bool LLGLSLShader::sProfileEnabled = false; @@ -227,11 +227,10 @@ void LLGLSLShader::stopProfile(U32 count, U32 mode)  void LLGLSLShader::placeProfileQuery()  { -#if !LL_DARWIN      if (mTimerQuery == 0)      { -        glGenQueriesARB(1, &mSamplesQuery); -        glGenQueriesARB(1, &mTimerQuery); +        glGenQueries(1, &mSamplesQuery); +        glGenQueries(1, &mTimerQuery);      }      if (!mTextureStateFetched) @@ -267,16 +266,14 @@ void LLGLSLShader::placeProfileQuery()      } -    glBeginQueryARB(GL_SAMPLES_PASSED, mSamplesQuery); -    glBeginQueryARB(GL_TIME_ELAPSED, mTimerQuery); -#endif +    glBeginQuery(GL_SAMPLES_PASSED, mSamplesQuery); +    glBeginQuery(GL_TIME_ELAPSED, mTimerQuery);  }  void LLGLSLShader::readProfileQuery(U32 count, U32 mode)  { -#if !LL_DARWIN -    glEndQueryARB(GL_TIME_ELAPSED); -    glEndQueryARB(GL_SAMPLES_PASSED); +    glEndQuery(GL_TIME_ELAPSED); +    glEndQuery(GL_SAMPLES_PASSED);      U64 time_elapsed = 0;      glGetQueryObjectui64v(mTimerQuery, GL_QUERY_RESULT, &time_elapsed); @@ -304,7 +301,6 @@ void LLGLSLShader::readProfileQuery(U32 count, U32 mode)      sTotalDrawCalls++;      mDrawCalls++; -#endif  } @@ -347,30 +343,37 @@ void LLGLSLShader::unloadInternal()      if (mProgramObject)      { -        GLhandleARB obj[1024]; -        GLsizei count; -        glGetAttachedObjectsARB(mProgramObject, 1024, &count, obj); +        GLuint obj[1024]; +        GLsizei count = 0; +        glGetAttachedShaders(mProgramObject, 1024, &count, obj); + +        for (GLsizei i = 0; i < count; i++) +        { +            glDetachShader(mProgramObject, obj[i]); +        }          for (GLsizei i = 0; i < count; i++)          { -            glDetachObjectARB(mProgramObject, obj[i]); -            glDeleteObjectARB(obj[i]); +            if (glIsShader(obj[i])) +            { +                glDeleteShader(obj[i]); +            }          } -        glDeleteObjectARB(mProgramObject); +        glDeleteProgram(mProgramObject);          mProgramObject = 0;      }      if (mTimerQuery)      { -        glDeleteQueriesARB(1, &mTimerQuery); +        glDeleteQueries(1, &mTimerQuery);          mTimerQuery = 0;      }      if (mSamplesQuery)      { -        glDeleteQueriesARB(1, &mSamplesQuery); +        glDeleteQueries(1, &mSamplesQuery);          mSamplesQuery = 0;      } @@ -401,7 +404,7 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes,      llassert_always(!mShaderFiles.empty());      // Create program -    mProgramObject = glCreateProgramObjectARB(); +    mProgramObject = glCreateProgram();      if (mProgramObject == 0)      {          // Shouldn't happen if shader related extensions, like ARB_vertex_shader, exist. @@ -425,7 +428,7 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes,      vector< pair<string,GLenum> >::iterator fileIter = mShaderFiles.begin();      for ( ; fileIter != mShaderFiles.end(); fileIter++ )      { -        GLhandleARB shaderhandle = LLShaderMgr::instance()->loadShaderFile((*fileIter).first, mShaderLevel, (*fileIter).second, &mDefines, mFeatures.mIndexedTextureChannels); +        GLuint shaderhandle = LLShaderMgr::instance()->loadShaderFile((*fileIter).first, mShaderLevel, (*fileIter).second, &mDefines, mFeatures.mIndexedTextureChannels);          LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << LL_ENDL;          if (shaderhandle)          { @@ -452,7 +455,7 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes,  #ifdef GL_INTERLEAVED_ATTRIBS      if (varying_count > 0 && varyings)      { -        glTransformFeedbackVaryings(mProgramObject, varying_count, varyings, GL_INTERLEAVED_ATTRIBS); +        glTransformFeedbackVaryings((GLuint64) mProgramObject, varying_count, varyings, GL_INTERLEAVED_ATTRIBS);      }  #endif @@ -501,24 +504,28 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes,          unbind();      } +#ifdef LL_PROFILER_ENABLE_TRACY_OPENGL +    setLabel(mName.c_str()); +#endif +      return success;  }  #if DEBUG_SHADER_INCLUDES -void dumpAttachObject( const char *func_name, GLhandleARB program_object, const std::string &object_path ) +void dumpAttachObject( const char *func_name, GLuint program_object, const std::string &object_path )  { -    GLcharARB* info_log; +    GLchar* info_log;      GLint      info_len_expect = 0;      GLint      info_len_actual = 0; -    glGetObjectParameterivARB(program_object, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_len_expect); +    glGetShaderiv(program_object, GL_INFO_LOG_LENGTH,, &info_len_expect);      fprintf(stderr, " * %-20s(), log size: %d, %s\n", func_name, info_len_expect, object_path.c_str());      if (info_len_expect > 0)      {          fprintf(stderr, " ========== %s() ========== \n", func_name); -        info_log = new GLcharARB [ info_len_expect ]; -        glGetInfoLogARB(program_object, info_len_expect, &info_len_actual, info_log); +        info_log = new GLchar [ info_len_expect ]; +       glGetProgramInfoLog(program_object, info_len_expect, &info_len_actual, info_log);          fprintf(stderr, "%s\n",  info_log);          delete [] info_log;      } @@ -530,7 +537,7 @@ BOOL LLGLSLShader::attachVertexObject(std::string object_path)      if (LLShaderMgr::instance()->mVertexShaderObjects.count(object_path) > 0)      {          stop_glerror(); -        glAttachObjectARB(mProgramObject, LLShaderMgr::instance()->mVertexShaderObjects[object_path]); +        glAttachShader(mProgramObject, LLShaderMgr::instance()->mVertexShaderObjects[object_path]);  #if DEBUG_SHADER_INCLUDES          dumpAttachObject("attachVertexObject", mProgramObject, object_path);  #endif // DEBUG_SHADER_INCLUDES @@ -549,7 +556,7 @@ BOOL LLGLSLShader::attachFragmentObject(std::string object_path)      if (LLShaderMgr::instance()->mFragmentShaderObjects.count(object_path) > 0)      {          stop_glerror(); -        glAttachObjectARB(mProgramObject, LLShaderMgr::instance()->mFragmentShaderObjects[object_path]); +        glAttachShader(mProgramObject, LLShaderMgr::instance()->mFragmentShaderObjects[object_path]);  #if DEBUG_SHADER_INCLUDES          dumpAttachObject("attachFragmentObject", mProgramObject, object_path);  #endif // DEBUG_SHADER_INCLUDES @@ -563,12 +570,12 @@ BOOL LLGLSLShader::attachFragmentObject(std::string object_path)      }  } -void LLGLSLShader::attachObject(GLhandleARB object) +void LLGLSLShader::attachObject(GLuint object)  {      if (object != 0)      {          stop_glerror(); -        glAttachObjectARB(mProgramObject, object); +        glAttachShader(mProgramObject, object);  #if DEBUG_SHADER_INCLUDES          std::string object_path("???");          dumpAttachObject("attachObject", mProgramObject, object_path); @@ -581,7 +588,7 @@ void LLGLSLShader::attachObject(GLhandleARB object)      }  } -void LLGLSLShader::attachObjects(GLhandleARB* objects, S32 count) +void LLGLSLShader::attachObjects(GLuint* objects, S32 count)  {      for (S32 i = 0; i < count; i++)      { @@ -597,7 +604,7 @@ BOOL LLGLSLShader::mapAttributes(const std::vector<LLStaticHashedString> * attri      for (U32 i = 0; i < LLShaderMgr::instance()->mReservedAttribs.size(); i++)      {          const char* name = LLShaderMgr::instance()->mReservedAttribs[i].c_str(); -        glBindAttribLocationARB(mProgramObject, i, (const GLcharARB *) name); +        glBindAttribLocation(mProgramObject, i, (const GLchar *) name);      }      //link the program @@ -620,7 +627,7 @@ BOOL LLGLSLShader::mapAttributes(const std::vector<LLStaticHashedString> * attri          for (U32 i = 0; i < LLShaderMgr::instance()->mReservedAttribs.size(); i++)          {              const char* name = LLShaderMgr::instance()->mReservedAttribs[i].c_str(); -            S32 index = glGetAttribLocationARB(mProgramObject, (const GLcharARB *)name); +            S32 index = glGetAttribLocation(mProgramObject, (const GLchar *)name);              if (index != -1)              {  #if LL_RELEASE_WITH_DEBUG_INFO @@ -637,7 +644,7 @@ BOOL LLGLSLShader::mapAttributes(const std::vector<LLStaticHashedString> * attri              for (U32 i = 0; i < numAttributes; i++)              {                  const char* name = (*attributes)[i].String().c_str(); -                S32 index = glGetAttribLocationARB(mProgramObject, name); +                S32 index = glGetAttribLocation(mProgramObject, name);                  if (index != -1)                  {                      mAttribute[LLShaderMgr::instance()->mReservedAttribs.size() + i] = index; @@ -668,8 +675,7 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString> *      name[0] = 0; -    glGetActiveUniformARB(mProgramObject, index, 1024, &length, &size, &type, (GLcharARB *)name); -#if !LL_DARWIN +    glGetActiveUniform(mProgramObject, index, 1024, &length, &size, &type, (GLchar *)name);      if (size > 0)      {          switch(type) @@ -711,9 +717,8 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString> *          }          mTotalUniformSize += size;      } -#endif -    S32 location = glGetUniformLocationARB(mProgramObject, name); +    S32 location = glGetUniformLocation(mProgramObject, name);      if (location != -1)      {          //chop off "[0]" so we can always access the first element @@ -738,7 +743,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;              }          } @@ -752,7 +757,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;                  }              } @@ -775,16 +780,38 @@ 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) +    if ((type >= GL_SAMPLER_1D  && type <= GL_SAMPLER_2D_RECT_SHADOW) || +        type == GL_SAMPLER_2D_MULTISAMPLE || +        type == GL_SAMPLER_CUBE_MAP_ARRAY)      {   //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) +        { +            glUniform1i(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++; +            } +            glUniform1iv(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;  } @@ -811,7 +838,7 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)  	//get the number of active uniforms  	GLint activeCount; -	glGetObjectParameterivARB(mProgramObject, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &activeCount); +    glGetProgramiv(mProgramObject, GL_ACTIVE_UNIFORMS, &activeCount);  	//........................................................................................................................................  	//........................................................................................ @@ -832,14 +859,18 @@ 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  	*/ -	S32 diffuseMap = glGetUniformLocationARB(mProgramObject, "diffuseMap"); -	S32 specularMap = glGetUniformLocationARB(mProgramObject, "specularMap"); -	S32 bumpMap = glGetUniformLocationARB(mProgramObject, "bumpMap"); -    S32 altDiffuseMap = glGetUniformLocationARB(mProgramObject, "altDiffuseMap"); -	S32 environmentMap = glGetUniformLocationARB(mProgramObject, "environmentMap"); +	S32 diffuseMap = glGetUniformLocation(mProgramObject, "diffuseMap"); +	S32 specularMap = glGetUniformLocation(mProgramObject, "specularMap"); +	S32 bumpMap = glGetUniformLocation(mProgramObject, "bumpMap"); +    S32 altDiffuseMap = glGetUniformLocation(mProgramObject, "altDiffuseMap"); +	S32 environmentMap = glGetUniformLocation(mProgramObject, "environmentMap"); +    S32 reflectionMap = glGetUniformLocation(mProgramObject, "reflectionMap");  	std::set<S32> skip_index; @@ -856,7 +887,7 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)  		{  			name[0] = '\0'; -			glGetActiveUniformARB(mProgramObject, i, 1024, &length, &size, &type, (GLcharARB *)name); +            glGetActiveUniform(mProgramObject, i, 1024, &length, &size, &type, (GLchar *)name);  			if (-1 == diffuseMap && std::string(name) == "diffuseMap")  			{ @@ -882,6 +913,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; @@ -892,8 +929,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); @@ -912,6 +950,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); +            }  		}  	} @@ -927,6 +970,17 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)  	}  	//........................................................................................................................................ +    if (mFeatures.hasReflectionProbes) // Set up block binding, in a way supported by Apple (rather than binding = 1 in .glsl). +    {   // See slide 35 and more of https://docs.huihoo.com/apple/wwdc/2011/session_420__advances_in_opengl_for_mac_os_x_lion.pdf +        static const GLuint BLOCKBINDING = 1; //picked by us +        //Get the index, similar to a uniform location +        GLuint UBOBlockIndex = glGetUniformBlockIndex(mProgramObject, "ReflectionProbes"); +        if (UBOBlockIndex != GL_INVALID_INDEX) +        { +            //Set this index to a binding index +            glUniformBlockBinding(mProgramObject, UBOBlockIndex, BLOCKBINDING); +        } +    }  	unbind();  	LL_DEBUGS("ShaderUniform") << "Total Uniform Size: " << mTotalUniformSize << LL_ENDL; @@ -957,7 +1011,7 @@ void LLGLSLShader::bind()      if (sCurBoundShader != mProgramObject)  // Don't re-bind current shader      {          LLVertexBuffer::unbind(); -        glUseProgramObjectARB(mProgramObject); +        glUseProgram(mProgramObject);          sCurBoundShader = mProgramObject;          sCurBoundShaderPtr = this;      } @@ -989,7 +1043,7 @@ void LLGLSLShader::unbind()      gGL.flush();      stop_glerror();      LLVertexBuffer::unbind(); -    glUseProgramObjectARB(0); +    glUseProgram(0);      sCurBoundShader = 0;      sCurBoundShaderPtr = NULL;      stop_glerror(); @@ -1000,7 +1054,7 @@ void LLGLSLShader::bindNoShader(void)      LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;      LLVertexBuffer::unbind(); -    glUseProgramObjectARB(0); +    glUseProgram(0);      sCurBoundShader = 0;      sCurBoundShaderPtr = NULL;  } @@ -1130,7 +1184,7 @@ void LLGLSLShader::uniform1i(U32 index, GLint x)              const auto& iter = mValue.find(mUniform[index]);              if (iter == mValue.end() || iter->second.mV[0] != x)              { -                glUniform1iARB(mUniform[index], x); +                glUniform1i(mUniform[index], x);                  mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f);              }          } @@ -1153,7 +1207,7 @@ void LLGLSLShader::uniform1f(U32 index, GLfloat x)              const auto& iter = mValue.find(mUniform[index]);              if (iter == mValue.end() || iter->second.mV[0] != x)              { -                glUniform1fARB(mUniform[index], x); +                glUniform1f(mUniform[index], x);                  mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f);              }          } @@ -1176,7 +1230,7 @@ void LLGLSLShader::uniform2f(U32 index, GLfloat x, GLfloat y)              LLVector4 vec(x,y,0.f,0.f);              if (iter == mValue.end() || shouldChange(iter->second,vec))              { -                glUniform2fARB(mUniform[index], x, y); +                glUniform2f(mUniform[index], x, y);                  mValue[mUniform[index]] = vec;              }          } @@ -1199,7 +1253,7 @@ void LLGLSLShader::uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z)              LLVector4 vec(x,y,z,0.f);              if (iter == mValue.end() || shouldChange(iter->second,vec))              { -                glUniform3fARB(mUniform[index], x, y, z); +                glUniform3f(mUniform[index], x, y, z);                  mValue[mUniform[index]] = vec;              }          } @@ -1222,7 +1276,7 @@ void LLGLSLShader::uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat              LLVector4 vec(x,y,z,w);              if (iter == mValue.end() || shouldChange(iter->second,vec))              { -                glUniform4fARB(mUniform[index], x, y, z, w); +                glUniform4f(mUniform[index], x, y, z, w);                  mValue[mUniform[index]] = vec;              }          } @@ -1245,13 +1299,37 @@ void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v)              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); +                glUniform1iv(mUniform[index], count, v); +                mValue[mUniform[index]] = vec; +            } +        } +    } +} + +void LLGLSLShader::uniform4iv(U32 index, U32 count, const GLint* v) +{ +    if (mProgramObject) +    { +        if (mUniform.size() <= index) +        { +            LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; +            return; +        } + +        if (mUniform[index] >= 0) +        { +            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) +            { +                glUniform1iv(mUniform[index], count, v);                  mValue[mUniform[index]] = vec;              }          }      }  } +  void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v)  {      if (mProgramObject) @@ -1268,7 +1346,7 @@ void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v)              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); +                glUniform1fv(mUniform[index], count, v);                  mValue[mUniform[index]] = vec;              }          } @@ -1291,7 +1369,7 @@ void LLGLSLShader::uniform2fv(U32 index, U32 count, const GLfloat* v)              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); +                glUniform2fv(mUniform[index], count, v);                  mValue[mUniform[index]] = vec;              }          } @@ -1314,7 +1392,7 @@ void LLGLSLShader::uniform3fv(U32 index, U32 count, const GLfloat* v)              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); +                glUniform3fv(mUniform[index], count, v);                  mValue[mUniform[index]] = vec;              }          } @@ -1338,7 +1416,7 @@ void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v)              if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)              {                  LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; -                glUniform4fvARB(mUniform[index], count, v); +                glUniform4fv(mUniform[index], count, v);                  mValue[mUniform[index]] = vec;              }          } @@ -1357,7 +1435,7 @@ void LLGLSLShader::uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, c          if (mUniform[index] >= 0)          { -            glUniformMatrix2fvARB(mUniform[index], count, transpose, v); +            glUniformMatrix2fv(mUniform[index], count, transpose, v);          }      }  } @@ -1374,7 +1452,7 @@ void LLGLSLShader::uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, c          if (mUniform[index] >= 0)          { -            glUniformMatrix3fvARB(mUniform[index], count, transpose, v); +            glUniformMatrix3fv(mUniform[index], count, transpose, v);          }      }  } @@ -1410,7 +1488,7 @@ void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, c          if (mUniform[index] >= 0)          { -            glUniformMatrix4fvARB(mUniform[index], count, transpose, v); +            glUniformMatrix4fv(mUniform[index], count, transpose, v);          }      }  } @@ -1428,7 +1506,7 @@ GLint LLGLSLShader::getUniformLocation(const LLStaticHashedString& uniform)              if (gDebugGL)              {                  stop_glerror(); -                if (iter->second != glGetUniformLocationARB(mProgramObject, uniform.String().c_str())) +                if (iter->second != glGetUniformLocation(mProgramObject, uniform.String().c_str()))                  {                      LL_ERRS() << "Uniform does not match." << LL_ENDL;                  } @@ -1483,7 +1561,41 @@ void LLGLSLShader::uniform1i(const LLStaticHashedString& uniform, GLint v)          LLVector4 vec(v,0.f,0.f,0.f);          if (iter == mValue.end() || shouldChange(iter->second,vec))          { -            glUniform1iARB(location, v); +            glUniform1i(location, v); +            mValue[location] = vec; +        } +    } +} + +void LLGLSLShader::uniform1iv(const LLStaticHashedString& uniform, U32 count, const GLint* v) +{ +    GLint location = getUniformLocation(uniform); + +    if (location >= 0) +    { +        LLVector4 vec(v[0], 0, 0, 0); +        const auto& iter = mValue.find(location); +        if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1) +        { +            LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; +            glUniform1iv(location, count, v); +            mValue[location] = vec; +        } +    } +} + +void LLGLSLShader::uniform4iv(const LLStaticHashedString& uniform, U32 count, const GLint* v) +{ +    GLint location = getUniformLocation(uniform); + +    if (location >= 0) +    { +        LLVector4 vec(v[0], v[1], v[2], v[3]); +        const auto& iter = mValue.find(location); +        if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1) +        { +            LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; +            glUniform4iv(location, count, v);              mValue[location] = vec;          }      } @@ -1499,7 +1611,7 @@ void LLGLSLShader::uniform2i(const LLStaticHashedString& uniform, GLint i, GLint          LLVector4 vec(i,j,0.f,0.f);          if (iter == mValue.end() || shouldChange(iter->second,vec))          { -            glUniform2iARB(location, i, j); +            glUniform2i(location, i, j);              mValue[location] = vec;          }      } @@ -1516,7 +1628,7 @@ void LLGLSLShader::uniform1f(const LLStaticHashedString& uniform, GLfloat v)          LLVector4 vec(v,0.f,0.f,0.f);          if (iter == mValue.end() || shouldChange(iter->second,vec))          { -            glUniform1fARB(location, v); +            glUniform1f(location, v);              mValue[location] = vec;          }      } @@ -1532,7 +1644,7 @@ void LLGLSLShader::uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLf          LLVector4 vec(x,y,0.f,0.f);          if (iter == mValue.end() || shouldChange(iter->second,vec))          { -            glUniform2fARB(location, x,y); +            glUniform2f(location, x,y);              mValue[location] = vec;          }      } @@ -1549,7 +1661,7 @@ void LLGLSLShader::uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLf          LLVector4 vec(x,y,z,0.f);          if (iter == mValue.end() || shouldChange(iter->second,vec))          { -            glUniform3fARB(location, x,y,z); +            glUniform3f(location, x,y,z);              mValue[location] = vec;          }      } @@ -1565,7 +1677,7 @@ void LLGLSLShader::uniform1fv(const LLStaticHashedString& uniform, U32 count, co          LLVector4 vec(v[0],0.f,0.f,0.f);          if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)          { -            glUniform1fvARB(location, count, v); +            glUniform1fv(location, count, v);              mValue[location] = vec;          }      } @@ -1581,7 +1693,7 @@ void LLGLSLShader::uniform2fv(const LLStaticHashedString& uniform, U32 count, co          LLVector4 vec(v[0],v[1],0.f,0.f);          if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)          { -            glUniform2fvARB(location, count, v); +            glUniform2fv(location, count, v);              mValue[location] = vec;          }      } @@ -1597,7 +1709,7 @@ void LLGLSLShader::uniform3fv(const LLStaticHashedString& uniform, U32 count, co          LLVector4 vec(v[0],v[1],v[2],0.f);          if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)          { -            glUniform3fvARB(location, count, v); +            glUniform3fv(location, count, v);              mValue[location] = vec;          }      } @@ -1614,7 +1726,7 @@ void LLGLSLShader::uniform4fv(const LLStaticHashedString& uniform, U32 count, co          if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)          {              LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; -            glUniform4fvARB(location, count, v); +            glUniform4fv(location, count, v);              mValue[location] = vec;          }      } @@ -1627,7 +1739,7 @@ void LLGLSLShader::uniformMatrix4fv(const LLStaticHashedString& uniform, U32 cou      if (location >= 0)      {          stop_glerror(); -        glUniformMatrix4fvARB(location, count, transpose, v); +        glUniformMatrix4fv(location, count, transpose, v);          stop_glerror();      }  } @@ -1637,7 +1749,7 @@ void LLGLSLShader::vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GL  {      if (mAttribute[index] > 0)      { -        glVertexAttrib4fARB(mAttribute[index], x, y, z, w); +        glVertexAttrib4f(mAttribute[index], x, y, z, w);      }  } @@ -1645,7 +1757,7 @@ void LLGLSLShader::vertexAttrib4fv(U32 index, GLfloat* v)  {      if (mAttribute[index] > 0)      { -        glVertexAttrib4fvARB(mAttribute[index], v); +        glVertexAttrib4fv(mAttribute[index], v);      }  } @@ -1678,3 +1790,10 @@ void LLShaderUniforms::apply(LLGLSLShader* shader)          shader->uniform3fv(uniform.mUniform, 1, uniform.mValue.mV);      }  } + +#ifdef LL_PROFILER_ENABLE_TRACY_OPENGL +void LLGLSLShader::setLabel(const char* label) { +    LL_LABEL_OBJECT_GL(GL_PROGRAM, mProgramObject, strlen(label), label); +} + +#endif | 
