]> git.tdb.fi Git - libs/gl.git/blob - source/glsl/compatibility.h
Reduce coupling between the GLSL compiler and the graphics engine
[libs/gl.git] / source / glsl / compatibility.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 class DefaultPrecisionGenerator: private TraversingVisitor
12 {
13 private:
14         Stage *stage;
15         std::set<std::string> have_default;
16         NodeList<Statement>::iterator insert_point;
17
18 public:
19         DefaultPrecisionGenerator();
20
21         void apply(Stage &);
22
23 private:
24         virtual void visit(Block &);
25         virtual void visit(Precision &);
26         virtual void visit(VariableDeclaration &);
27         using TraversingVisitor::visit;
28 };
29
30 class PrecisionRemover: private TraversingVisitor
31 {
32 private:
33         std::set<Node *> nodes_to_remove;
34
35 public:
36         void apply(Stage &);
37
38 private:
39         virtual void visit(Precision &);
40         virtual void visit(VariableDeclaration &);
41         using TraversingVisitor::visit;
42 };
43
44 class LegacyConverter: private TraversingVisitor
45 {
46 private:
47         Stage *stage;
48         Features features;
49         std::string type;
50         VariableDeclaration *frag_out;
51         NodeList<Statement>::iterator uniform_insert_point;
52         std::set<Node *> nodes_to_remove;
53
54 public:
55         LegacyConverter();
56
57         virtual void apply(Stage &, const Features &);
58
59 private:
60         virtual void visit(Block &);
61         bool check_version(const Version &) const;
62         bool check_extension(bool Features::*) const;
63         bool supports_unified_interface_syntax() const;
64         virtual void visit(VariableReference &);
65         virtual void visit(Assignment &);
66         bool supports_unified_sampling_functions() const;
67         virtual void visit(FunctionCall &);
68         bool supports_interface_layouts() const;
69         bool supports_centroid_sampling() const;
70         bool supports_sample_sampling() const;
71         virtual void visit(VariableDeclaration &);
72         bool supports_interface_blocks(const std::string &) const;
73         virtual void visit(InterfaceBlock &);
74         using TraversingVisitor::visit;
75 };
76
77 } // namespace SL
78 } // namespace GL
79 } // namespace Msp
80
81 #endif