summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2019-03-04 13:50:12 +0100
committerKonstantin Käfer <mail@kkaefer.com>2019-03-05 15:20:36 +0100
commit1ca25a375b3d7794bf56b0a106adb1bd7108c9e3 (patch)
treeebd0f58923e8b42874bf13bdfff00930e2d5cd56
parent1d050cb6fd1b0efa68c4b11513d3a0d9fe75899f (diff)
downloadqtlocation-mapboxgl-1ca25a375b3d7794bf56b0a106adb1bd7108c9e3.tar.gz
[core] add data type to vertex attribute descriptors
-rw-r--r--src/mbgl/gfx/attribute.hpp115
-rw-r--r--src/mbgl/gfx/types.hpp39
-rw-r--r--src/mbgl/gl/attribute.hpp41
-rw-r--r--src/mbgl/gl/context.cpp8
-rw-r--r--src/mbgl/gl/types.hpp10
-rw-r--r--src/mbgl/gl/value.cpp93
-rw-r--r--src/mbgl/gl/vertex_buffer.hpp5
-rw-r--r--src/mbgl/renderer/paint_property_binder.hpp31
8 files changed, 234 insertions, 108 deletions
diff --git a/src/mbgl/gfx/attribute.hpp b/src/mbgl/gfx/attribute.hpp
index ec34a69a9a..2f33d3e484 100644
--- a/src/mbgl/gfx/attribute.hpp
+++ b/src/mbgl/gfx/attribute.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include <mbgl/gfx/types.hpp>
#include <mbgl/util/type_list.hpp>
#include <mbgl/util/indexed_tuple.hpp>
@@ -20,18 +21,62 @@
namespace mbgl {
namespace gfx {
+namespace {
+
+template <typename, std::size_t> constexpr AttributeDataType AttributeDataTypeOf = AttributeDataType::Invalid;
+template <> constexpr AttributeDataType AttributeDataTypeOf<int8_t, 1> = AttributeDataType::Byte;
+template <> constexpr AttributeDataType AttributeDataTypeOf<int8_t, 2> = AttributeDataType::Byte2;
+template <> constexpr AttributeDataType AttributeDataTypeOf<int8_t, 3> = AttributeDataType::Byte3;
+template <> constexpr AttributeDataType AttributeDataTypeOf<int8_t, 4> = AttributeDataType::Byte4;
+template <> constexpr AttributeDataType AttributeDataTypeOf<uint8_t, 1> = AttributeDataType::UByte;
+template <> constexpr AttributeDataType AttributeDataTypeOf<uint8_t, 2> = AttributeDataType::UByte2;
+template <> constexpr AttributeDataType AttributeDataTypeOf<uint8_t, 3> = AttributeDataType::UByte3;
+template <> constexpr AttributeDataType AttributeDataTypeOf<uint8_t, 4> = AttributeDataType::UByte4;
+template <> constexpr AttributeDataType AttributeDataTypeOf<int16_t, 1> = AttributeDataType::Short;
+template <> constexpr AttributeDataType AttributeDataTypeOf<int16_t, 2> = AttributeDataType::Short2;
+template <> constexpr AttributeDataType AttributeDataTypeOf<int16_t, 3> = AttributeDataType::Short3;
+template <> constexpr AttributeDataType AttributeDataTypeOf<int16_t, 4> = AttributeDataType::Short4;
+template <> constexpr AttributeDataType AttributeDataTypeOf<uint16_t, 1> = AttributeDataType::UShort;
+template <> constexpr AttributeDataType AttributeDataTypeOf<uint16_t, 2> = AttributeDataType::UShort2;
+template <> constexpr AttributeDataType AttributeDataTypeOf<uint16_t, 3> = AttributeDataType::UShort3;
+template <> constexpr AttributeDataType AttributeDataTypeOf<uint16_t, 4> = AttributeDataType::UShort4;
+template <> constexpr AttributeDataType AttributeDataTypeOf<int32_t, 1> = AttributeDataType::Int;
+template <> constexpr AttributeDataType AttributeDataTypeOf<int32_t, 2> = AttributeDataType::Int2;
+template <> constexpr AttributeDataType AttributeDataTypeOf<int32_t, 3> = AttributeDataType::Int3;
+template <> constexpr AttributeDataType AttributeDataTypeOf<int32_t, 4> = AttributeDataType::Int4;
+template <> constexpr AttributeDataType AttributeDataTypeOf<uint32_t, 1> = AttributeDataType::UInt;
+template <> constexpr AttributeDataType AttributeDataTypeOf<uint32_t, 2> = AttributeDataType::UInt2;
+template <> constexpr AttributeDataType AttributeDataTypeOf<uint32_t, 3> = AttributeDataType::UInt3;
+template <> constexpr AttributeDataType AttributeDataTypeOf<uint32_t, 4> = AttributeDataType::UInt4;
+template <> constexpr AttributeDataType AttributeDataTypeOf<float, 1> = AttributeDataType::Float;
+template <> constexpr AttributeDataType AttributeDataTypeOf<float, 2> = AttributeDataType::Float2;
+template <> constexpr AttributeDataType AttributeDataTypeOf<float, 3> = AttributeDataType::Float3;
+template <> constexpr AttributeDataType AttributeDataTypeOf<float, 4> = AttributeDataType::Float4;
+
+} // namespace
+
template <typename T, std::size_t N>
class AttributeType {
public:
- using ValueType = T;
+ using ElementType = T;
+ static constexpr AttributeDataType DataType = AttributeDataTypeOf<T, N>;
static constexpr size_t Dimensions = N;
using Value = std::array<T, N>;
};
+struct AttributeDescriptor {
+ AttributeDataType dataType;
+ uint8_t offset;
+};
+
+inline bool operator==(const AttributeDescriptor& lhs, const AttributeDescriptor& rhs) {
+ return lhs.dataType == rhs.dataType && lhs.offset == rhs.offset;
+}
+
struct VertexDescriptor {
- const uint8_t size;
- const uint8_t count;
- const uint8_t offsets[5];
+ uint8_t stride;
+ uint8_t count;
+ AttributeDescriptor attributes[5];
};
// Attribute binding requires member offsets. The only standard way to
@@ -49,41 +94,41 @@ struct Vertex;
template <class A1>
struct Vertex<A1> {
using Type = Vertex<A1>;
- A1 a1;
+ typename A1::Value a1;
} MBGL_VERTEX_ALIGN;
template <class A1, class A2>
struct Vertex<A1, A2> {
using Type = Vertex<A1, A2>;
- A1 a1;
- A2 a2;
+ typename A1::Value a1;
+ typename A2::Value a2;
} MBGL_VERTEX_ALIGN;
template <class A1, class A2, class A3>
struct Vertex<A1, A2, A3> {
using Type = Vertex<A1, A2, A3>;
- A1 a1;
- A2 a2;
- A3 a3;
+ typename A1::Value a1;
+ typename A2::Value a2;
+ typename A3::Value a3;
} MBGL_VERTEX_ALIGN;
template <class A1, class A2, class A3, class A4>
struct Vertex<A1, A2, A3, A4> {
using Type = Vertex<A1, A2, A3, A4>;
- A1 a1;
- A2 a2;
- A3 a3;
- A4 a4;
+ typename A1::Value a1;
+ typename A2::Value a2;
+ typename A3::Value a3;
+ typename A4::Value a4;
} MBGL_VERTEX_ALIGN;
template <class A1, class A2, class A3, class A4, class A5>
struct Vertex<A1, A2, A3, A4, A5> {
using Type = Vertex<A1, A2, A3, A4, A5>;
- A1 a1;
- A2 a2;
- A3 a3;
- A4 a4;
- A5 a5;
+ typename A1::Value a1;
+ typename A2::Value a2;
+ typename A3::Value a3;
+ typename A4::Value a4;
+ typename A5::Value a5;
} MBGL_VERTEX_ALIGN;
template <class>
@@ -95,7 +140,7 @@ struct Descriptor<Vertex<A1>> {
static_assert(sizeof(Type) < 256, "vertex type must be smaller than 256 bytes");
static_assert(std::is_standard_layout<Type>::value, "vertex type must use standard layout");
static constexpr const VertexDescriptor Data = { sizeof(Type), 1, {
- offsetof(Type, a1),
+ { A1::DataType, offsetof(Type, a1) },
}};
};
@@ -105,8 +150,8 @@ struct Descriptor<Vertex<A1, A2>> {
static_assert(sizeof(Type) < 256, "vertex type must be smaller than 256 bytes");
static_assert(std::is_standard_layout<Type>::value, "vertex type must use standard layout");
static constexpr const VertexDescriptor Data = { sizeof(Type), 2, {
- offsetof(Type, a1),
- offsetof(Type, a2),
+ { A1::DataType, offsetof(Type, a1) },
+ { A2::DataType, offsetof(Type, a2) },
}};
};
@@ -116,9 +161,9 @@ struct Descriptor<Vertex<A1, A2, A3>> {
static_assert(sizeof(Type) < 256, "vertex type must be smaller than 256 bytes");
static_assert(std::is_standard_layout<Type>::value, "vertex type must use standard layout");
static constexpr const VertexDescriptor Data = { sizeof(Type), 3, {
- offsetof(Type, a1),
- offsetof(Type, a2),
- offsetof(Type, a3),
+ { A1::DataType, offsetof(Type, a1) },
+ { A2::DataType, offsetof(Type, a2) },
+ { A3::DataType, offsetof(Type, a3) },
}};
};
@@ -128,10 +173,10 @@ struct Descriptor<Vertex<A1, A2, A3, A4>> {
static_assert(sizeof(Type) < 256, "vertex type must be smaller than 256 bytes");
static_assert(std::is_standard_layout<Type>::value, "vertex type must use standard layout");
static constexpr const VertexDescriptor Data = { sizeof(Type), 4, {
- offsetof(Type, a1),
- offsetof(Type, a2),
- offsetof(Type, a3),
- offsetof(Type, a4),
+ { A1::DataType, offsetof(Type, a1) },
+ { A2::DataType, offsetof(Type, a2) },
+ { A3::DataType, offsetof(Type, a3) },
+ { A4::DataType, offsetof(Type, a4) },
}};
};
@@ -141,17 +186,17 @@ struct Descriptor<Vertex<A1, A2, A3, A4, A5>> {
static_assert(sizeof(Type) < 256, "vertex type must be smaller than 256 bytes");
static_assert(std::is_standard_layout<Type>::value, "vertex type must use standard layout");
static constexpr const VertexDescriptor Data = { sizeof(Type), 5, {
- offsetof(Type, a1),
- offsetof(Type, a2),
- offsetof(Type, a3),
- offsetof(Type, a4),
- offsetof(Type, a5),
+ { A1::DataType, offsetof(Type, a1) },
+ { A2::DataType, offsetof(Type, a2) },
+ { A3::DataType, offsetof(Type, a3) },
+ { A4::DataType, offsetof(Type, a4) },
+ { A5::DataType, offsetof(Type, a5) },
}};
};
template <class... As>
struct Vertex<TypeList<As...>> {
- using Type = Vertex<typename As::Type::Value...>;
+ using Type = Vertex<typename As::Type...>;
};
} // namespace detail
diff --git a/src/mbgl/gfx/types.hpp b/src/mbgl/gfx/types.hpp
index d1421dddb7..a9cb4e1ece 100644
--- a/src/mbgl/gfx/types.hpp
+++ b/src/mbgl/gfx/types.hpp
@@ -15,6 +15,45 @@ enum class PrimitiveType : uint8_t {
TriangleFan,
};
+enum class AttributeDataType : uint8_t {
+ Byte,
+ Byte2,
+ Byte3,
+ Byte4,
+
+ UByte,
+ UByte2,
+ UByte3,
+ UByte4,
+
+ Short,
+ Short2,
+ Short3,
+ Short4,
+
+ UShort,
+ UShort2,
+ UShort3,
+ UShort4,
+
+ Int,
+ Int2,
+ Int3,
+ Int4,
+
+ UInt,
+ UInt2,
+ UInt3,
+ UInt4,
+
+ Float,
+ Float2,
+ Float3,
+ Float4,
+
+ Invalid = 255,
+};
+
enum class ColorBlendEquationType : uint8_t {
Add,
Subtract,
diff --git a/src/mbgl/gl/attribute.hpp b/src/mbgl/gl/attribute.hpp
index e03e3ebf89..33749d257f 100644
--- a/src/mbgl/gl/attribute.hpp
+++ b/src/mbgl/gl/attribute.hpp
@@ -18,29 +18,17 @@
namespace mbgl {
namespace gl {
-template <class> struct DataTypeOf;
-template <> struct DataTypeOf< int8_t> : std::integral_constant<DataType, DataType::Byte> {};
-template <> struct DataTypeOf<uint8_t> : std::integral_constant<DataType, DataType::UnsignedByte> {};
-template <> struct DataTypeOf< int16_t> : std::integral_constant<DataType, DataType::Short> {};
-template <> struct DataTypeOf<uint16_t> : std::integral_constant<DataType, DataType::UnsignedShort> {};
-template <> struct DataTypeOf< int32_t> : std::integral_constant<DataType, DataType::Integer> {};
-template <> struct DataTypeOf<uint32_t> : std::integral_constant<DataType, DataType::UnsignedInteger> {};
-template <> struct DataTypeOf<float> : std::integral_constant<DataType, DataType::Float> {};
-
class AttributeBinding {
public:
- DataType attributeType;
- uint8_t attributeSize;
- uint32_t attributeOffset;
-
+ gfx::AttributeDescriptor attribute;
+ uint8_t vertexStride;
BufferID vertexBuffer;
- uint32_t vertexSize;
uint32_t vertexOffset;
friend bool operator==(const AttributeBinding& lhs,
const AttributeBinding& rhs) {
- return std::tie(lhs.attributeType, lhs.attributeSize, lhs.attributeOffset, lhs.vertexBuffer, lhs.vertexSize, lhs.vertexOffset)
- == std::tie(rhs.attributeType, rhs.attributeSize, rhs.attributeOffset, rhs.vertexBuffer, rhs.vertexSize, rhs.vertexOffset);
+ return std::tie(lhs.attribute, lhs.vertexStride, lhs.vertexBuffer, lhs.vertexOffset)
+ == std::tie(rhs.attribute, rhs.vertexStride, rhs.vertexBuffer, rhs.vertexOffset);
}
};
@@ -51,20 +39,13 @@ using AttributeBindingArray = std::vector<optional<AttributeBinding>>;
override the number of components available in the buffer for each vertex. Thus,
a buffer with only one float for each vertex can be bound to a `vec2` attribute
*/
-template <class AttributeType, class Vertex>
-AttributeBinding attributeBinding(const VertexBuffer<Vertex>& buffer,
- std::size_t attributeIndex,
- std::size_t attributeSize = AttributeType::Dimensions) {
- static_assert(std::is_standard_layout<Vertex>::value, "vertex type must use standard layout");
- assert(attributeSize >= 1);
- assert(attributeSize <= 4);
- assert(gfx::vertexDescriptor<Vertex>.count > attributeIndex);
- return AttributeBinding {
- DataTypeOf<typename AttributeType::ValueType>::value,
- static_cast<uint8_t>(attributeSize),
- static_cast<uint32_t>(gfx::vertexDescriptor<Vertex>.offsets[attributeIndex]),
+template <std::size_t I, typename Vertex>
+AttributeBinding attributeBinding(const VertexBuffer<Vertex>& buffer) {
+ static_assert(I < gfx::vertexDescriptor<Vertex>.count, "vertex attribute index out of range");
+ return {
+ gfx::vertexDescriptor<Vertex>.attributes[I],
+ gfx::vertexDescriptor<Vertex>.stride,
buffer.buffer,
- static_cast<uint32_t>(gfx::vertexDescriptor<Vertex>.size),
0,
};
}
@@ -126,7 +107,7 @@ public:
}
static Bindings bindings(const VertexBuffer<gfx::Vertex<Types>>& buffer) {
- return Bindings { attributeBinding<typename As::Type>(buffer, TypeIndex<As, As...>::value)... };
+ return Bindings { attributeBinding<TypeIndex<As, As...>::value>(buffer)... };
}
static Bindings offsetBindings(const Bindings& bindings, std::size_t vertexOffset) {
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp
index bcbb3ab66c..72d59737f3 100644
--- a/src/mbgl/gl/context.cpp
+++ b/src/mbgl/gl/context.cpp
@@ -17,14 +17,6 @@ using namespace platform;
static_assert(underlying_type(ShaderType::Vertex) == GL_VERTEX_SHADER, "OpenGL type mismatch");
static_assert(underlying_type(ShaderType::Fragment) == GL_FRAGMENT_SHADER, "OpenGL type mismatch");
-static_assert(underlying_type(DataType::Byte) == GL_BYTE, "OpenGL type mismatch");
-static_assert(underlying_type(DataType::UnsignedByte) == GL_UNSIGNED_BYTE, "OpenGL type mismatch");
-static_assert(underlying_type(DataType::Short) == GL_SHORT, "OpenGL type mismatch");
-static_assert(underlying_type(DataType::UnsignedShort) == GL_UNSIGNED_SHORT, "OpenGL type mismatch");
-static_assert(underlying_type(DataType::Integer) == GL_INT, "OpenGL type mismatch");
-static_assert(underlying_type(DataType::UnsignedInteger) == GL_UNSIGNED_INT, "OpenGL type mismatch");
-static_assert(underlying_type(DataType::Float) == GL_FLOAT, "OpenGL type mismatch");
-
#if not MBGL_USE_GLES2
static_assert(underlying_type(RenderbufferType::RGBA) == GL_RGBA8, "OpenGL type mismatch");
#else
diff --git a/src/mbgl/gl/types.hpp b/src/mbgl/gl/types.hpp
index 4c3033454f..22b7098100 100644
--- a/src/mbgl/gl/types.hpp
+++ b/src/mbgl/gl/types.hpp
@@ -32,16 +32,6 @@ enum class ShaderType : uint32_t {
Fragment = 0x8B30
};
-enum class DataType : uint16_t {
- Byte = 0x1400,
- UnsignedByte = 0x1401,
- Short = 0x1402,
- UnsignedShort = 0x1403,
- Integer = 0x1404,
- UnsignedInteger = 0x1405,
- Float = 0x1406
-};
-
enum class RenderbufferType : uint32_t {
RGBA = 0x8058,
DepthStencil = 0x88F0,
diff --git a/src/mbgl/gl/value.cpp b/src/mbgl/gl/value.cpp
index 4e56686103..b290cde50c 100644
--- a/src/mbgl/gl/value.cpp
+++ b/src/mbgl/gl/value.cpp
@@ -398,17 +398,102 @@ BindVertexArray::Type BindVertexArray::Get(const Context& context) {
const optional<AttributeBinding> VertexAttribute::Default {};
+namespace {
+
+GLenum vertexType(const gfx::AttributeDataType type) {
+ switch (type) {
+ case gfx::AttributeDataType::Byte:
+ case gfx::AttributeDataType::Byte2:
+ case gfx::AttributeDataType::Byte3:
+ case gfx::AttributeDataType::Byte4:
+ return GL_BYTE;
+ case gfx::AttributeDataType::UByte:
+ case gfx::AttributeDataType::UByte2:
+ case gfx::AttributeDataType::UByte3:
+ case gfx::AttributeDataType::UByte4:
+ return GL_UNSIGNED_BYTE;
+ case gfx::AttributeDataType::Short:
+ case gfx::AttributeDataType::Short2:
+ case gfx::AttributeDataType::Short3:
+ case gfx::AttributeDataType::Short4:
+ return GL_SHORT;
+ case gfx::AttributeDataType::UShort:
+ case gfx::AttributeDataType::UShort2:
+ case gfx::AttributeDataType::UShort3:
+ case gfx::AttributeDataType::UShort4:
+ return GL_UNSIGNED_SHORT;
+ case gfx::AttributeDataType::Int:
+ case gfx::AttributeDataType::Int2:
+ case gfx::AttributeDataType::Int3:
+ case gfx::AttributeDataType::Int4:
+ return GL_INT;
+ case gfx::AttributeDataType::UInt:
+ case gfx::AttributeDataType::UInt2:
+ case gfx::AttributeDataType::UInt3:
+ case gfx::AttributeDataType::UInt4:
+ return GL_UNSIGNED_INT;
+ case gfx::AttributeDataType::Float:
+ case gfx::AttributeDataType::Float2:
+ case gfx::AttributeDataType::Float3:
+ case gfx::AttributeDataType::Float4:
+ return GL_FLOAT;
+ default:
+ return GL_FLOAT;
+ }
+}
+
+GLint components(const gfx::AttributeDataType type) {
+ switch (type) {
+ case gfx::AttributeDataType::Byte:
+ case gfx::AttributeDataType::UByte:
+ case gfx::AttributeDataType::Short:
+ case gfx::AttributeDataType::UShort:
+ case gfx::AttributeDataType::Int:
+ case gfx::AttributeDataType::UInt:
+ case gfx::AttributeDataType::Float:
+ return 1;
+ case gfx::AttributeDataType::Byte2:
+ case gfx::AttributeDataType::UByte2:
+ case gfx::AttributeDataType::Short2:
+ case gfx::AttributeDataType::UShort2:
+ case gfx::AttributeDataType::Int2:
+ case gfx::AttributeDataType::UInt2:
+ case gfx::AttributeDataType::Float2:
+ return 2;
+ case gfx::AttributeDataType::Byte3:
+ case gfx::AttributeDataType::UByte3:
+ case gfx::AttributeDataType::Short3:
+ case gfx::AttributeDataType::UShort3:
+ case gfx::AttributeDataType::Int3:
+ case gfx::AttributeDataType::UInt3:
+ case gfx::AttributeDataType::Float3:
+ return 3;
+ case gfx::AttributeDataType::Byte4:
+ case gfx::AttributeDataType::UByte4:
+ case gfx::AttributeDataType::Short4:
+ case gfx::AttributeDataType::UShort4:
+ case gfx::AttributeDataType::Int4:
+ case gfx::AttributeDataType::UInt4:
+ case gfx::AttributeDataType::Float4:
+ return 4;
+ default:
+ return 0;
+ }
+}
+
+} // namespace
+
void VertexAttribute::Set(const optional<AttributeBinding>& binding, Context& context, AttributeLocation location) {
if (binding) {
context.vertexBuffer = binding->vertexBuffer;
MBGL_CHECK_ERROR(glEnableVertexAttribArray(location));
MBGL_CHECK_ERROR(glVertexAttribPointer(
location,
- static_cast<GLint>(binding->attributeSize),
- static_cast<GLenum>(binding->attributeType),
+ components(binding->attribute.dataType),
+ vertexType(binding->attribute.dataType),
static_cast<GLboolean>(false),
- static_cast<GLsizei>(binding->vertexSize),
- reinterpret_cast<GLvoid*>(binding->attributeOffset + (binding->vertexSize * binding->vertexOffset))));
+ static_cast<GLsizei>(binding->vertexStride),
+ reinterpret_cast<GLvoid*>(binding->attribute.offset + (binding->vertexStride * binding->vertexOffset))));
} else {
MBGL_CHECK_ERROR(glDisableVertexAttribArray(location));
}
diff --git a/src/mbgl/gl/vertex_buffer.hpp b/src/mbgl/gl/vertex_buffer.hpp
index 0b62b86c12..b65e7f9a01 100644
--- a/src/mbgl/gl/vertex_buffer.hpp
+++ b/src/mbgl/gl/vertex_buffer.hpp
@@ -2,17 +2,12 @@
#include <mbgl/gl/object.hpp>
-#include <vector>
-
namespace mbgl {
namespace gl {
template <class V>
class VertexBuffer {
public:
- using Vertex = V;
- static constexpr std::size_t vertexSize = sizeof(Vertex);
-
std::size_t vertexCount;
UniqueBuffer buffer;
};
diff --git a/src/mbgl/renderer/paint_property_binder.hpp b/src/mbgl/renderer/paint_property_binder.hpp
index 874fab5add..cbf60ea679 100644
--- a/src/mbgl/renderer/paint_property_binder.hpp
+++ b/src/mbgl/renderer/paint_property_binder.hpp
@@ -25,7 +25,7 @@ namespace mbgl {
being zoomed.
*/
template <class AttributeType>
-using ZoomInterpolatedAttributeType = gfx::AttributeType<typename AttributeType::ValueType, AttributeType::Dimensions * 2>;
+using ZoomInterpolatedAttributeType = gfx::AttributeType<typename AttributeType::ElementType, AttributeType::Dimensions * 2>;
inline std::array<float, 1> attributeValue(float v) {
return {{ v }};
@@ -174,8 +174,7 @@ template <class T, class A>
class SourceFunctionPaintPropertyBinder : public PaintPropertyBinder<T, T, PossiblyEvaluatedPropertyValue<T>, A> {
public:
using BaseAttributeType = A;
- using BaseAttributeValue = typename A::Value;
- using BaseVertex = gfx::Vertex<BaseAttributeValue>;
+ using BaseVertex = gfx::Vertex<BaseAttributeType>;
using AttributeType = ZoomInterpolatedAttributeType<A>;
@@ -201,7 +200,9 @@ public:
if (currentValue.isConstant()) {
return {};
} else {
- return std::tuple<optional<gl::AttributeBinding>> { gl::attributeBinding<AttributeType>(*vertexBuffer, 0, BaseAttributeType::Dimensions) };
+ return std::tuple<optional<gl::AttributeBinding>>{
+ gl::attributeBinding<0>(*vertexBuffer)
+ };
}
}
@@ -231,7 +232,7 @@ public:
using AttributeType = ZoomInterpolatedAttributeType<A>;
using AttributeValue = typename AttributeType::Value;
- using Vertex = gfx::Vertex<AttributeValue>;
+ using Vertex = gfx::Vertex<AttributeType>;
CompositeFunctionPaintPropertyBinder(style::PropertyExpression<T> expression_, float zoom, T defaultValue_)
: expression(std::move(expression_)),
@@ -259,7 +260,9 @@ public:
if (currentValue.isConstant()) {
return {};
} else {
- return std::tuple<optional<gl::AttributeBinding>> { gl::attributeBinding<AttributeType>(*vertexBuffer, 0) };
+ return std::tuple<optional<gl::AttributeBinding>>{
+ gl::attributeBinding<0>(*vertexBuffer)
+ };
}
}
@@ -295,13 +298,10 @@ public:
using AttributeType2 = ZoomInterpolatedAttributeType<A2>;
using BaseAttributeType = A1;
- using BaseAttributeValue = typename BaseAttributeType::Value;
-
using BaseAttributeType2 = A2;
- using BaseAttributeValue2 = typename BaseAttributeType2::Value;
- using Vertex = gfx::Vertex<BaseAttributeValue>;
- using Vertex2 = gfx::Vertex<BaseAttributeValue2>;
+ using Vertex = gfx::Vertex<BaseAttributeType>;
+ using Vertex2 = gfx::Vertex<BaseAttributeType2>;
CompositeCrossFadedPaintPropertyBinder(style::PropertyExpression<T> expression_, float zoom, T defaultValue_)
: expression(std::move(expression_)),
@@ -354,11 +354,10 @@ public:
if (currentValue.isConstant()) {
return {};
} else {
- return std::tuple<optional<gl::AttributeBinding>, optional<gl::AttributeBinding>> {
- gl::attributeBinding<AttributeType>(*patternToVertexBuffer, 0, BaseAttributeType::Dimensions),
- gl::attributeBinding<AttributeType2>(
- crossfade.fromScale == 2 ? *zoomInVertexBuffer : *zoomOutVertexBuffer,
- 0, BaseAttributeType2::Dimensions) };
+ return std::tuple<optional<gl::AttributeBinding>, optional<gl::AttributeBinding>>{
+ gl::attributeBinding<0>(*patternToVertexBuffer),
+ gl::attributeBinding<0>(crossfade.fromScale == 2 ? *zoomInVertexBuffer : *zoomOutVertexBuffer)
+ };
}
}