1 #ifndef MSP_GL_SL_FINALIZE_H_
2 #define MSP_GL_SL_FINALIZE_H_
11 /** Assigns offset layout qualifiers to struct members. */
12 class StructOrganizer: private TraversingVisitor
20 void apply(Stage &s) { s.content.visit(*this); }
23 virtual void visit(StructDeclaration &);
24 virtual void visit(VariableDeclaration &);
27 /** Assigns location and binding layout qualifiers to interface variables and
29 class LocationAllocator: private TraversingVisitor
38 Uniform(): location(-1), desc_set(-1), bind_point(-1) { }
41 std::map<std::string, std::set<unsigned> > used_locations;
42 std::map<std::string, Uniform> uniforms;
43 std::map<unsigned, std::set<unsigned> > used_bindings;
44 std::vector<VariableDeclaration *> unplaced_variables;
45 std::vector<VariableDeclaration *> unbound_textures;
46 std::vector<InterfaceBlock *> unbound_blocks;
49 void apply(Module &, const Features &);
53 void allocate_locations(const std::string &);
54 void bind_uniform(RefPtr<Layout> &, const std::string &, unsigned);
55 void add_layout_value(RefPtr<Layout> &, const std::string &, unsigned);
57 virtual void visit(VariableDeclaration &);
58 virtual void visit(InterfaceBlock &);
59 virtual void visit(FunctionDeclaration &) { }
62 /** Generates default precision declarations or removes precision declarations
63 according to the requirements of the target API. */
64 class PrecisionConverter: private TraversingVisitor
68 std::set<std::string> have_default;
69 NodeList<Statement>::iterator insert_point;
70 std::set<Node *> nodes_to_remove;
78 virtual void visit(Block &);
79 virtual void visit(Precision &);
80 virtual void visit(VariableDeclaration &);
83 /** Converts structures of the syntax tree to match a particular set of
85 class LegacyConverter: private TraversingVisitor
90 VariableDeclaration *frag_out;
91 NodeList<Statement>::iterator uniform_insert_point;
92 std::set<Node *> nodes_to_remove;
97 virtual void apply(Stage &, const Features &);
100 void unsupported(const std::string &);
102 virtual void visit(Block &);
103 bool check_version(const Version &) const;
104 bool check_extension(bool Features::*) const;
105 bool supports_stage(Stage::Type) const;
106 bool supports_unified_interface_syntax() const;
107 virtual void visit(VariableReference &);
108 virtual void visit(Assignment &);
109 bool supports_unified_sampling_functions() const;
110 virtual void visit(FunctionCall &);
111 bool supports_interface_layouts() const;
112 bool supports_stage_interface_layouts() const;
113 bool supports_centroid_sampling() const;
114 bool supports_sample_sampling() const;
115 bool supports_uniform_location() const;
116 bool supports_binding() const;
117 virtual void visit(VariableDeclaration &);
118 bool supports_interface_blocks(const std::string &) const;
119 bool supports_interface_block_location() const;
120 virtual void visit(InterfaceBlock &);