]> git.tdb.fi Git - libs/gl.git/blob - source/glsl/finalize.h
212007131e80a3d0e37173364005d68f3b8d1166
[libs/gl.git] / source / glsl / finalize.h
1 #ifndef MSP_GL_SL_COMPATIBILITY_H_
2 #define MSP_GL_SL_COMPATIBILITY_H_
3
4 #include <string>
5 #include "visitor.h"
6
7 namespace Msp {
8 namespace GL {
9 namespace SL {
10
11 /** Generates default precision declarations if they are missing, to satisfy
12 GLSL ES requirements. */
13 class DefaultPrecisionGenerator: private TraversingVisitor
14 {
15 private:
16         Stage *stage;
17         std::set<std::string> have_default;
18         NodeList<Statement>::iterator insert_point;
19
20 public:
21         DefaultPrecisionGenerator();
22
23         void apply(Stage &);
24
25 private:
26         virtual void visit(Block &);
27         virtual void visit(Precision &);
28         virtual void visit(VariableDeclaration &);
29 };
30
31 /** Removes precision qualifiers from variable declarations, as well as
32 default precision declarations. */
33 class PrecisionRemover: private TraversingVisitor
34 {
35 private:
36         std::set<Node *> nodes_to_remove;
37
38 public:
39         void apply(Stage &);
40
41 private:
42         virtual void visit(Precision &);
43         virtual void visit(VariableDeclaration &);
44 };
45
46 /** Converts structures of the syntax tree to match a particular set of
47 features. */
48 class LegacyConverter: private TraversingVisitor
49 {
50 private:
51         Stage *stage;
52         Features features;
53         std::string r_type;
54         VariableDeclaration *frag_out;
55         NodeList<Statement>::iterator uniform_insert_point;
56         std::set<Node *> nodes_to_remove;
57
58 public:
59         LegacyConverter();
60
61         virtual void apply(Stage &, const Features &);
62
63 private:
64         void unsupported(const std::string &);
65
66         virtual void visit(Block &);
67         bool check_version(const Version &) const;
68         bool check_extension(bool Features::*) const;
69         bool supports_stage(Stage::Type) const;
70         bool supports_unified_interface_syntax() const;
71         virtual void visit(VariableReference &);
72         virtual void visit(Assignment &);
73         bool supports_unified_sampling_functions() const;
74         virtual void visit(FunctionCall &);
75         bool supports_interface_layouts() const;
76         bool supports_centroid_sampling() const;
77         bool supports_sample_sampling() const;
78         virtual void visit(VariableDeclaration &);
79         bool supports_interface_blocks(const std::string &) const;
80         virtual void visit(InterfaceBlock &);
81 };
82
83 } // namespace SL
84 } // namespace GL
85 } // namespace Msp
86
87 #endif