X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprogramcompiler.cpp;h=6b8d2eb8a6ae75bbd7d5ea74c7fe7bde4e4b39b6;hp=3dc07d80fa4dd2566c069d0cae5bdb4451f7ac5d;hb=7189f63c549e9061789c47726ff8d6d12afca1a0;hpb=a170be7d2b295c4a3bbcea6585634bece3e1638b diff --git a/source/programcompiler.cpp b/source/programcompiler.cpp index 3dc07d80..6b8d2eb8 100644 --- a/source/programcompiler.cpp +++ b/source/programcompiler.cpp @@ -1,4 +1,8 @@ +#include #include +#include +#include +#include #include #include #include @@ -321,6 +325,11 @@ void ProgramCompiler::Formatter::apply(ProgramSyntax::Stage &s) formatted += '\n'; } + for(vector::const_iterator i=s.required_extensions.begin(); i!=s.required_extensions.end(); ++i) + formatted += format("#extension %s: require\n", (*i)->get_name()); + if(!s.required_extensions.empty()) + formatted += '\n'; + Visitor::apply(s); } @@ -1776,6 +1785,18 @@ bool ProgramCompiler::LegacyConverter::check_version(const Version &feature_vers return true; } +bool ProgramCompiler::LegacyConverter::check_extension(const Extension &extension) const +{ + if(!extension) + return false; + + vector::iterator i = find(stage->required_extensions, &extension); + if(i==stage->required_extensions.end()) + stage->required_extensions.push_back(&extension); + + return true; +} + bool ProgramCompiler::LegacyConverter::supports_unified_interface_syntax() const { if(target_api==OPENGL_ES2) @@ -1844,24 +1865,30 @@ bool ProgramCompiler::LegacyConverter::supports_interface_layouts() const { if(target_api==OPENGL_ES2) return check_version(Version(3, 0)); + else if(check_version(Version(3, 30))) + return true; else - return check_version(Version(3, 30)); + return check_extension(ARB_explicit_attrib_location); } bool ProgramCompiler::LegacyConverter::supports_centroid_sampling() const { if(target_api==OPENGL_ES2) return check_version(Version(3, 0)); + else if(check_version(Version(1, 20))) + return true; else - return check_version(Version(1, 20)); + return check_extension(EXT_gpu_shader4); } bool ProgramCompiler::LegacyConverter::supports_sample_sampling() const { if(target_api==OPENGL_ES2) return check_version(Version(3, 20)); + else if(check_version(Version(4, 0))) + return true; else - return check_version(Version(4, 0)); + return check_extension(ARB_gpu_shader5); } void ProgramCompiler::LegacyConverter::visit(VariableDeclaration &var) @@ -1923,8 +1950,12 @@ bool ProgramCompiler::LegacyConverter::supports_interface_blocks(const string &i else return check_version(Version(3, 20)); } + else if(check_version(Version(1, 50))) + return true; + else if(iface=="uniform") + return check_extension(ARB_uniform_buffer_object); else - return check_version(Version(1, 50)); + return false; } void ProgramCompiler::LegacyConverter::visit(InterfaceBlock &iface)