]> git.tdb.fi Git - libs/gl.git/blob - source/glsl/finalize.h
Combine the precision handling visitors and rewrite the logic
[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 or removes precision declarations
12 according to the requirements of the target API. */
13 class PrecisionConverter: private TraversingVisitor
14 {
15 private:
16         Stage *stage;
17         std::set<std::string> have_default;
18         NodeList<Statement>::iterator insert_point;
19         std::set<Node *> nodes_to_remove;
20
21 public:
22         PrecisionConverter();
23
24         void apply(Stage &);
25
26 private:
27         virtual void visit(Block &);
28         virtual void visit(Precision &);
29         virtual void visit(VariableDeclaration &);
30 };
31
32 /** Converts structures of the syntax tree to match a particular set of
33 features. */
34 class LegacyConverter: private TraversingVisitor
35 {
36 private:
37         Stage *stage;
38         Features features;
39         std::string r_type;
40         VariableDeclaration *frag_out;
41         NodeList<Statement>::iterator uniform_insert_point;
42         std::set<Node *> nodes_to_remove;
43
44 public:
45         LegacyConverter();
46
47         virtual void apply(Stage &, const Features &);
48
49 private:
50         void unsupported(const std::string &);
51
52         virtual void visit(Block &);
53         bool check_version(const Version &) const;
54         bool check_extension(bool Features::*) const;
55         bool supports_stage(Stage::Type) const;
56         bool supports_unified_interface_syntax() const;
57         virtual void visit(VariableReference &);
58         virtual void visit(Assignment &);
59         bool supports_unified_sampling_functions() const;
60         virtual void visit(FunctionCall &);
61         bool supports_interface_layouts() const;
62         bool supports_centroid_sampling() const;
63         bool supports_sample_sampling() const;
64         virtual void visit(VariableDeclaration &);
65         bool supports_interface_blocks(const std::string &) const;
66         virtual void visit(InterfaceBlock &);
67 };
68
69 } // namespace SL
70 } // namespace GL
71 } // namespace Msp
72
73 #endif