summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Linden <46733234+brad-linden@users.noreply.github.com>2024-11-19 10:49:09 -0800
committerGitHub <noreply@github.com>2024-11-19 10:49:09 -0800
commit7be9c43f286671893ff0a9dee13d721a6731255b (patch)
treeb49f62290187b2b719d1fb3b2cdbb467c64b4bfd
parentc654dac4b7593355a5754042d0b43e03924b3efb (diff)
brad/2744 handle shader errors (#3105)
* Partial solution to secondlife/viewer#2744 crash with better error handling. Handles shader compile errors better, and should turn crash into an LL_ERRS assertion failure. Strengthed more assertions and improved shader error line numbers * Even more error handling to get a handle on crash secondlife/viewer#2744 * Improved GLSL correctness on Intel chips that lack OpenGL 4.6 support. secondlife/viewer#2744 * Removed non-working fallback code for gDeferredPostProgram * Fixed incorrect llmax call
-rw-r--r--indra/llrender/llglslshader.cpp5
-rw-r--r--indra/llrender/llrender.cpp3
-rw-r--r--indra/llrender/llshadermgr.cpp14
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/CASF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl2
-rw-r--r--indra/newview/llfeaturemanager.cpp15
-rw-r--r--indra/newview/llviewershadermgr.cpp9
-rw-r--r--indra/newview/pipeline.cpp27
9 files changed, 54 insertions, 25 deletions
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 6ba5463acd..45bb24a5b7 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -1046,7 +1046,7 @@ void LLGLSLShader::bind()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
- llassert(mProgramObject != 0);
+ llassert_always(mProgramObject != 0);
gGL.flush();
@@ -1069,6 +1069,9 @@ void LLGLSLShader::bind()
LLShaderMgr::instance()->updateShaderUniforms(this);
mUniformsDirty = false;
}
+
+ llassert_always(sCurBoundShaderPtr != nullptr);
+ llassert_always(sCurBoundShader == mProgramObject);
}
void LLGLSLShader::bind(U8 variant)
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index c8a9fb4893..eb2cd560a6 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -1569,7 +1569,8 @@ void LLRender::flush()
if (mCount > 0)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE;
- llassert(LLGLSLShader::sCurBoundShaderPtr != nullptr);
+ llassert_always(LLGLSLShader::sCurBoundShaderPtr != nullptr);
+
if (!mUIOffset.empty())
{
sUICalls++;
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index 150277c8df..e02dd4771e 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -559,17 +559,11 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev
}
else if (major_version == 3)
{
- if (minor_version < 10)
+ if (minor_version <= 29)
{
- shader_code_text[shader_code_count++] = strdup("#version 300\n");
- }
- else if (minor_version <= 19)
- {
- shader_code_text[shader_code_count++] = strdup("#version 310\n");
- }
- else if (minor_version <= 29)
- {
- shader_code_text[shader_code_count++] = strdup("#version 320\n");
+ // OpenGL 3.2 had GLSL version 1.50. anything after that the version numbers match.
+ // https://www.khronos.org/opengl/wiki/Core_Language_(GLSL)#OpenGL_and_GLSL_versions
+ shader_code_text[shader_code_count++] = strdup("#version 150\n");
}
else
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/CASF.glsl b/indra/newview/app_settings/shaders/class1/deferred/CASF.glsl
index e80c59b39f..017855325c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/CASF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/CASF.glsl
@@ -1150,7 +1150,7 @@ vec3 linear_to_srgb(vec3 cl);
AF3 ASignedF3(AF3 m){return ASatF3(m*AF3_(A_INFN_F));}
AF4 ASignedF4(AF4 m){return ASatF4(m*AF4_(A_INFN_F));}
//------------------------------------------------------------------------------------------------------------------------------
- AF1 AGtZeroF1(AF1 m){return ASatF1(m*AF1_(A_INFP_F));}
+// #2744 avoid constant overflow AF1 AGtZeroF1(AF1 m){return ASatF1(m*AF1_(A_INFP_F));}
AF2 AGtZeroF2(AF2 m){return ASatF2(m*AF2_(A_INFP_F));}
AF3 AGtZeroF3(AF3 m){return ASatF3(m*AF3_(A_INFP_F));}
AF4 AGtZeroF4(AF4 m){return ASatF4(m*AF4_(A_INFP_F));}
diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl
index feb0947649..b3964c9215 100644
--- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl
@@ -130,7 +130,7 @@ vec4 prefilterEnvMap(vec3 R)
float totalWeight = 0.0;
float envMapDim = float(textureSize(reflectionProbes, 0).s);
float roughness = mipLevel/max_probe_lod;
- int numSamples = max(int(PROBE_FILTER_SAMPLES*roughness), 1);
+ uint numSamples = uint(max(PROBE_FILTER_SAMPLES*roughness, 1));
float numMips = max_probe_lod+1;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl
index 9ac389f926..dc135243a6 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl
@@ -81,7 +81,7 @@ void main()
vec4 collectedColor = vec4(0);
- float w = tapScreenSpaceReflection(4, tc, pos, norm.xyz, collectedColor, diffuseMap, 0);
+ float w = tapScreenSpaceReflection(4, tc, pos, norm.xyz, collectedColor, diffuseMap, 0.f);
collectedColor.rgb *= specCol.rgb;
diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp
index b5d8f70c2e..c5d074a5e8 100644
--- a/indra/newview/llfeaturemanager.cpp
+++ b/indra/newview/llfeaturemanager.cpp
@@ -655,6 +655,21 @@ void LLFeatureManager::applyBaseMasks()
if (gGLManager.mIsIntel)
{
maskFeatures("Intel");
+ if (gGLManager.mGLVersion < 4.59f)
+ {
+ // if we don't have OpenGL 4.6 on intel, set it to OpenGL 3.3
+ // we also want to trigger the GL3 fallbacks on these chipsets
+ // this is expected to be mainly pre-Haswell Intel HD Graphics 4X00 and 5X00.
+ // A lot of these chips claim 4.3 or 4.4 support, but don't seem to work.
+ // https://code.blender.org/2019/04/supported-gpus-in-blender-2-80/
+ // https://docs.blender.org/manual/en/latest/troubleshooting/gpu/windows/intel.html#legacy-intel-hd-4000-5000
+ // https://www.intel.com/content/www/us/en/support/articles/000005524/graphics.html
+ // this will disable things like reflection probes, HDR, FXAA and SMAA
+ gGLManager.mGLVersion = llmin(gGLManager.mGLVersion, 3.33f);
+ // and select GLSL version for OpenGL 3.3
+ gGLManager.mGLSLVersionMajor = 3;
+ gGLManager.mGLSLVersionMinor = 30;
+ }
}
if (gGLManager.mIsApple)
{
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index f5af9cc397..cdebb08b18 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -2501,7 +2501,14 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gCASProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER));
gCASProgram.mShaderFiles.push_back(make_pair("deferred/CASF.glsl", GL_FRAGMENT_SHADER));
gCASProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
- gCASProgram.createShader();
+ success = gCASProgram.createShader();
+ // llassert(success);
+ if (!success)
+ {
+ LL_WARNS() << "Failed to create shader '" << gCASProgram.mName << "', disabling!" << LL_ENDL;
+ // continue as if this shader never happened
+ success = true;
+ }
}
if (success)
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index d8bd6fc882..6bef6b3438 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1436,15 +1436,24 @@ void LLPipeline::createLUTBuffers()
mPbrBrdfLut.allocate(512, 512, GL_RG16F);
mPbrBrdfLut.bindTarget();
- gDeferredGenBrdfLutProgram.bind();
-
- gGL.begin(LLRender::TRIANGLE_STRIP);
- gGL.vertex2f(-1, -1);
- gGL.vertex2f(-1, 1);
- gGL.vertex2f(1, -1);
- gGL.vertex2f(1, 1);
- gGL.end();
- gGL.flush();
+
+ if (gDeferredGenBrdfLutProgram.isComplete())
+ {
+ gDeferredGenBrdfLutProgram.bind();
+ llassert_always(LLGLSLShader::sCurBoundShaderPtr != nullptr);
+
+ gGL.begin(LLRender::TRIANGLE_STRIP);
+ gGL.vertex2f(-1, -1);
+ gGL.vertex2f(-1, 1);
+ gGL.vertex2f(1, -1);
+ gGL.vertex2f(1, 1);
+ gGL.end();
+ gGL.flush();
+ }
+ else
+ {
+ LL_WARNS("Brad") << gDeferredGenBrdfLutProgram.mName << " failed to load, cannot be used!" << LL_ENDL;
+ }
gDeferredGenBrdfLutProgram.unbind();
mPbrBrdfLut.flush();