Skip to content
Snippets Groups Projects
Commit d43b8d85 authored by Ptolemy's avatar Ptolemy
Browse files

SL-13019: Add debug logging of shaders used to track down macOSX / OSX GLSL linker errors

parent a387b38d
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
#include "OpenGL/OpenGL.h" #include "OpenGL/OpenGL.h"
#endif #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 // Lots of STL stuff in here, using namespace std to keep things more readable
using std::vector; using std::vector;
using std::pair; using std::pair;
...@@ -402,6 +406,10 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes, ...@@ -402,6 +406,10 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes,
mDefines["OLD_SELECT"] = "1"; mDefines["OLD_SELECT"] = "1";
#endif #endif
#if DEBUG_SHADER_INCLUDES
fprintf(stderr, "--- %s ---\n", mName.c_str());
#endif // DEBUG_SHADER_INCLUDES
//compile new source //compile new source
vector< pair<string,GLenum> >::iterator fileIter = mShaderFiles.begin(); vector< pair<string,GLenum> >::iterator fileIter = mShaderFiles.begin();
for ( ; fileIter != mShaderFiles.end(); fileIter++ ) for ( ; fileIter != mShaderFiles.end(); fileIter++ )
...@@ -485,12 +493,36 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes, ...@@ -485,12 +493,36 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes,
return success; 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) BOOL LLGLSLShader::attachVertexObject(std::string object_path)
{ {
if (LLShaderMgr::instance()->mVertexShaderObjects.count(object_path) > 0) if (LLShaderMgr::instance()->mVertexShaderObjects.count(object_path) > 0)
{ {
stop_glerror(); stop_glerror();
glAttachObjectARB(mProgramObject, LLShaderMgr::instance()->mVertexShaderObjects[object_path]); glAttachObjectARB(mProgramObject, LLShaderMgr::instance()->mVertexShaderObjects[object_path]);
#if DEBUG_SHADER_INCLUDES
dumpAttachObject("attachVertexObject", mProgramObject, object_path);
#endif // DEBUG_SHADER_INCLUDES
stop_glerror(); stop_glerror();
return TRUE; return TRUE;
} }
...@@ -507,6 +539,9 @@ BOOL LLGLSLShader::attachFragmentObject(std::string object_path) ...@@ -507,6 +539,9 @@ BOOL LLGLSLShader::attachFragmentObject(std::string object_path)
{ {
stop_glerror(); stop_glerror();
glAttachObjectARB(mProgramObject, LLShaderMgr::instance()->mFragmentShaderObjects[object_path]); glAttachObjectARB(mProgramObject, LLShaderMgr::instance()->mFragmentShaderObjects[object_path]);
#if DEBUG_SHADER_INCLUDES
dumpAttachObject("attachFragmentObject", mProgramObject, object_path);
#endif // DEBUG_SHADER_INCLUDES
stop_glerror(); stop_glerror();
return TRUE; return TRUE;
} }
...@@ -523,6 +558,10 @@ void LLGLSLShader::attachObject(GLhandleARB object) ...@@ -523,6 +558,10 @@ void LLGLSLShader::attachObject(GLhandleARB object)
{ {
stop_glerror(); stop_glerror();
glAttachObjectARB(mProgramObject, object); glAttachObjectARB(mProgramObject, object);
#if DEBUG_SHADER_INCLUDES
std::string object_path("???");
dumpAttachObject("attachObject", mProgramObject, object_path);
#endif // DEBUG_SHADER_INCLUDES
stop_glerror(); stop_glerror();
} }
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment