Hi James, Its not direct answer to your questions but a code snippet overloading Program which I used to change shader variant depending on compilation/link result (from most advanced to more basic fallbacks). This approach was quite simple I tested Program compilation result (including compilation/ling log) by simply checking if my Program was really applied after Program::apply() and if not adopted fallback to less demanding shaders. Not sure if this will solve your problem but perhaps will be a step forward to proper solution.
class MyProgram: public osg::Program { public: MyProgram( ): _shaderVariant( DefaultShaderVariant ) { osg::Shader * vertShader = osgDB::readShaderFile( osg::Shader::VERTEX, "MyVertexShader.glsl" ); osg::Shader * fragShader = osgDB::readShaderFile( osg::Shader::FRAGMENT, "MyFragmentShader.glsl" ); addShader( vertShader ); addShader( fragShader ); notified.resize( DefaultShaderVariant + 1 ); } void setDigitDefine( std::string MACRO, int DIGIT ) const { // For brevity code removed but // this function simply checks shader sources and // finds all ocurences of // #define MACRO DEFAULT_DIGIT // and replaces them to // #define MACRO DIGIT // to select shader codepath dependant on macro value } void apply( osg::State& state ) const { while( _shaderVariant > 0 ) { osg::Program::apply( state ); // Break if program was applied ie its not null if( state.getLastAppliedProgramObject() != NULL ) { if( !notified[0] ) { std::cout<< "INFO: MyProgram - GLSL Compilation Succeeded." << std::endl; std::cout<< " Shader variant: " << _shaderVariant << std::endl; std::cout<< " GL Vendor: " << glGetString(GL_VENDOR) << std::endl; std::cout<< " GL Renderer: " << glGetString(GL_RENDERER) << std::endl; std::cout<< " GL Version: " << glGetString(GL_VERSION) << std::endl; notified[0] = true; } break; } if( !notified[_shaderVariant] ) { std::string infoLog; getPCP( state )->getInfoLog( infoLog ); std::cout<< "ERROR: MyProgram - GLSL Compilation Failed." << std::endl; std::cout<< " Shader variant: " << _shaderVariant << std::endl; std::cout<< " GL Vendor: " << glGetString(GL_VENDOR) << std::endl; std::cout<< " GL Renderer: " << glGetString(GL_RENDERER) << std::endl; std::cout<< " GL Version: " << glGetString(GL_VERSION) << std::endl; std::cout<< infoLog << std::endl; notified[_shaderVariant] = true; } // Switch to fallback variants if program link failed setDigitDefine( "SHADER_VARIANT", --_shaderVariant ); } } protected: mutable int _shaderVariant; static const int DefaultShaderVariant = 2; mutable std::vector< bool > notified; }; Cheers, Wojtek Lewandowski śr., 24 lut 2021 o 19:04 'James Turner' via OpenSceneGraph Users < osg-us...@googlegroups.com> napisał(a): > I’m trying to extract shader compile and link info logs at runtime, so I > can log+report them. > > I note osg::Program::getGlProgramInfoLog exists, obviously it takes a > context ID since the PerContextProgram is what has the actual errors. > > Two things I need help with: > > 1) does the program log also contain shader compile errors, or is this > only the link log? I don’t see a corresponding APi on osg::Shader, is why I > ask > > 2) *when* can I call the log functions and expect to get valid results? > Given the OSG drawing model, obviously the log won’t be available > immediately when creating the Program.. Do I need to use a DrawCallback to > check the log after the first time the Program has been used? > > I looked for examples of using getGlProgramInfoLog but unfortunately > couldn't find any, maybe pointing me at one would answer both of these > points. > > -- > You received this message because you are subscribed to the Google Groups > "OpenSceneGraph Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to osg-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/osg-users/437023da-c7b2-4bfb-a6b9-6d6613236e04n%40googlegroups.com > <https://groups.google.com/d/msgid/osg-users/437023da-c7b2-4bfb-a6b9-6d6613236e04n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org