summaryrefslogtreecommitdiff
path: root/indra/llrender/llglslshader.cpp
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2024-06-10 10:43:38 -0500
committerGitHub <noreply@github.com>2024-06-10 10:43:38 -0500
commit227e9be06832515fd10eb496d4a2a4528d1ebd92 (patch)
treedfe366ee3ea6c4fe4b08dc080fd07313e279a7d5 /indra/llrender/llglslshader.cpp
parent33ddedd6b557ed9130dd8cd3b8327a697614a3ac (diff)
#1654 generate normals and tangents according to gltf specification (#1662)
* Disable unloading of objects in background. * Add unlit GLTF shader variant
Diffstat (limited to 'indra/llrender/llglslshader.cpp')
-rw-r--r--indra/llrender/llglslshader.cpp71
1 files changed, 19 insertions, 52 deletions
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 8ea134393a..6a60914b80 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -381,13 +381,10 @@ void LLGLSLShader::unloadInternal()
stop_glerror();
}
-bool LLGLSLShader::createShader(std::vector<LLStaticHashedString>* attributes,
- std::vector<LLStaticHashedString>* uniforms,
- U32 varying_count,
- const char** varyings)
+bool LLGLSLShader::createShader()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
-
+
unloadInternal();
sInstances.insert(this);
@@ -454,11 +451,11 @@ bool LLGLSLShader::createShader(std::vector<LLStaticHashedString>* attributes,
// Map attributes and uniforms
if (success)
{
- success = mapAttributes(attributes);
+ success = mapAttributes();
}
if (success)
{
- success = mapUniforms(uniforms);
+ success = mapUniforms();
}
if (!success)
{
@@ -469,7 +466,7 @@ bool LLGLSLShader::createShader(std::vector<LLStaticHashedString>* attributes,
{
LL_SHADER_LOADING_WARNS() << "Failed to link using shader level " << mShaderLevel << " trying again using shader level " << (mShaderLevel - 1) << LL_ENDL;
mShaderLevel--;
- return createShader(attributes, uniforms);
+ return createShader();
}
else
{
@@ -602,7 +599,7 @@ void LLGLSLShader::attachObjects(GLuint* objects, S32 count)
}
}
-bool LLGLSLShader::mapAttributes(const std::vector<LLStaticHashedString>* attributes)
+bool LLGLSLShader::mapAttributes()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
@@ -621,11 +618,10 @@ bool LLGLSLShader::mapAttributes(const std::vector<LLStaticHashedString>* attrib
}
mAttribute.clear();
- U32 numAttributes = (attributes == NULL) ? 0 : attributes->size();
#if LL_RELEASE_WITH_DEBUG_INFO
- mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size() + numAttributes, { -1, NULL });
+ mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size(), { -1, NULL });
#else
- mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size() + numAttributes, -1);
+ mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size(), -1);
#endif
if (res)
@@ -649,19 +645,6 @@ bool LLGLSLShader::mapAttributes(const std::vector<LLStaticHashedString>* attrib
LL_DEBUGS("ShaderUniform") << "Attribute " << name << " assigned to channel " << index << LL_ENDL;
}
}
- if (attributes != NULL)
- {
- for (U32 i = 0; i < numAttributes; i++)
- {
- const char* name = (*attributes)[i].String().c_str();
- S32 index = glGetAttribLocation(mProgramObject, name);
- if (index != -1)
- {
- mAttribute[LLShaderMgr::instance()->mReservedAttribs.size() + i] = index;
- LL_DEBUGS("ShaderUniform") << "Attribute " << name << " assigned to channel " << index << LL_ENDL;
- }
- }
- }
return true;
}
@@ -669,7 +652,7 @@ bool LLGLSLShader::mapAttributes(const std::vector<LLStaticHashedString>* attrib
return false;
}
-void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString>* uniforms)
+void LLGLSLShader::mapUniform(GLint index)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
@@ -756,21 +739,6 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString>* u
return;
}
}
-
- if (uniforms != NULL)
- {
- for (U32 i = 0; i < uniforms->size(); i++)
- {
- if ((mUniform[i + LLShaderMgr::instance()->mReservedUniforms.size()] == -1)
- && ((*uniforms)[i].String() == name))
- {
- //found it
- mUniform[i + LLShaderMgr::instance()->mReservedUniforms.size()] = location;
- mTexture[i + LLShaderMgr::instance()->mReservedUniforms.size()] = mapUniformTextureChannel(location, type, size);
- return;
- }
- }
- }
}
}
@@ -830,7 +798,7 @@ GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type, GLint
return -1;
}
-bool LLGLSLShader::mapUniforms(const vector<LLStaticHashedString>* uniforms)
+bool LLGLSLShader::mapUniforms()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
@@ -843,9 +811,8 @@ bool LLGLSLShader::mapUniforms(const vector<LLStaticHashedString>* uniforms)
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);
+ mUniform.resize(LLShaderMgr::instance()->mReservedUniforms.size(), -1);
+ mTexture.resize(LLShaderMgr::instance()->mReservedUniforms.size(), -1);
bind();
@@ -946,26 +913,26 @@ bool LLGLSLShader::mapUniforms(const vector<LLStaticHashedString>* uniforms)
if (specularDiff || bumpLessDiff || envLessDiff || refLessDiff)
{
- mapUniform(diffuseMap, uniforms);
+ mapUniform(diffuseMap);
skip_index.insert(diffuseMap);
if (-1 != specularMap) {
- mapUniform(specularMap, uniforms);
+ mapUniform(specularMap);
skip_index.insert(specularMap);
}
if (-1 != bumpMap) {
- mapUniform(bumpMap, uniforms);
+ mapUniform(bumpMap);
skip_index.insert(bumpMap);
}
if (-1 != environmentMap) {
- mapUniform(environmentMap, uniforms);
+ mapUniform(environmentMap);
skip_index.insert(environmentMap);
}
if (-1 != reflectionMap) {
- mapUniform(reflectionMap, uniforms);
+ mapUniform(reflectionMap);
skip_index.insert(reflectionMap);
}
}
@@ -979,7 +946,7 @@ bool LLGLSLShader::mapUniforms(const vector<LLStaticHashedString>* uniforms)
if (skip_index.end() != skip_index.find(i)) continue;
//........................................................................................
- mapUniform(i, uniforms);
+ mapUniform(i);
}
//........................................................................................................................................
@@ -1057,7 +1024,7 @@ void LLGLSLShader::bind()
}
}
-void LLGLSLShader::bind(U32 variant)
+void LLGLSLShader::bind(U8 variant)
{
llassert(mGLTFVariants.size() == LLGLSLShader::NUM_GLTF_VARIANTS);
llassert(variant < LLGLSLShader::NUM_GLTF_VARIANTS);