Improved the formating of GLSL source that is passed to OpenGL to make debugging shaders easier.

This commit is contained in:
Robert Osfield
2017-10-14 09:03:08 +01:00
parent 2303d6afc4
commit 0a5c6d3fd6
2 changed files with 24 additions and 10 deletions

View File

@@ -624,13 +624,6 @@ void Shader::PerContextShader::compileShader(osg::State& state)
}
if (osg::getNotifyLevel()>=osg::INFO)
{
std::string sourceWithLineNumbers = insertLineNumbers(source);
OSG_INFO << "\nCompiling " << _shader->getTypename()
<< " source:\n" << sourceWithLineNumbers << std::endl;
}
GLint compiled = GL_FALSE;
// OSG_NOTICE<<"Compiling PerContextShader "<<this<<" DefineString="<<getDefineString()<<std::endl;
@@ -639,6 +632,13 @@ void Shader::PerContextShader::compileShader(osg::State& state)
{
const GLchar* sourceText = reinterpret_cast<const GLchar*>(source.c_str());
_extensions->glShaderSource( _glShaderHandle, 1, &sourceText, NULL );
if (osg::getNotifyLevel()>=osg::INFO)
{
std::string sourceWithLineNumbers = insertLineNumbers(source);
OSG_INFO << "\nCompiling A :" << _shader->getTypename()
<< " source:\n" << sourceWithLineNumbers << std::endl;
}
}
else
{
@@ -681,6 +681,12 @@ void Shader::PerContextShader::compileShader(osg::State& state)
sourceText[2] = reinterpret_cast<const GLchar*>(source.c_str());
_extensions->glShaderSource( _glShaderHandle, 3, sourceText, NULL );
if (osg::getNotifyLevel()>=osg::INFO)
{
std::string sourceWithLineNumbers = insertLineNumbers(versionLine+_defineStr+source);
OSG_INFO << "\nCompiling B: " << _shader->getTypename()
<< " source:\n" << sourceWithLineNumbers << std::endl;
}
// OSG_NOTICE<<" Version Line : ["<<std::endl<<versionLine<<"]"<<std::endl;
// OSG_NOTICE<<" DefineStr : ["<<std::endl<<_defineStr<<"]"<<std::endl;
@@ -693,6 +699,14 @@ void Shader::PerContextShader::compileShader(osg::State& state)
sourceText[1] = reinterpret_cast<const GLchar*>(source.c_str());
_extensions->glShaderSource( _glShaderHandle, 2, sourceText, NULL );
if (osg::getNotifyLevel()>=osg::INFO)
{
std::string sourceWithLineNumbers = insertLineNumbers(_defineStr+source);
OSG_INFO << "\nCompiling C: " << _shader->getTypename()
<< " source:\n" << sourceWithLineNumbers << std::endl;
}
// OSG_NOTICE<<" DefineStr : ["<<std::endl<<_defineStr<<"]"<<std::endl;
// OSG_NOTICE<<" Source : ["<<std::endl<<source<<"]"<<std::endl;
}

View File

@@ -1272,9 +1272,9 @@ namespace State_Utils
bool State::convertVertexShaderSourceToOsgBuiltIns(std::string& source) const
{
OSG_INFO<<"State::convertShaderSourceToOsgBuiltIns()"<<std::endl;
OSG_DEBUG<<"State::convertShaderSourceToOsgBuiltIns()"<<std::endl;
OSG_INFO<<"++Before Converted source "<<std::endl<<source<<std::endl<<"++++++++"<<std::endl;
OSG_DEBUG<<"++Before Converted source "<<std::endl<<source<<std::endl<<"++++++++"<<std::endl;
State_Utils::substitudeEnvVars(*this, source);
@@ -1335,7 +1335,7 @@ bool State::convertVertexShaderSourceToOsgBuiltIns(std::string& source) const
}
}
OSG_INFO<<"-------- Converted source "<<std::endl<<source<<std::endl<<"----------------"<<std::endl;
OSG_DEBUG<<"-------- Converted source "<<std::endl<<source<<std::endl<<"----------------"<<std::endl;
return true;
}