summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llrender/llglslshader.cpp39
1 files changed, 39 insertions, 0 deletions
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<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