]> git.tdb.fi Git - libs/gl.git/blob - source/core/reflectdata.h
Use friend declaration to access hidden data in Batch
[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;
24                 union
25                 {
26                         int location;
27                         unsigned offset;
28                 };
29                 unsigned array_size;
30                 unsigned array_stride;
31                 unsigned matrix_stride;
32                 DataType type;
33                 Tag tag;
34                 int binding;
35
36                 UniformInfo();
37         };
38
39         struct UniformBlockInfo
40         {
41                 std::string name;
42                 unsigned data_size;
43                 int bind_point;
44                 std::vector<const UniformInfo *> uniforms;
45                 LayoutHash layout_hash;
46
47                 UniformBlockInfo();
48
49                 void sort_uniforms();
50                 void update_layout_hash();
51         };
52
53         struct AttributeInfo
54         {
55                 std::string name;
56                 unsigned location;
57                 unsigned array_size;
58                 DataType type;
59
60                 AttributeInfo();
61         };
62
63         std::vector<UniformBlockInfo> uniform_blocks;
64         std::vector<UniformInfo> uniforms;
65         LayoutHash layout_hash;
66         std::vector<AttributeInfo> attributes;
67
68         void update_layout_hash();
69 };
70
71 } // namespace GL
72 } // namespace Msp
73
74 #endif