X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fcompatibility.h;h=212007131e80a3d0e37173364005d68f3b8d1166;hb=f2ad2730858046b08e8147297fa01bf3499b86a3;hp=732f3477db5f9b401550ff999bde3d6f50af0718;hpb=1fa69bb8eec3070f5da296d6dd0bd67aea62d3bf;p=libs%2Fgl.git diff --git a/source/glsl/compatibility.h b/source/glsl/compatibility.h index 732f3477..21200713 100644 --- a/source/glsl/compatibility.h +++ b/source/glsl/compatibility.h @@ -8,54 +8,65 @@ namespace Msp { namespace GL { namespace SL { -class DefaultPrecisionGenerator: public BlockModifier +/** Generates default precision declarations if they are missing, to satisfy +GLSL ES requirements. */ +class DefaultPrecisionGenerator: private TraversingVisitor { private: - Stage::Type stage_type; - bool toplevel; + Stage *stage; std::set have_default; + NodeList::iterator insert_point; public: DefaultPrecisionGenerator(); void apply(Stage &); - using BlockModifier::visit; +private: virtual void visit(Block &); virtual void visit(Precision &); virtual void visit(VariableDeclaration &); }; -class PrecisionRemover: public BlockModifier +/** Removes precision qualifiers from variable declarations, as well as +default precision declarations. */ +class PrecisionRemover: private TraversingVisitor { +private: + std::set nodes_to_remove; + public: - void apply(Stage &s) { visit(s.content); } + void apply(Stage &); - using BlockModifier::visit; +private: virtual void visit(Precision &); virtual void visit(VariableDeclaration &); }; -class LegacyConverter: public BlockModifier +/** Converts structures of the syntax tree to match a particular set of +features. */ +class LegacyConverter: private TraversingVisitor { private: Stage *stage; - GLApi target_api; - Version target_version; - std::string type; + Features features; + std::string r_type; VariableDeclaration *frag_out; + NodeList::iterator uniform_insert_point; + std::set nodes_to_remove; public: LegacyConverter(); - LegacyConverter(const Version &); + + virtual void apply(Stage &, const Features &); private: + void unsupported(const std::string &); + + virtual void visit(Block &); bool check_version(const Version &) const; - bool check_extension(const Extension &) const; -public: - using BlockModifier::visit; - virtual void apply(Stage &); -private: + 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 &);