]> git.tdb.fi Git - libs/gl.git/blob - source/glsl/finalize.h
Use type information in converting legacy texture sampling functions
[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         VariableDeclaration *frag_out;
40         NodeList<Statement>::iterator uniform_insert_point;
41         std::set<Node *> nodes_to_remove;
42
43 public:
44         LegacyConverter();
45
46         virtual void apply(Stage &, const Features &);
47
48 private:
49         void unsupported(const std::string &);
50
51         virtual void visit(Block &);
52         bool check_version(const Version &) const;
53         bool check_extension(bool Features::*) const;
54         bool supports_stage(Stage::Type) const;
55         bool supports_unified_interface_syntax() const;
56         virtual void visit(VariableReference &);
57         virtual void visit(Assignment &);
58         bool supports_unified_sampling_functions() const;
59         virtual void visit(FunctionCall &);
60         bool supports_interface_layouts() const;
61         bool supports_centroid_sampling() const;
62         bool supports_sample_sampling() const;
63         virtual void visit(VariableDeclaration &);
64         bool supports_interface_blocks(const std::string &) const;
65         virtual void visit(InterfaceBlock &);
66 };
67
68 } // namespace SL
69 } // namespace GL
70 } // namespace Msp
71
72 #endif