summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/attribute.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/gl/attribute.hpp')
-rw-r--r--src/mbgl/gl/attribute.hpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/mbgl/gl/attribute.hpp b/src/mbgl/gl/attribute.hpp
index 62c89178cd..c7f9ba3fd4 100644
--- a/src/mbgl/gl/attribute.hpp
+++ b/src/mbgl/gl/attribute.hpp
@@ -95,5 +95,36 @@ public:
}
};
+template <class>
+class AttributeKey;
+
+constexpr auto attributeDefinePrefix() {
+ return "#define HAS_UNIFORM_u_";
+}
+
+template <class... As>
+class AttributeKey<TypeList<As...>> final {
+public:
+ static_assert(sizeof...(As) <= 32, "attribute count exceeds 32");
+
+ static uint32_t compute(const gfx::AttributeBindings<TypeList<As...>>& bindings) {
+ uint32_t value = 0;
+ util::ignore(
+ { (bindings.template get<As>() ? (void)(value |= 1 << TypeIndex<As, As...>::value)
+ : (void)0,
+ 0)... });
+ return value;
+ }
+
+ static std::string defines(const gfx::AttributeBindings<TypeList<As...>>& bindings) {
+ std::string result;
+ util::ignore({ (!bindings.template get<As>()
+ ? (void)(result += concat_literals<&attributeDefinePrefix, &As::name, &string_literal<'\n'>::value>::value())
+ : (void)0,
+ 0)... });
+ return result;
+ }
+};
+
} // namespace gl
} // namespace mbgl