]> git.tdb.fi Git - libs/gl.git/blob - source/core/reflectdata.h
Store descriptor set in program reflection data
[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 descriptor_set = 0;
35                 int binding = -1;
36         };
37
38         struct UniformBlockInfo
39         {
40                 std::string name;
41                 unsigned data_size = 0;
42                 int descriptor_set = 0;
43                 int bind_point = -1;
44                 std::vector<const UniformInfo *> uniforms;
45                 LayoutHash layout_hash = 0;
46
47                 void sort_uniforms();
48                 void update_layout_hash();
49         };
50
51         struct AttributeInfo
52         {
53                 std::string name;
54                 int location = -1;
55                 unsigned array_size = 0;
56                 DataType type = VOID;
57         };
58
59         std::vector<UniformBlockInfo> uniform_blocks;
60         std::vector<UniformInfo> uniforms;
61         LayoutHash layout_hash = 0;
62         std::vector<AttributeInfo> attributes;
63         unsigned n_clip_distances = 0;
64
65         void update_layout_hash();
66 };
67
68 } // namespace GL
69 } // namespace Msp
70
71 #endif