]> git.tdb.fi Git - libs/gl.git/blob - source/glsl/spirvwriter.h
Check the flat qualifier from the correct member
[libs/gl.git] / source / glsl / spirvwriter.h
1 #ifndef MSP_GL_SL_SPIRVWRITER_H_
2 #define MSP_GL_SL_SPIRVWRITER_H_
3
4 #include <string>
5 #include <vector>
6 #include <cstdint>
7 #include "spirvconstants.h"
8
9 namespace Msp {
10 namespace GL {
11 namespace SL {
12
13 struct SpirVContent
14 {
15         typedef std::uint32_t Word;
16
17         std::vector<Word> code;
18         std::vector<Word> capabilities;
19         std::vector<Word> extensions;
20         std::vector<Word> entry_points;
21         std::vector<Word> exec_modes;
22         std::vector<Word> names;
23         std::vector<Word> decorations;
24         std::vector<Word> globals;
25         std::vector<Word> functions;
26         std::vector<Word> locals;
27         std::vector<Word> function_body;
28 };
29
30 class SpirVWriter
31 {
32 public:
33         typedef SpirVOpcode Opcode;
34         typedef SpirVDecoration Decoration;
35         typedef SpirVContent::Word Word;
36         typedef Word Id;
37
38 private:
39         SpirVContent &content;
40         std::vector<Word> *op_target;
41         unsigned op_head_pos;
42         Id current_block_id;
43
44 public:
45         SpirVWriter(SpirVContent &);
46
47         void append(std::vector<Word> &, const std::vector<Word> &);
48         void write(Word);
49         void write_float(float);
50         void write_string(const std::string &);
51         void begin_op(std::vector<Word> &, Opcode, unsigned = 0);
52         void end_op(SpirVOpcode);
53         void write_op(std::vector<Word> &, Opcode);
54         void write_op(std::vector<Word> &, Opcode, Word);
55         void write_op(std::vector<Word> &, Opcode, Word, Word);
56         void write_op(std::vector<Word> &, Opcode, Word, Word, Word);
57         void write_op_name(Id, const std::string &);
58         void write_op_member_name(Id, unsigned, const std::string &);
59         void write_op_decorate(Id, Decoration);
60         void write_op_decorate(Id, Decoration, Word);
61         void write_op_member_decorate(Id, unsigned, Decoration);
62         void write_op_member_decorate(Id, unsigned, Decoration, Word);
63         void write_op_label(Id);
64         Id get_current_block() const { return current_block_id; }
65         void begin_function_body(Id);
66         void end_function_body();
67         void finalize(unsigned, Id);
68 };
69
70 } // namespace SL
71 } // namespace GL
72 } // namespace Msp
73
74 #endif