]> git.tdb.fi Git - libs/gl.git/blob - source/core/reflectdata.h
Add correct copy and move semantics to most classes
[libs/gl.git] / source / core / reflectdata.h
1 #ifndef MSP_GL_REFLECTDATA_H_
2 #define MSP_GL_REFLECTDATA_H_
3
4 #include <string>
5 #include <vector>
6 #include "datatype.h"
7 #include "tag.h"
8
9 namespace Msp {
10 namespace GL {
11
12 /**
13 Reflection data for shader programs.
14 */
15 struct ReflectData
16 {
17         enum
18         {
19                 DEFAULT_BLOCK = -1,
20                 PUSH_CONSTANT = -2
21         };
22
23         typedef unsigned LayoutHash;
24         struct UniformBlockInfo;
25
26         struct UniformInfo
27         {
28                 std::string name;
29                 const UniformBlockInfo *block = 0;
30                 union
31                 {
32                         int location = -1;
33                         unsigned offset;
34                 };
35                 unsigned array_size = 0;
36                 unsigned array_stride = 0;
37                 unsigned matrix_stride = 0;
38                 DataType type = VOID;
39                 Tag tag;
40                 int descriptor_set = 0;
41                 int binding = -1;
42         };
43
44         struct UniformBlockInfo
45         {
46                 std::string name;
47                 unsigned data_size = 0;
48                 int descriptor_set = 0;
49                 int bind_point = DEFAULT_BLOCK;
50                 std::vector<const UniformInfo *> uniforms;
51                 LayoutHash layout_hash = 0;
52
53                 void sort_uniforms();
54                 void update_layout_hash();
55         };
56
57         struct AttributeInfo
58         {
59                 std::string name;
60                 int location = -1;
61                 unsigned array_size = 0;
62                 DataType type = VOID;
63         };
64
65         std::vector<UniformBlockInfo> uniform_blocks;
66         std::vector<UniformInfo> uniforms;
67         LayoutHash layout_hash = 0;
68         std::vector<AttributeInfo> attributes;
69         unsigned n_clip_distances = 0;
70
71         void update_layout_hash();
72 };
73
74 } // namespace GL
75 } // namespace Msp
76
77 #endif