X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogramcompiler.cpp;h=2dabd7cd8203ff0910eb97c2528e354e0b3943ff;hb=eb6a546dcffc1b67f0a23d8b075fbdc86a2872a0;hp=c35fa275c2b1bbadbcfbfb8f113cf68d165d4a8a;hpb=6dc2da27f0831d4172fcfeba4900616fd6c844b8;p=libs%2Fgl.git diff --git a/source/programcompiler.cpp b/source/programcompiler.cpp index c35fa275..2dabd7cd 100644 --- a/source/programcompiler.cpp +++ b/source/programcompiler.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include "error.h" @@ -39,20 +40,25 @@ ProgramCompiler::ProgramCompiler(): module(0) { } -void ProgramCompiler::compile(const string &source) +void ProgramCompiler::compile(const string &source, const string &src_name) { resources = 0; - module = &parser.parse(source); + module = &parser.parse(source, src_name); process(); } -void ProgramCompiler::compile(IO::Base &io, Resources *res) +void ProgramCompiler::compile(IO::Base &io, Resources *res, const string &src_name) { resources = res; - module = &parser.parse(io); + module = &parser.parse(io, src_name); process(); } +void ProgramCompiler::compile(IO::Base &io, const string &src_name) +{ + compile(io, 0, src_name); +} + void ProgramCompiler::add_shaders(Program &program) { if(!module) @@ -71,8 +77,11 @@ void ProgramCompiler::add_shaders(Program &program) else if(i->type==FRAGMENT) { program.attach_shader_owned(new FragmentShader(apply(*i))); - for(map::iterator j=i->locations.begin(); j!=i->locations.end(); ++j) - program.bind_fragment_data(j->second, j->first); + if(EXT_gpu_shader4) + { + for(map::iterator j=i->locations.begin(); j!=i->locations.end(); ++j) + program.bind_fragment_data(j->second, j->first); + } } } } @@ -80,7 +89,7 @@ void ProgramCompiler::add_shaders(Program &program) Module *ProgramCompiler::create_builtins_module() { ProgramParser parser; - Module *module = new Module(parser.parse(builtins_src)); + Module *module = new Module(parser.parse(builtins_src, "")); for(list::iterator i=module->stages.begin(); i!=module->stages.end(); ++i) { VariableResolver resolver; @@ -133,7 +142,7 @@ void ProgramCompiler::import(const string &name) if(!io) throw runtime_error(format("module %s not found", name)); ProgramParser import_parser; - Module &imported_module = import_parser.parse(*io); + Module &imported_module = import_parser.parse(*io, fn); inject_block(module->shared.content, imported_module.shared.content); apply(module->shared); @@ -1678,6 +1687,8 @@ void ProgramCompiler::LegacyConverter::visit(VariableDeclaration &var) } else if(stage->type==FRAGMENT && var.interface=="out") { + if(location!=0) + static Require _req(EXT_gpu_shader4); stage->locations[var.name] = location; var.layout->qualifiers.erase(i); }