diff --git a/ext/native/thin3d/GLQueueRunner.cpp b/ext/native/thin3d/GLQueueRunner.cpp index 536847fc39..863398d745 100644 --- a/ext/native/thin3d/GLQueueRunner.cpp +++ b/ext/native/thin3d/GLQueueRunner.cpp @@ -101,12 +101,27 @@ void GLQueueRunner::RunInitSteps(const std::vector &steps) { GLint bufLength = 0; glGetProgramiv(program->program, GL_INFO_LOG_LENGTH, &bufLength); if (bufLength) { - char* buf = new char[bufLength]; - glGetProgramInfoLog(program->program, bufLength, NULL, buf); + char *buf = new char[bufLength]; + glGetProgramInfoLog(program->program, bufLength, nullptr, buf); + + // TODO: Could be other than vs/fs. Also, we're assuming order here... + const char *vsDesc = step.create_program.shaders[0]->desc.c_str(); + const char *fsDesc = step.create_program.num_shaders > 1 ? step.create_program.shaders[1]->desc.c_str() : nullptr; + const char *vsCode = step.create_program.shaders[0]->code.c_str(); + const char *fsCode = step.create_program.num_shaders > 1 ? step.create_program.shaders[1]->code.c_str() : nullptr; + Reporting::ReportMessage("Error in shader program link: info: %s\nfs: %s\n%s\nvs: %s\n%s", buf, fsDesc, fsCode, vsDesc, vsCode); + ELOG("Could not link program:\n %s", buf); - // We've thrown out the source at this point. Might want to do something about that. + ERROR_LOG(G3D, "VS desc:\n%s", vsDesc); + ERROR_LOG(G3D, "FS desc:\n%s", fsDesc); + ERROR_LOG(G3D, "VS:\n%s\n", vsCode); + ERROR_LOG(G3D, "FS:\n%s\n", fsCode); + #ifdef _WIN32 OutputDebugStringUTF8(buf); + OutputDebugStringUTF8(vsCode); + if (fsCode) + OutputDebugStringUTF8(fsCode); #endif delete[] buf; } else { @@ -166,6 +181,8 @@ void GLQueueRunner::RunInitSteps(const std::vector &steps) { step.create_shader.shader->valid = false; step.create_shader.shader->failed = true; } + // Before we throw away the code, attach it to the shader for debugging. + step.create_shader.shader->code = code; delete[] step.create_shader.code; step.create_shader.shader->valid = true; break; diff --git a/ext/native/thin3d/GLRenderManager.h b/ext/native/thin3d/GLRenderManager.h index bbc40210be..90502cbb24 100644 --- a/ext/native/thin3d/GLRenderManager.h +++ b/ext/native/thin3d/GLRenderManager.h @@ -76,6 +76,7 @@ public: // Warning: Won't know until a future frame. bool failed = false; std::string desc; + std::string code; }; class GLRProgram {