SL-13019: Add debug logging of shaders used to track down macOSX / OSX GLSL linker errors
parent
a387b38d20
commit
d43b8d8551
|
|
@ -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<LLStaticHashedString> * 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<string,GLenum> >::iterator fileIter = mShaderFiles.begin();
|
||||
for ( ; fileIter != mShaderFiles.end(); fileIter++ )
|
||||
|
|
@ -485,12 +493,36 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue