From a387b38d20bdbf1039c36cd7811e9cfb93809a2e Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Wed, 15 Apr 2020 09:26:29 -0700 Subject: Cleanup to coding standard --- indra/llrender/llglslshader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llrender/llglslshader.cpp') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 384e5bf99f..8cc3c50ec2 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -485,7 +485,8 @@ BOOL LLGLSLShader::createShader(std::vector * attributes, return success; } -BOOL LLGLSLShader::attachVertexObject(std::string object_path) { +BOOL LLGLSLShader::attachVertexObject(std::string object_path) +{ if (LLShaderMgr::instance()->mVertexShaderObjects.count(object_path) > 0) { stop_glerror(); -- cgit v1.2.3 From d43b8d8551518d95086f32f03aaee969a4b69916 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Wed, 15 Apr 2020 15:38:46 -0700 Subject: SL-13019: Add debug logging of shaders used to track down macOSX / OSX GLSL linker errors --- indra/llrender/llglslshader.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'indra/llrender/llglslshader.cpp') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 8cc3c50ec2..74cfa60b27 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -37,6 +37,10 @@ #include "OpenGL/OpenGL.h" #endif +// Print-print list of shader included source files that are linked together via glAttachObjectARB() +// 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 + // Lots of STL stuff in here, using namespace std to keep things more readable using std::vector; using std::pair; @@ -402,6 +406,10 @@ BOOL LLGLSLShader::createShader(std::vector * attributes, mDefines["OLD_SELECT"] = "1"; #endif +#if DEBUG_SHADER_INCLUDES + fprintf(stderr, "--- %s ---\n", mName.c_str()); +#endif // DEBUG_SHADER_INCLUDES + //compile new source vector< pair >::iterator fileIter = mShaderFiles.begin(); for ( ; fileIter != mShaderFiles.end(); fileIter++ ) @@ -485,12 +493,36 @@ BOOL LLGLSLShader::createShader(std::vector * attributes, return success; } +#if DEBUG_SHADER_INCLUDES +void dumpAttachObject( const char *func_name, GLhandleARB program_object, const std::string &object_path ) +{ + GLcharARB* info_log; + GLint info_len_expect = 0; + GLint info_len_actual = 0; + + glGetObjectParameterivARB(program_object, GL_OBJECT_INFO_LOG_LENGTH_ARB, &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); + fprintf(stderr, "%s\n", info_log); + delete [] info_log; + } +} +#endif // DEBUG_SHADER_INCLUDES + BOOL LLGLSLShader::attachVertexObject(std::string object_path) { if (LLShaderMgr::instance()->mVertexShaderObjects.count(object_path) > 0) { stop_glerror(); glAttachObjectARB(mProgramObject, LLShaderMgr::instance()->mVertexShaderObjects[object_path]); +#if DEBUG_SHADER_INCLUDES + dumpAttachObject("attachVertexObject", mProgramObject, object_path); +#endif // DEBUG_SHADER_INCLUDES stop_glerror(); return TRUE; } @@ -507,6 +539,9 @@ BOOL LLGLSLShader::attachFragmentObject(std::string object_path) { stop_glerror(); glAttachObjectARB(mProgramObject, LLShaderMgr::instance()->mFragmentShaderObjects[object_path]); +#if DEBUG_SHADER_INCLUDES + dumpAttachObject("attachFragmentObject", mProgramObject, object_path); +#endif // DEBUG_SHADER_INCLUDES stop_glerror(); return TRUE; } @@ -523,6 +558,10 @@ void LLGLSLShader::attachObject(GLhandleARB object) { stop_glerror(); glAttachObjectARB(mProgramObject, object); +#if DEBUG_SHADER_INCLUDES + std::string object_path("???"); + dumpAttachObject("attachObject", mProgramObject, object_path); +#endif // DEBUG_SHADER_INCLUDES stop_glerror(); } else -- cgit v1.2.3 From d357bf7ae5c5e0b6e66e7d82ce1677360b4cb990 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 1 Apr 2021 17:36:26 +0300 Subject: SL-14990 Turn on shader init logging after crash --- indra/llrender/llglslshader.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/llrender/llglslshader.cpp') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 74cfa60b27..4351f6e2c8 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -396,10 +396,18 @@ BOOL LLGLSLShader::createShader(std::vector * attributes, mLightHash = 0xFFFFFFFF; llassert_always(!mShaderFiles.empty()); - BOOL success = TRUE; // Create program mProgramObject = glCreateProgramObjectARB(); + if (mProgramObject == 0) + { + // Shouldn't happen if shader related extensions, like ARB_vertex_shader, exist. + LL_SHADER_LOADING_WARNS() << "Failed to create handle for shader: " << mName << LL_ENDL; + unloadInternal(); + return FALSE; + } + + BOOL success = TRUE; #if LL_DARWIN // work-around missing mix(vec3,vec3,bvec3) -- cgit v1.2.3