]> git.tdb.fi Git - libs/gl.git/blob - source/core/reflectdata.h
Redesign asynchronous buffer uploads
[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                 UNIFORM_BLOCK_BINDING = 0,
22                 TEXTURE_BINDING = 0x1000000
23         };
24
25         typedef unsigned LayoutHash;
26         struct UniformBlockInfo;
27
28         struct UniformInfo
29         {
30                 std::string name;
31                 const UniformBlockInfo *block = 0;
32                 union
33                 {
34                         int location = -1;
35                         unsigned offset;
36                 };
37                 unsigned array_size = 0;
38                 unsigned array_stride = 0;
39                 unsigned matrix_stride = 0;
40                 DataType type = VOID;
41                 Tag tag;
42                 int binding = -1;
43         };
44
45         struct UniformBlockInfo
46         {
47                 std::string name;
48                 unsigned data_size = 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         unsigned n_descriptor_sets = 0;
71         std::vector<int> used_bindings;
72
73         void update_layout_hash();
74         void update_used_bindings();
75 };
76
77 } // namespace GL
78 } // namespace Msp
79
80 #endif