]> git.tdb.fi Git - libs/gl.git/commitdiff
Consider extensions when checking GLSL features
authorMikko Rasa <tdb@tdb.fi>
Fri, 21 Jun 2019 08:22:08 +0000 (11:22 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 21 Jun 2019 11:54:28 +0000 (14:54 +0300)
extensions/arb_explicit_attrib_location.glext [new file with mode: 0644]
extensions/arb_gpu_shader5.glext [new file with mode: 0644]
scripts/extgen.py
source/programcompiler.cpp
source/programcompiler.h
source/programsyntax.h

diff --git a/extensions/arb_explicit_attrib_location.glext b/extensions/arb_explicit_attrib_location.glext
new file mode 100644 (file)
index 0000000..77222b9
--- /dev/null
@@ -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 (file)
index 0000000..2fbb4fc
--- /dev/null
@@ -0,0 +1 @@
+extension ARB_gpu_shader5
index 92c78b504ff5a27ae1582c0e5d294f748d3692ed..15ef167bfaf60c9d3de0a162e53b13f7150ace26 100755 (executable)
@@ -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):
index 3dc07d80fa4dd2566c069d0cae5bdb4451f7ac5d..6b8d2eb8a6ae75bbd7d5ea74c7fe7bde4e4b39b6 100644 (file)
@@ -1,4 +1,8 @@
+#include <msp/core/algorithm.h>
 #include <msp/core/raii.h>
+#include <msp/gl/extensions/arb_explicit_attrib_location.h>
+#include <msp/gl/extensions/arb_gpu_shader5.h>
+#include <msp/gl/extensions/arb_uniform_buffer_object.h>
 #include <msp/gl/extensions/ext_gpu_shader4.h>
 #include <msp/strings/format.h>
 #include <msp/strings/utils.h>
@@ -321,6 +325,11 @@ void ProgramCompiler::Formatter::apply(ProgramSyntax::Stage &s)
                formatted += '\n';
        }
 
+       for(vector<const Extension *>::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<const Extension *>::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)
index 1f0601b5871f859a5dc771f6566f9311644d355d..76e9eef352f83f67a46c6b8a620d0411c0bf0440 100644 (file)
@@ -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 &);
index 6a03f40fab67b2f4b02d17de5873587edf1d3e88..1f26bc568800e1f9374cb0f4b9e20647442d6804 100644 (file)
@@ -389,6 +389,7 @@ struct Stage
        std::map<std::string, VariableDeclaration *> out_variables;
        std::map<std::string, unsigned> locations;
        Version required_version;
+       std::vector<const Extension *> required_extensions;
 
        Stage(StageType);
 };