From: Mikko Rasa Date: Fri, 21 Jun 2019 08:22:08 +0000 (+0300) Subject: Consider extensions when checking GLSL features X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=7189f63c549e9061789c47726ff8d6d12afca1a0;p=libs%2Fgl.git Consider extensions when checking GLSL features --- diff --git a/extensions/arb_explicit_attrib_location.glext b/extensions/arb_explicit_attrib_location.glext new file mode 100644 index 00000000..77222b92 --- /dev/null +++ b/extensions/arb_explicit_attrib_location.glext @@ -0,0 +1 @@ +extension ARB_explicit_attrib_location diff --git a/extensions/arb_gpu_shader5.glext b/extensions/arb_gpu_shader5.glext new file mode 100644 index 00000000..2fbb4fc1 --- /dev/null +++ b/extensions/arb_gpu_shader5.glext @@ -0,0 +1 @@ +extension ARB_gpu_shader5 diff --git a/scripts/extgen.py b/scripts/extgen.py index 92c78b50..15ef167b 100755 --- a/scripts/extgen.py +++ b/scripts/extgen.py @@ -399,7 +399,7 @@ def detect_backport_extension(host_api, things): best_ext = e best_count = count - if best_count*2>=total_count: + if total_count and best_count*2>=total_count: print "Warning: Inconsistent backport extension %s"%best_ext.name def collect_extensions(thing, api, exts): 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) diff --git a/source/programcompiler.h b/source/programcompiler.h index 1f0601b5..76e9eef3 100644 --- a/source/programcompiler.h +++ b/source/programcompiler.h @@ -360,6 +360,7 @@ private: LegacyConverter(const Version &); bool check_version(const Version &) const; + bool check_extension(const Extension &) const; using Visitor::visit; bool supports_unified_interface_syntax() const; virtual void visit(ProgramSyntax::VariableReference &); diff --git a/source/programsyntax.h b/source/programsyntax.h index 6a03f40f..1f26bc56 100644 --- a/source/programsyntax.h +++ b/source/programsyntax.h @@ -389,6 +389,7 @@ struct Stage std::map out_variables; std::map locations; Version required_version; + std::vector required_extensions; Stage(StageType); };