]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/reflectdata.h
Split reflection data from Program to a separate struct
[libs/gl.git] / source / core / reflectdata.h
diff --git a/source/core/reflectdata.h b/source/core/reflectdata.h
new file mode 100644 (file)
index 0000000..90b7ce0
--- /dev/null
@@ -0,0 +1,74 @@
+#ifndef MSP_GL_REFLECTDATA_H_
+#define MSP_GL_REFLECTDATA_H_
+
+#include <string>
+#include <vector>
+#include "datatype.h"
+#include "tag.h"
+
+namespace Msp {
+namespace GL {
+
+/**
+Reflection data for shader programs.
+*/
+struct ReflectData
+{
+       typedef unsigned LayoutHash;
+       struct UniformBlockInfo;
+
+       struct UniformInfo
+       {
+               std::string name;
+               const UniformBlockInfo *block;
+               union
+               {
+                       int location;
+                       unsigned offset;
+               };
+               unsigned array_size;
+               unsigned array_stride;
+               unsigned matrix_stride;
+               DataType type;
+               Tag tag;
+               int binding;
+
+               UniformInfo();
+       };
+
+       struct UniformBlockInfo
+       {
+               std::string name;
+               unsigned data_size;
+               int bind_point;
+               std::vector<const UniformInfo *> uniforms;
+               LayoutHash layout_hash;
+
+               UniformBlockInfo();
+
+               void sort_uniforms();
+               void update_layout_hash();
+       };
+
+       struct AttributeInfo
+       {
+               std::string name;
+               unsigned location;
+               unsigned array_size;
+               DataType type;
+
+               AttributeInfo();
+       };
+
+       std::vector<UniformBlockInfo> uniform_blocks;
+       std::vector<UniformInfo> uniforms;
+       LayoutHash layout_hash;
+       std::vector<AttributeInfo> attributes;
+
+       void update_layout_hash();
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif