]> git.tdb.fi Git - libs/gl.git/blob - source/core/reflectdata.h
Use default member initializers for simple types
[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         typedef unsigned LayoutHash;
18         struct UniformBlockInfo;
19
20         struct UniformInfo
21         {
22                 std::string name;
23                 const UniformBlockInfo *block = 0;
24                 union
25                 {
26                         int location = -1;
27                         unsigned offset;
28                 };
29                 unsigned array_size = 0;
30                 unsigned array_stride = 0;
31                 unsigned matrix_stride = 0;
32                 DataType type = VOID;
33                 Tag tag;
34                 int binding = -1;
35         };
36
37         struct UniformBlockInfo
38         {
39                 std::string name;
40                 unsigned data_size = 0;
41                 int bind_point = -1;
42                 std::vector<const UniformInfo *> uniforms;
43                 LayoutHash layout_hash = 0;
44
45                 void sort_uniforms();
46                 void update_layout_hash();
47         };
48
49         struct AttributeInfo
50         {
51                 std::string name;
52                 unsigned location = -1;
53                 unsigned array_size = 0;
54                 DataType type = VOID;
55         };
56
57         std::vector<UniformBlockInfo> uniform_blocks;
58         std::vector<UniformInfo> uniforms;
59         LayoutHash layout_hash;
60         std::vector<AttributeInfo> attributes;
61
62         void update_layout_hash();
63 };
64
65 } // namespace GL
66 } // namespace Msp
67
68 #endif