Error-reporting: improve reports for STGs and effects
When an effect defines no shader sources, special case this error to avoid confusing result from SGProgram. Add error-context for readNode STG loading, so failures inside an STG can be attributed
This commit is contained in:
parent
ed29d9b75d
commit
01233ba537
@ -993,6 +993,14 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sgprogram->getNumShaders() == 0) {
|
||||
simgear::reportFailure(simgear::LoadFailure::BadData,
|
||||
simgear::ErrorCode::LoadEffectsShaders,
|
||||
"No shader source code defined for effect",
|
||||
effect->filePath());
|
||||
}
|
||||
|
||||
for (const auto& key : prgKey.attributes) {
|
||||
program->addBindAttribLocation(key.first, key.second);
|
||||
}
|
||||
|
@ -580,7 +580,9 @@ struct ReaderWriterSTG::_ModelBin {
|
||||
}
|
||||
callback(token,name, SGGeod::fromDegM(obj._lon, obj._lat, obj._elev), obj._hdg,restofline);
|
||||
} else {
|
||||
SG_LOG( SG_TERRAIN, SG_ALERT, absoluteFileName << ": Unknown token '" << token << "'" );
|
||||
// SG_LOG( SG_TERRAIN, SG_ALERT, absoluteFileName << ": Unknown token '" << token << "'" );
|
||||
simgear::reportFailure(simgear::LoadFailure::Misconfigured, simgear::ErrorCode::BTGLoad,
|
||||
"Unknown STG token:" + token, absoluteFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -709,6 +711,7 @@ ReaderWriterSTG::readNode(const std::string& fileName, const osgDB::Options* opt
|
||||
{
|
||||
_ModelBin modelBin;
|
||||
SGBucket bucket(bucketIndexFromFileName(fileName));
|
||||
simgear::ErrorReportContext ec("terrain-bucket", bucket.gen_index_str());
|
||||
|
||||
// We treat 123.stg different than ./123.stg.
|
||||
// The difference is that ./123.stg as well as any absolute path
|
||||
@ -716,6 +719,7 @@ ReaderWriterSTG::readNode(const std::string& fileName, const osgDB::Options* opt
|
||||
// In contrast 123.stg uses the search paths to load a set of stg
|
||||
// files spread across the scenery directories.
|
||||
if (osgDB::getSimpleFileName(fileName) != fileName) {
|
||||
simgear::ErrorReportContext ec("terrain-stg", fileName);
|
||||
if (!modelBin.read(fileName, options))
|
||||
return ReadResult::FILE_NOT_FOUND;
|
||||
}
|
||||
@ -754,6 +758,7 @@ ReaderWriterSTG::readNode(const std::string& fileName, const osgDB::Options* opt
|
||||
|
||||
for (auto suffix : sgOpts->getSceneryPathSuffixes()) {
|
||||
const auto p = base / suffix / basePath / fileName;
|
||||
simgear::ErrorReportContext ec("terrain-stg", p.utf8Str());
|
||||
modelBin.read(p, options);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ void SGProgram::apply(osg::State& state) const
|
||||
std::string infoLog;
|
||||
_checkState = FailedToApply;
|
||||
getPCP(state)->getInfoLog(infoLog);
|
||||
|
||||
if (!infoLog.empty()) {
|
||||
// log all the shader source file names, to help in debugging link errors
|
||||
std::ostringstream os;
|
||||
for (int i = 0; i < getNumShaders(); ++i) {
|
||||
@ -64,6 +64,7 @@ void SGProgram::apply(osg::State& state) const
|
||||
"Shader program errors: " + infoLog +
|
||||
"\n\nShader sources:\n" + os.str(),
|
||||
_effectFilePath);
|
||||
}
|
||||
|
||||
for (int i = 0; i < getNumShaders(); ++i) {
|
||||
const auto shader = getShader(i);
|
||||
|
Loading…
Reference in New Issue
Block a user