]> git.tdb.fi Git - libs/gl.git/blob - source/glsl/compatibility.h
Refactor the way of applying visitors to stages
[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: public BlockModifier
12 {
13 private:
14         Stage::Type stage_type;
15         bool toplevel;
16         std::set<std::string> have_default;
17
18 public:
19         DefaultPrecisionGenerator();
20
21         void apply(Stage &);
22
23         using BlockModifier::visit;
24         virtual void visit(Block &);
25         virtual void visit(Precision &);
26         virtual void visit(VariableDeclaration &);
27 };
28
29 class PrecisionRemover: public BlockModifier
30 {
31 public:
32         void apply(Stage &s) { visit(s.content); }
33
34         using BlockModifier::visit;
35         virtual void visit(Precision &);
36         virtual void visit(VariableDeclaration &);
37 };
38
39 class LegacyConverter: public BlockModifier
40 {
41 private:
42         Stage *stage;
43         GLApi target_api;
44         Version target_version;
45         std::string type;
46         VariableDeclaration *frag_out;
47
48 public:
49         LegacyConverter();
50         LegacyConverter(const Version &);
51
52 private:
53         bool check_version(const Version &) const;
54         bool check_extension(const Extension &) const;
55 public:
56         using BlockModifier::visit;
57         virtual void apply(Stage &);
58 private:
59         bool supports_unified_interface_syntax() const;
60         virtual void visit(VariableReference &);
61         virtual void visit(Assignment &);
62         bool supports_unified_sampling_functions() const;
63         virtual void visit(FunctionCall &);
64         bool supports_interface_layouts() const;
65         bool supports_centroid_sampling() const;
66         bool supports_sample_sampling() const;
67         virtual void visit(VariableDeclaration &);
68         bool supports_interface_blocks(const std::string &) const;
69         virtual void visit(InterfaceBlock &);
70 };
71
72 } // namespace SL
73 } // namespace GL
74 } // namespace Msp
75
76 #endif