]> git.tdb.fi Git - libs/gl.git/blob - source/glsl/compiler.h
Header fixes in the GLSL compiler
[libs/gl.git] / source / glsl / compiler.h
1 #ifndef MSP_GL_SL_COMPILER_H_
2 #define MSP_GL_SL_COMPILER_H_
3
4 #include <vector>
5 #include <msp/datafile/collection.h>
6 #include <msp/io/base.h>
7 #include "parser.h"
8 #include "syntax.h"
9
10 namespace Msp {
11 namespace GL {
12 namespace SL {
13
14 class Compiler
15 {
16 public:
17         enum Mode
18         {
19                 MODULE,
20                 PROGRAM
21         };
22
23 private:
24         Module *module;
25         std::vector<std::string> imported_names;
26
27 public:
28         Compiler();
29         ~Compiler();
30
31 private:
32         void clear();
33 public:
34         void set_source(const std::string &, const std::string & = "<string>");
35         void load_source(IO::Base &, DataFile::Collection * = 0, const std::string & = "<file>");
36         void load_source(IO::Base &, const std::string &);
37         void compile(Mode);
38
39         std::string get_combined_glsl() const;
40         std::vector<Stage::Type> get_stages() const;
41         std::string get_stage_glsl(Stage::Type) const;
42         const std::map<std::string, unsigned> &get_vertex_attributes() const;
43         const std::map<std::string, unsigned> &get_fragment_outputs() const;
44         const SourceMap &get_source_map() const;
45 private:
46
47         void append_module(Module &, DataFile::Collection *);
48         void append_stage(Stage &);
49         void import(DataFile::Collection *, const std::string &);
50         void generate(Stage &, Mode);
51         bool optimize(Stage &);
52         void finalize(Stage &, Mode);
53         static void inject_block(Block &, const Block &);
54 };
55
56 } // namespace SL
57 } // namespace GL
58 } // namespace Msp
59
60 #endif