]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/compatibility.h
Reduce coupling between the GLSL compiler and the graphics engine
[libs/gl.git] / source / glsl / compatibility.h
index fdbd3d07fb304c0c79202445f4df04befaef9a58..d3a3a74c0dc493fba95e34f06b1b5eb72f8a3266 100644 (file)
@@ -8,12 +8,12 @@ namespace Msp {
 namespace GL {
 namespace SL {
 
-class DefaultPrecisionGenerator: private BlockModifier
+class DefaultPrecisionGenerator: private TraversingVisitor
 {
 private:
-       Stage::Type stage_type;
-       bool toplevel;
+       Stage *stage;
        std::set<std::string> have_default;
+       NodeList<Statement>::iterator insert_point;
 
 public:
        DefaultPrecisionGenerator();
@@ -24,38 +24,42 @@ private:
        virtual void visit(Block &);
        virtual void visit(Precision &);
        virtual void visit(VariableDeclaration &);
-       using BlockModifier::visit;
+       using TraversingVisitor::visit;
 };
 
-class PrecisionRemover: private BlockModifier
+class PrecisionRemover: private TraversingVisitor
 {
+private:
+       std::set<Node *> nodes_to_remove;
+
 public:
-       void apply(Stage &s) { visit(s.content); }
+       void apply(Stage &);
 
 private:
        virtual void visit(Precision &);
        virtual void visit(VariableDeclaration &);
-       using BlockModifier::visit;
+       using TraversingVisitor::visit;
 };
 
-class LegacyConverter: private BlockModifier
+class LegacyConverter: private TraversingVisitor
 {
 private:
        Stage *stage;
-       GLApi target_api;
-       Version target_version;
+       Features features;
        std::string type;
        VariableDeclaration *frag_out;
+       NodeList<Statement>::iterator uniform_insert_point;
+       std::set<Node *> nodes_to_remove;
 
 public:
        LegacyConverter();
-       LegacyConverter(const Version &);
 
-       virtual void apply(Stage &);
+       virtual void apply(Stage &, const Features &);
 
 private:
+       virtual void visit(Block &);
        bool check_version(const Version &) const;
-       bool check_extension(const Extension &) const;
+       bool check_extension(bool Features::*) const;
        bool supports_unified_interface_syntax() const;
        virtual void visit(VariableReference &);
        virtual void visit(Assignment &);
@@ -67,7 +71,7 @@ private:
        virtual void visit(VariableDeclaration &);
        bool supports_interface_blocks(const std::string &) const;
        virtual void visit(InterfaceBlock &);
-       using BlockModifier::visit;
+       using TraversingVisitor::visit;
 };
 
 } // namespace SL