From 7be9c43f286671893ff0a9dee13d721a6731255b Mon Sep 17 00:00:00 2001 From: Brad Linden <46733234+brad-linden@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:49:09 -0800 Subject: 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 --- indra/llrender/llglslshader.cpp | 5 +++- indra/llrender/llrender.cpp | 3 ++- indra/llrender/llshadermgr.cpp | 14 ++++------- .../app_settings/shaders/class1/deferred/CASF.glsl | 2 +- .../shaders/class1/interface/radianceGenF.glsl | 2 +- .../class3/deferred/screenSpaceReflPostF.glsl | 2 +- indra/newview/llfeaturemanager.cpp | 15 ++++++++++++ indra/newview/llviewershadermgr.cpp | 9 +++++++- indra/newview/pipeline.cpp | 27 ++++++++++++++-------- 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(); -- cgit v1.2.3 From 8d52d06fcbffa33dad4412480471275068387c87 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 19 Nov 2024 22:22:43 +0200 Subject: Crash at getDiscardLevel() --- indra/newview/llviewertexturelist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 5f678d4008..2dc0458d99 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1061,7 +1061,7 @@ F32 LLViewerTextureList::updateImagesCreateTextures(F32 max_time) imagep->mCreatePending = false; mCreateTextureList.pop(); - if (imagep->getDiscardLevel() < imagep->getDesiredDiscardLevel()) + if (imagep->hasGLTexture() && imagep->getDiscardLevel() < imagep->getDesiredDiscardLevel()) { LL_WARNS_ONCE("Texture") << "Texture will be downscaled immediately after loading." << LL_ENDL; imagep->scaleDown(); -- cgit v1.2.3 From 6c6b38821ef0ea452b640b31006a8ef4f2dfef55 Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Wed, 20 Nov 2024 01:08:35 +0200 Subject: #3093 World Map tiles are blurry --- indra/newview/llviewertexture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index c10e28d688..03c586b270 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -2917,7 +2917,7 @@ void LLViewerLODTexture::processTextureStats() mDesiredDiscardLevel = 0; } // Generate the request priority and render priority - else if (mDontDiscard || !mUseMipMaps) + else if (mDontDiscard || !mUseMipMaps || (getFTType() == FTT_MAP_TILE)) { mDesiredDiscardLevel = 0; if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT) -- cgit v1.2.3