]> git.tdb.fi Git - libs/gl.git/blob - source/core/reflectdata.h
Change default binding ranges to match lowest OpenGL standard
[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 = 0;
60         std::vector<AttributeInfo> attributes;
61         unsigned n_clip_distances = 0;
62
63         void update_layout_hash();
64 };
65
66 } // namespace GL
67 } // namespace Msp
68
69 #endif