Skip to content

Commit 2fd17d2

Browse files
brad-lindenakleshchev
authored andcommitted
brad/2744 handle shader errors (#3105)
* Partial solution to #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 #2744 * Improved GLSL correctness on Intel chips that lack OpenGL 4.6 support. #2744 * Removed non-working fallback code for gDeferredPostProgram * Fixed incorrect llmax call
1 parent 56093cb commit 2fd17d2

File tree

9 files changed

+54
-25
lines changed

9 files changed

+54
-25
lines changed

indra/llrender/llglslshader.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ void LLGLSLShader::bind()
10461046
{
10471047
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
10481048

1049-
llassert(mProgramObject != 0);
1049+
llassert_always(mProgramObject != 0);
10501050

10511051
gGL.flush();
10521052

@@ -1069,6 +1069,9 @@ void LLGLSLShader::bind()
10691069
LLShaderMgr::instance()->updateShaderUniforms(this);
10701070
mUniformsDirty = false;
10711071
}
1072+
1073+
llassert_always(sCurBoundShaderPtr != nullptr);
1074+
llassert_always(sCurBoundShader == mProgramObject);
10721075
}
10731076

10741077
void LLGLSLShader::bind(U8 variant)

indra/llrender/llrender.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,8 @@ void LLRender::flush()
15691569
if (mCount > 0)
15701570
{
15711571
LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE;
1572-
llassert(LLGLSLShader::sCurBoundShaderPtr != nullptr);
1572+
llassert_always(LLGLSLShader::sCurBoundShaderPtr != nullptr);
1573+
15731574
if (!mUIOffset.empty())
15741575
{
15751576
sUICalls++;

indra/llrender/llshadermgr.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -559,17 +559,11 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev
559559
}
560560
else if (major_version == 3)
561561
{
562-
if (minor_version < 10)
562+
if (minor_version <= 29)
563563
{
564-
shader_code_text[shader_code_count++] = strdup("#version 300\n");
565-
}
566-
else if (minor_version <= 19)
567-
{
568-
shader_code_text[shader_code_count++] = strdup("#version 310\n");
569-
}
570-
else if (minor_version <= 29)
571-
{
572-
shader_code_text[shader_code_count++] = strdup("#version 320\n");
564+
// OpenGL 3.2 had GLSL version 1.50. anything after that the version numbers match.
565+
// https://www.khronos.org/opengl/wiki/Core_Language_(GLSL)#OpenGL_and_GLSL_versions
566+
shader_code_text[shader_code_count++] = strdup("#version 150\n");
573567
}
574568
else
575569
{

indra/newview/app_settings/shaders/class1/deferred/CASF.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ vec3 linear_to_srgb(vec3 cl);
11511151
AF3 ASignedF3(AF3 m){return ASatF3(m*AF3_(A_INFN_F));}
11521152
AF4 ASignedF4(AF4 m){return ASatF4(m*AF4_(A_INFN_F));}
11531153
//------------------------------------------------------------------------------------------------------------------------------
1154-
AF1 AGtZeroF1(AF1 m){return ASatF1(m*AF1_(A_INFP_F));}
1154+
// #2744 avoid constant overflow AF1 AGtZeroF1(AF1 m){return ASatF1(m*AF1_(A_INFP_F));}
11551155
AF2 AGtZeroF2(AF2 m){return ASatF2(m*AF2_(A_INFP_F));}
11561156
AF3 AGtZeroF3(AF3 m){return ASatF3(m*AF3_(A_INFP_F));}
11571157
AF4 AGtZeroF4(AF4 m){return ASatF4(m*AF4_(A_INFP_F));}

indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ vec4 prefilterEnvMap(vec3 R)
130130
float totalWeight = 0.0;
131131
float envMapDim = float(textureSize(reflectionProbes, 0).s);
132132
float roughness = mipLevel/max_probe_lod;
133-
int numSamples = max(int(PROBE_FILTER_SAMPLES*roughness), 1);
133+
uint numSamples = uint(max(PROBE_FILTER_SAMPLES*roughness, 1));
134134

135135
float numMips = max_probe_lod+1;
136136

indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void main()
8181

8282
vec4 collectedColor = vec4(0);
8383

84-
float w = tapScreenSpaceReflection(4, tc, pos, norm.xyz, collectedColor, diffuseMap, 0);
84+
float w = tapScreenSpaceReflection(4, tc, pos, norm.xyz, collectedColor, diffuseMap, 0.f);
8585

8686
collectedColor.rgb *= specCol.rgb;
8787

indra/newview/llfeaturemanager.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,21 @@ void LLFeatureManager::applyBaseMasks()
627627
if (gGLManager.mIsIntel)
628628
{
629629
maskFeatures("Intel");
630+
if (gGLManager.mGLVersion < 4.59f)
631+
{
632+
// if we don't have OpenGL 4.6 on intel, set it to OpenGL 3.3
633+
// we also want to trigger the GL3 fallbacks on these chipsets
634+
// this is expected to be mainly pre-Haswell Intel HD Graphics 4X00 and 5X00.
635+
// A lot of these chips claim 4.3 or 4.4 support, but don't seem to work.
636+
// https://code.blender.org/2019/04/supported-gpus-in-blender-2-80/
637+
// https://docs.blender.org/manual/en/latest/troubleshooting/gpu/windows/intel.html#legacy-intel-hd-4000-5000
638+
// https://www.intel.com/content/www/us/en/support/articles/000005524/graphics.html
639+
// this will disable things like reflection probes, HDR, FXAA and SMAA
640+
gGLManager.mGLVersion = llmin(gGLManager.mGLVersion, 3.33f);
641+
// and select GLSL version for OpenGL 3.3
642+
gGLManager.mGLSLVersionMajor = 3;
643+
gGLManager.mGLSLVersionMinor = 30;
644+
}
630645
}
631646
if (gGLManager.mIsApple)
632647
{

indra/newview/llviewershadermgr.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2539,7 +2539,14 @@ bool LLViewerShaderMgr::loadShadersDeferred()
25392539
gCASProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER));
25402540
gCASProgram.mShaderFiles.push_back(make_pair("deferred/CASF.glsl", GL_FRAGMENT_SHADER));
25412541
gCASProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
2542-
gCASProgram.createShader();
2542+
success = gCASProgram.createShader();
2543+
// llassert(success);
2544+
if (!success)
2545+
{
2546+
LL_WARNS() << "Failed to create shader '" << gCASProgram.mName << "', disabling!" << LL_ENDL;
2547+
// continue as if this shader never happened
2548+
success = true;
2549+
}
25432550
}
25442551

25452552
if (success)

indra/newview/pipeline.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,15 +1435,24 @@ void LLPipeline::createLUTBuffers()
14351435

14361436
mPbrBrdfLut.allocate(512, 512, GL_RG16F);
14371437
mPbrBrdfLut.bindTarget();
1438-
gDeferredGenBrdfLutProgram.bind();
1439-
1440-
gGL.begin(LLRender::TRIANGLE_STRIP);
1441-
gGL.vertex2f(-1, -1);
1442-
gGL.vertex2f(-1, 1);
1443-
gGL.vertex2f(1, -1);
1444-
gGL.vertex2f(1, 1);
1445-
gGL.end();
1446-
gGL.flush();
1438+
1439+
if (gDeferredGenBrdfLutProgram.isComplete())
1440+
{
1441+
gDeferredGenBrdfLutProgram.bind();
1442+
llassert_always(LLGLSLShader::sCurBoundShaderPtr != nullptr);
1443+
1444+
gGL.begin(LLRender::TRIANGLE_STRIP);
1445+
gGL.vertex2f(-1, -1);
1446+
gGL.vertex2f(-1, 1);
1447+
gGL.vertex2f(1, -1);
1448+
gGL.vertex2f(1, 1);
1449+
gGL.end();
1450+
gGL.flush();
1451+
}
1452+
else
1453+
{
1454+
LL_WARNS("Brad") << gDeferredGenBrdfLutProgram.mName << " failed to load, cannot be used!" << LL_ENDL;
1455+
}
14471456

14481457
gDeferredGenBrdfLutProgram.unbind();
14491458
mPbrBrdfLut.flush();

0 commit comments

Comments
 (0)