]> git.tdb.fi Git - libs/gl.git/blob - source/core/reflectdata.cpp
7a141db261f0b032aa3a9800a61079fa5a9162c2
[libs/gl.git] / source / core / reflectdata.cpp
1 #include <msp/core/algorithm.h>
2 #include <msp/core/hash.h>
3 #include <msp/strings/format.h>
4 #include "reflectdata.h"
5
6 using namespace std;
7
8 namespace Msp {
9 namespace GL {
10
11 void ReflectData::update_layout_hash()
12 {
13         string layout_descriptor;
14         for(const UniformBlockInfo &b: uniform_blocks)
15                 layout_descriptor += format("%d:%x\n", b.bind_point, b.layout_hash);
16         layout_hash = hash32(layout_descriptor);
17 }
18
19
20 ReflectData::UniformInfo::UniformInfo():
21         block(0),
22         location(-1),
23         array_size(0),
24         array_stride(0),
25         matrix_stride(0),
26         type(VOID),
27         binding(-1)
28 { }
29
30
31 ReflectData::UniformBlockInfo::UniformBlockInfo():
32         data_size(0),
33         bind_point(-1),
34         layout_hash(0)
35 { }
36
37 void ReflectData::UniformBlockInfo::sort_uniforms()
38 {
39         sort(uniforms, [](const UniformInfo *u1, const UniformInfo *u2){ return u1->location<u2->location; });
40 }
41
42 void ReflectData::UniformBlockInfo::update_layout_hash()
43 {
44         string layout_descriptor;
45         for(const UniformInfo *u: uniforms)
46                 layout_descriptor += format("%d:%s:%x:%d\n", u->location, u->name, u->type, u->array_size);
47         layout_hash = hash32(layout_descriptor);
48 }
49
50
51 ReflectData::AttributeInfo::AttributeInfo():
52         location(-1),
53         array_size(0),
54         type(VOID)
55 { }
56
57 } // namespace GL
58 } // namespace Msp