]> git.tdb.fi Git - libs/gl.git/blob - source/core/reflectdata.h
Fix reflection of image types from Spir-V modules
[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 binding = -1;
41         };
42
43         struct UniformBlockInfo
44         {
45                 std::string name;
46                 unsigned data_size = 0;
47                 int bind_point = DEFAULT_BLOCK;
48                 std::vector<const UniformInfo *> uniforms;
49                 LayoutHash layout_hash = 0;
50
51                 void sort_uniforms();
52                 void update_layout_hash();
53         };
54
55         struct AttributeInfo
56         {
57                 std::string name;
58                 int location = -1;
59                 unsigned array_size = 0;
60                 DataType type = VOID;
61         };
62
63         std::vector<UniformBlockInfo> uniform_blocks;
64         std::vector<UniformInfo> uniforms;
65         LayoutHash layout_hash = 0;
66         std::vector<AttributeInfo> attributes;
67         unsigned n_clip_distances = 0;
68         unsigned n_descriptor_sets = 0;
69
70         void update_layout_hash();
71 };
72
73 } // namespace GL
74 } // namespace Msp
75
76 #endif