diff options
Diffstat (limited to 'src/mbgl/programs/attributes.hpp')
-rw-r--r-- | src/mbgl/programs/attributes.hpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/mbgl/programs/attributes.hpp b/src/mbgl/programs/attributes.hpp index 7d39c04395..e9ca18927e 100644 --- a/src/mbgl/programs/attributes.hpp +++ b/src/mbgl/programs/attributes.hpp @@ -8,6 +8,16 @@ namespace mbgl { namespace attributes { +/* + * Pack a pair of values, interpreted as uint8's, into a single float. + * Used to conserve vertex attributes. Values are unpacked in the vertex + * shader using the `unpack_float()` function, defined in _prelude.vertex.glsl. + */ +template <typename T> +inline uint16_t packUint8Pair(T a, T b) { + return static_cast<uint16_t>(a) * 256 + static_cast<uint16_t>(b); +} + // Layout attributes MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_pos); @@ -15,10 +25,15 @@ MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_extrude); MBGL_DEFINE_ATTRIBUTE(int16_t, 4, a_pos_offset); MBGL_DEFINE_ATTRIBUTE(uint16_t, 2, a_texture_pos); -template <std::size_t N> +template <typename T, std::size_t N> struct a_data { static auto name() { return "a_data"; } - using Type = gl::Attribute<uint8_t, N>; + using Type = gl::Attribute<T, N>; +}; + +struct a_size { + static auto name() { return "a_size"; } + using Type = gl::Attribute<uint16_t, 3>; }; template <std::size_t N> |