+#include <msp/io/print.h>
#include "module.h"
#include "resources.h"
-#include "glsl/compiler.h"
using namespace std;
{
SL::Compiler compiler;
compiler.set_source(src);
- compiler.compile(SL::Compiler::MODULE);
- prepared_source = compiler.get_combined_glsl();
- source_map = compiler.get_source_map();
+ compile(compiler);
}
void Module::load_source(IO::Base &io, Resources *res, const string &name)
{
SL::Compiler compiler;
compiler.load_source(io, res, name);
- compiler.compile(SL::Compiler::MODULE);
- prepared_source = compiler.get_combined_glsl();
- source_map = compiler.get_source_map();
+ compile(compiler);
}
void Module::load_source(IO::Base &io, const string &name)
load_source(io, 0, name);
}
+void Module::compile(SL::Compiler &compiler)
+{
+ compiler.compile(SL::Compiler::MODULE);
+ prepared_source = compiler.get_combined_glsl();
+ source_map = compiler.get_source_map();
+#ifdef DEBUG
+ string diagnostics = compiler.get_diagnostics();
+ if(!diagnostics.empty())
+ IO::print("Module diagnostics:\n%s\n", diagnostics);
+#endif
+}
+
} // namespace GL
} // namespace Msp
#include <string>
#include <msp/io/base.h>
+#include "glsl/compiler.h"
#include "glsl/sourcemap.h"
namespace Msp {
void set_source(const std::string &);
void load_source(IO::Base &, Resources *, const std::string &);
void load_source(IO::Base &, const std::string &);
+private:
+ void compile(SL::Compiler &);
+public:
const std::string &get_prepared_source() const { return prepared_source; }
const SL::SourceMap &get_source_map() const { return source_map; }
};
compiler.set_source(module->get_prepared_source(), "<module>");
compiler.specialize(spec_values);
compiler.compile(SL::Compiler::PROGRAM);
+#ifdef DEBUG
+ string diagnostics = compiler.get_diagnostics();
+ if(!diagnostics.empty())
+ IO::print("Program diagnostics:\n%s\n", diagnostics);
+#endif
vector<SL::Stage::Type> stages = compiler.get_stages();
for(vector<SL::Stage::Type>::const_iterator i=stages.begin(); i!=stages.end(); ++i)
try
{
compiler.compile(GL::SL::Compiler::PROGRAM);
+ string diag = compiler.get_diagnostics();
+ if(!diag.empty())
+ IO::print("Diagnostic messages from compiler:\n%s\n", diag);
}
catch(const GL::SL::invalid_shader_source &exc)
{