]> git.tdb.fi Git - libs/gl.git/commitdiff
Check that requested shader stages are supported
authorMikko Rasa <tdb@tdb.fi>
Sun, 21 Feb 2021 23:50:19 +0000 (01:50 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 21 Feb 2021 23:53:20 +0000 (01:53 +0200)
source/glsl/compatibility.cpp
source/glsl/compatibility.h

index 3407386248210035c8a6dee75fee815a9987696f..0769839430f371c646374f8150cfb0f245e17607 100644 (file)
@@ -88,6 +88,8 @@ void LegacyConverter::apply(Stage &s, const Features &feat)
 {
        stage = &s;
        features = feat;
+       if(!supports_stage(s.type))
+               throw unsupported_shader(format("Stage %s is not supported", Stage::get_stage_name(s.type)));
        visit(s.content);
 }
 
@@ -121,6 +123,19 @@ bool LegacyConverter::check_extension(bool Features::*extension) const
        return true;
 }
 
+bool LegacyConverter::supports_stage(Stage::Type st) const
+{
+       if(st==Stage::GEOMETRY)
+       {
+               if(features.gl_api==OPENGL_ES2)
+                       return check_version(Version(3, 20));
+               else
+                       return check_version(Version(1, 50));
+       }
+       else
+               return true;
+}
+
 bool LegacyConverter::supports_unified_interface_syntax() const
 {
        if(features.gl_api==OPENGL_ES2)
index d3a3a74c0dc493fba95e34f06b1b5eb72f8a3266..f91f188274c99c3d6cb06e05898fb7ae10655b33 100644 (file)
@@ -60,6 +60,7 @@ private:
        virtual void visit(Block &);
        bool check_version(const Version &) const;
        bool check_extension(bool Features::*) const;
+       bool supports_stage(Stage::Type) const;
        bool supports_unified_interface_syntax() const;
        virtual void visit(VariableReference &);
        virtual void visit(Assignment &);