[core] extract attribute structs and gl::Vertex to separate namespace
This commit is contained in:
@@ -498,6 +498,7 @@
|
||||
"mbgl/geometry/dem_data.hpp": "src/mbgl/geometry/dem_data.hpp",
|
||||
"mbgl/geometry/feature_index.hpp": "src/mbgl/geometry/feature_index.hpp",
|
||||
"mbgl/geometry/line_atlas.hpp": "src/mbgl/geometry/line_atlas.hpp",
|
||||
"mbgl/gfx/attribute.hpp": "src/mbgl/gfx/attribute.hpp",
|
||||
"mbgl/gfx/uniform.hpp": "src/mbgl/gfx/uniform.hpp",
|
||||
"mbgl/gl/attribute.hpp": "src/mbgl/gl/attribute.hpp",
|
||||
"mbgl/gl/color_mode.hpp": "src/mbgl/gl/color_mode.hpp",
|
||||
|
||||
148
src/mbgl/gfx/attribute.hpp
Normal file
148
src/mbgl/gfx/attribute.hpp
Normal file
@@ -0,0 +1,148 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/type_list.hpp>
|
||||
#include <mbgl/util/indexed_tuple.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
|
||||
#define MBGL_DEFINE_ATTRIBUTE(type_, n_, name_) \
|
||||
struct name_ { \
|
||||
using Type = ::mbgl::gfx::AttributeType<type_, n_>; \
|
||||
static auto name() { \
|
||||
return #name_; \
|
||||
} \
|
||||
}
|
||||
|
||||
namespace mbgl {
|
||||
namespace gfx {
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
class AttributeType {
|
||||
public:
|
||||
using ValueType = T;
|
||||
static constexpr size_t Dimensions = N;
|
||||
using Value = std::array<T, N>;
|
||||
};
|
||||
|
||||
// Attribute binding requires member offsets. The only standard way to
|
||||
// obtain an offset is the offsetof macro. The offsetof macro has defined
|
||||
// behavior only for standard layout types. That rules out std::tuple and
|
||||
// any other solution that relies on chained inheritance. Manually implemented
|
||||
// variadic specialization looks like the only solution. Fortunately, we
|
||||
// only use a maximum of five attributes.
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <class...>
|
||||
class Vertex;
|
||||
|
||||
template <>
|
||||
class Vertex<> {
|
||||
public:
|
||||
using VertexType = Vertex<>;
|
||||
};
|
||||
|
||||
template <class A1>
|
||||
class Vertex<A1> {
|
||||
public:
|
||||
A1 a1;
|
||||
|
||||
using VertexType = Vertex<A1>;
|
||||
static const std::size_t attributeOffsets[1];
|
||||
};
|
||||
|
||||
template <class A1, class A2>
|
||||
class Vertex<A1, A2> {
|
||||
public:
|
||||
A1 a1;
|
||||
A2 a2;
|
||||
|
||||
using VertexType = Vertex<A1, A2>;
|
||||
static const std::size_t attributeOffsets[2];
|
||||
};
|
||||
|
||||
template <class A1, class A2, class A3>
|
||||
class Vertex<A1, A2, A3> {
|
||||
public:
|
||||
A1 a1;
|
||||
A2 a2;
|
||||
A3 a3;
|
||||
|
||||
using VertexType = Vertex<A1, A2, A3>;
|
||||
static const std::size_t attributeOffsets[3];
|
||||
};
|
||||
|
||||
template <class A1, class A2, class A3, class A4>
|
||||
class Vertex<A1, A2, A3, A4> {
|
||||
public:
|
||||
A1 a1;
|
||||
A2 a2;
|
||||
A3 a3;
|
||||
A4 a4;
|
||||
|
||||
using VertexType = Vertex<A1, A2, A3, A4>;
|
||||
static const std::size_t attributeOffsets[4];
|
||||
};
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5>
|
||||
class Vertex<A1, A2, A3, A4, A5> {
|
||||
public:
|
||||
A1 a1;
|
||||
A2 a2;
|
||||
A3 a3;
|
||||
A4 a4;
|
||||
A5 a5;
|
||||
|
||||
using VertexType = Vertex<A1, A2, A3, A4, A5>;
|
||||
static const std::size_t attributeOffsets[5];
|
||||
};
|
||||
|
||||
template <class A1>
|
||||
const std::size_t Vertex<A1>::attributeOffsets[1] = {
|
||||
offsetof(VertexType, a1)
|
||||
};
|
||||
|
||||
template <class A1, class A2>
|
||||
const std::size_t Vertex<A1, A2>::attributeOffsets[2] = {
|
||||
offsetof(VertexType, a1),
|
||||
offsetof(VertexType, a2)
|
||||
};
|
||||
|
||||
template <class A1, class A2, class A3>
|
||||
const std::size_t Vertex<A1, A2, A3>::attributeOffsets[3] = {
|
||||
offsetof(VertexType, a1),
|
||||
offsetof(VertexType, a2),
|
||||
offsetof(VertexType, a3)
|
||||
};
|
||||
|
||||
template <class A1, class A2, class A3, class A4>
|
||||
const std::size_t Vertex<A1, A2, A3, A4>::attributeOffsets[4] = {
|
||||
offsetof(VertexType, a1),
|
||||
offsetof(VertexType, a2),
|
||||
offsetof(VertexType, a3),
|
||||
offsetof(VertexType, a4)
|
||||
};
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5>
|
||||
const std::size_t Vertex<A1, A2, A3, A4, A5>::attributeOffsets[5] = {
|
||||
offsetof(VertexType, a1),
|
||||
offsetof(VertexType, a2),
|
||||
offsetof(VertexType, a3),
|
||||
offsetof(VertexType, a4),
|
||||
offsetof(VertexType, a5)
|
||||
};
|
||||
|
||||
template <class... As>
|
||||
class Vertex<TypeList<As...>> {
|
||||
public:
|
||||
using VertexType = Vertex<typename As::Type::Value...>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class A>
|
||||
using Vertex = typename detail::Vertex<A>::VertexType;
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mbgl
|
||||
@@ -7,6 +7,17 @@ namespace gl {
|
||||
|
||||
using namespace platform;
|
||||
|
||||
optional<AttributeBinding> offsetAttributeBinding(const optional<AttributeBinding>& binding, std::size_t vertexOffset) {
|
||||
assert(vertexOffset <= std::numeric_limits<uint32_t>::max());
|
||||
if (binding) {
|
||||
AttributeBinding result = *binding;
|
||||
result.vertexOffset = static_cast<uint32_t>(vertexOffset);
|
||||
return result;
|
||||
} else {
|
||||
return binding;
|
||||
}
|
||||
}
|
||||
|
||||
void bindAttributeLocation(Context& context, ProgramID id, AttributeLocation location, const char* name) {
|
||||
// We're using sequentially numberered attribute locations starting with 0. Therefore we can use
|
||||
// the location as a proxy for the number of attributes.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/attribute.hpp>
|
||||
#include <mbgl/gl/types.hpp>
|
||||
#include <mbgl/gl/vertex_buffer.hpp>
|
||||
#include <mbgl/util/ignore.hpp>
|
||||
@@ -45,176 +46,41 @@ public:
|
||||
|
||||
using AttributeBindingArray = std::vector<optional<AttributeBinding>>;
|
||||
|
||||
/*
|
||||
gl::Attribute<T,N> manages the binding of a vertex buffer to a GL program attribute.
|
||||
- T is the underlying primitive type (exposed as Attribute<T,N>::ValueType)
|
||||
- N is the number of components in the attribute declared in the shader (exposed as Attribute<T,N>::Dimensions)
|
||||
*/
|
||||
template <class T, std::size_t N>
|
||||
class Attribute {
|
||||
public:
|
||||
using ValueType = T;
|
||||
static constexpr size_t Dimensions = N;
|
||||
using Value = std::array<T, N>;
|
||||
|
||||
/*
|
||||
Create a binding for this attribute. The `attributeSize` parameter may be used to
|
||||
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 Vertex>
|
||||
static AttributeBinding binding(const VertexBuffer<Vertex>& buffer,
|
||||
std::size_t attributeIndex,
|
||||
std::size_t attributeSize = N) {
|
||||
static_assert(std::is_standard_layout<Vertex>::value, "vertex type must use standard layout");
|
||||
assert(attributeSize >= 1);
|
||||
assert(attributeSize <= 4);
|
||||
assert(Vertex::attributeOffsets[attributeIndex] <= std::numeric_limits<uint32_t>::max());
|
||||
static_assert(sizeof(Vertex) <= std::numeric_limits<uint32_t>::max(), "vertex too large");
|
||||
return AttributeBinding {
|
||||
DataTypeOf<T>::value,
|
||||
static_cast<uint8_t>(attributeSize),
|
||||
static_cast<uint32_t>(Vertex::attributeOffsets[attributeIndex]),
|
||||
buffer.buffer,
|
||||
static_cast<uint32_t>(sizeof(Vertex)),
|
||||
0,
|
||||
};
|
||||
}
|
||||
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(Vertex::attributeOffsets[attributeIndex] <= std::numeric_limits<uint32_t>::max());
|
||||
static_assert(sizeof(Vertex) <= std::numeric_limits<uint32_t>::max(), "vertex too large");
|
||||
return AttributeBinding {
|
||||
DataTypeOf<typename AttributeType::ValueType>::value,
|
||||
static_cast<uint8_t>(attributeSize),
|
||||
static_cast<uint32_t>(Vertex::attributeOffsets[attributeIndex]),
|
||||
buffer.buffer,
|
||||
static_cast<uint32_t>(sizeof(Vertex)),
|
||||
0,
|
||||
};
|
||||
}
|
||||
|
||||
static optional<AttributeBinding> offsetBinding(const optional<AttributeBinding>& binding, std::size_t vertexOffset) {
|
||||
assert(vertexOffset <= std::numeric_limits<uint32_t>::max());
|
||||
if (binding) {
|
||||
AttributeBinding result = *binding;
|
||||
result.vertexOffset = static_cast<uint32_t>(vertexOffset);
|
||||
return result;
|
||||
} else {
|
||||
return binding;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#define MBGL_DEFINE_ATTRIBUTE(type_, n_, name_) \
|
||||
struct name_ { \
|
||||
static auto name() { return #name_; } \
|
||||
using Type = ::mbgl::gl::Attribute<type_, n_>; \
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
// Attribute binding requires member offsets. The only standard way to
|
||||
// obtain an offset is the offsetof macro. The offsetof macro has defined
|
||||
// behavior only for standard layout types. That rules out std::tuple and
|
||||
// any other solution that relies on chained inheritance. Manually implemented
|
||||
// variadic specialization looks like the only solution. Fortunately, we
|
||||
// only use a maximum of five attributes.
|
||||
|
||||
template <class... As>
|
||||
class Vertex;
|
||||
|
||||
template <>
|
||||
class Vertex<> {
|
||||
public:
|
||||
using VertexType = Vertex<>;
|
||||
};
|
||||
|
||||
template <class A1>
|
||||
class Vertex<A1> {
|
||||
public:
|
||||
typename A1::Value a1;
|
||||
|
||||
using VertexType = Vertex<A1>;
|
||||
static const std::size_t attributeOffsets[1];
|
||||
};
|
||||
|
||||
template <class A1, class A2>
|
||||
class Vertex<A1, A2> {
|
||||
public:
|
||||
typename A1::Value a1;
|
||||
typename A2::Value a2;
|
||||
|
||||
using VertexType = Vertex<A1, A2>;
|
||||
static const std::size_t attributeOffsets[2];
|
||||
};
|
||||
|
||||
template <class A1, class A2, class A3>
|
||||
class Vertex<A1, A2, A3> {
|
||||
public:
|
||||
typename A1::Value a1;
|
||||
typename A2::Value a2;
|
||||
typename A3::Value a3;
|
||||
|
||||
using VertexType = Vertex<A1, A2, A3>;
|
||||
static const std::size_t attributeOffsets[3];
|
||||
};
|
||||
|
||||
template <class A1, class A2, class A3, class A4>
|
||||
class Vertex<A1, A2, A3, A4> {
|
||||
public:
|
||||
typename A1::Value a1;
|
||||
typename A2::Value a2;
|
||||
typename A3::Value a3;
|
||||
typename A4::Value a4;
|
||||
|
||||
using VertexType = Vertex<A1, A2, A3, A4>;
|
||||
static const std::size_t attributeOffsets[4];
|
||||
};
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5>
|
||||
class Vertex<A1, A2, A3, A4, A5> {
|
||||
public:
|
||||
typename A1::Value a1;
|
||||
typename A2::Value a2;
|
||||
typename A3::Value a3;
|
||||
typename A4::Value a4;
|
||||
typename A5::Value a5;
|
||||
|
||||
using VertexType = Vertex<A1, A2, A3, A4, A5>;
|
||||
static const std::size_t attributeOffsets[5];
|
||||
};
|
||||
|
||||
template <class A1>
|
||||
const std::size_t Vertex<A1>::attributeOffsets[1] = {
|
||||
offsetof(VertexType, a1)
|
||||
};
|
||||
|
||||
template <class A1, class A2>
|
||||
const std::size_t Vertex<A1, A2>::attributeOffsets[2] = {
|
||||
offsetof(VertexType, a1),
|
||||
offsetof(VertexType, a2)
|
||||
};
|
||||
|
||||
template <class A1, class A2, class A3>
|
||||
const std::size_t Vertex<A1, A2, A3>::attributeOffsets[3] = {
|
||||
offsetof(VertexType, a1),
|
||||
offsetof(VertexType, a2),
|
||||
offsetof(VertexType, a3)
|
||||
};
|
||||
|
||||
template <class A1, class A2, class A3, class A4>
|
||||
const std::size_t Vertex<A1, A2, A3, A4>::attributeOffsets[4] = {
|
||||
offsetof(VertexType, a1),
|
||||
offsetof(VertexType, a2),
|
||||
offsetof(VertexType, a3),
|
||||
offsetof(VertexType, a4)
|
||||
};
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5>
|
||||
const std::size_t Vertex<A1, A2, A3, A4, A5>::attributeOffsets[5] = {
|
||||
offsetof(VertexType, a1),
|
||||
offsetof(VertexType, a2),
|
||||
offsetof(VertexType, a3),
|
||||
offsetof(VertexType, a4),
|
||||
offsetof(VertexType, a5)
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
optional<AttributeBinding> offsetAttributeBinding(const optional<AttributeBinding>& binding, std::size_t vertexOffset);
|
||||
|
||||
class Context;
|
||||
void bindAttributeLocation(Context&, ProgramID, AttributeLocation, const char * name);
|
||||
std::set<std::string> getActiveAttributes(ProgramID);
|
||||
|
||||
template <class>
|
||||
class Attributes;
|
||||
|
||||
template <class... As>
|
||||
class Attributes final {
|
||||
class Attributes<TypeList<As...>> final {
|
||||
public:
|
||||
using Types = TypeList<As...>;
|
||||
using Locations = IndexedTuple<
|
||||
@@ -225,8 +91,6 @@ public:
|
||||
TypeList<ExpandToType<As, optional<AttributeBinding>>...>>;
|
||||
using NamedLocations = std::vector<std::pair<const std::string, AttributeLocation>>;
|
||||
|
||||
using Vertex = detail::Vertex<typename As::Type...>;
|
||||
|
||||
static Locations bindLocations(Context& context, const ProgramID& id) {
|
||||
std::set<std::string> activeAttributes = getActiveAttributes(id);
|
||||
|
||||
@@ -262,12 +126,12 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
static Bindings bindings(const VertexBuffer<Vertex>& buffer) {
|
||||
return Bindings { As::Type::binding(buffer, TypeIndex<As, As...>::value)... };
|
||||
static Bindings bindings(const VertexBuffer<gfx::Vertex<Types>>& buffer) {
|
||||
return Bindings { attributeBinding<typename As::Type>(buffer, TypeIndex<As, As...>::value)... };
|
||||
}
|
||||
|
||||
static Bindings offsetBindings(const Bindings& bindings, std::size_t vertexOffset) {
|
||||
return Bindings { As::Type::offsetBinding(bindings.template get<As>(), vertexOffset)... };
|
||||
return Bindings { offsetAttributeBinding(bindings.template get<As>(), vertexOffset)... };
|
||||
}
|
||||
|
||||
static AttributeBindingArray toBindingArray(const Locations& locations, const Bindings& bindings) {
|
||||
@@ -293,8 +157,5 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template <class... As>
|
||||
using ConcatenateAttributes = typename TypeListConcat<typename As::Types...>::template ExpandInto<Attributes>;
|
||||
|
||||
} // namespace gl
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -51,8 +51,11 @@ public:
|
||||
|
||||
UniformLocation uniformLocation(ProgramID, const char * name);
|
||||
|
||||
template <class>
|
||||
class Uniforms;
|
||||
|
||||
template <class... Us>
|
||||
class Uniforms final {
|
||||
class Uniforms<TypeList<Us...>> final {
|
||||
public:
|
||||
using Types = TypeList<Us...>;
|
||||
using State = IndexedTuple<TypeList<Us...>, TypeList<UniformState<typename Us::Value>...>>;
|
||||
@@ -77,7 +80,7 @@ public:
|
||||
|
||||
template <class Program>
|
||||
static State loadNamedLocations(const Program& program) {
|
||||
return State(typename Us::State(program.uniformLocation(Us::name()))...);
|
||||
return State(UniformState<typename Us::Value>(program.uniformLocation(Us::name()))...);
|
||||
}
|
||||
|
||||
static NamedLocations getNamedLocations(const State& state) {
|
||||
@@ -89,8 +92,5 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template <class... Us>
|
||||
using ConcatenateUniforms = typename TypeListConcat<typename Us::Types...>::template ExpandInto<Uniforms>;
|
||||
|
||||
} // namespace gl
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace mbgl {
|
||||
}
|
||||
|
||||
void addDynamicAttributes(const Point<float>& anchorPoint, const float angle,
|
||||
gl::VertexVector<SymbolDynamicLayoutAttributes::Vertex>& dynamicVertexArray) {
|
||||
gl::VertexVector<gfx::Vertex<SymbolDynamicLayoutAttributes>>& dynamicVertexArray) {
|
||||
auto dynamicVertex = SymbolSDFIconProgram::dynamicLayoutVertex(anchorPoint, angle);
|
||||
dynamicVertexArray.emplace_back(dynamicVertex);
|
||||
dynamicVertexArray.emplace_back(dynamicVertex);
|
||||
@@ -130,7 +130,7 @@ namespace mbgl {
|
||||
dynamicVertexArray.emplace_back(dynamicVertex);
|
||||
}
|
||||
|
||||
void hideGlyphs(size_t numGlyphs, gl::VertexVector<SymbolDynamicLayoutAttributes::Vertex>& dynamicVertexArray) {
|
||||
void hideGlyphs(size_t numGlyphs, gl::VertexVector<gfx::Vertex<SymbolDynamicLayoutAttributes>>& dynamicVertexArray) {
|
||||
const Point<float> offscreenPoint = { -INFINITY, -INFINITY };
|
||||
for (size_t i = 0; i < numGlyphs; i++) {
|
||||
addDynamicAttributes(offscreenPoint, 0, dynamicVertexArray);
|
||||
@@ -288,7 +288,7 @@ namespace mbgl {
|
||||
const mat4& posMatrix,
|
||||
const mat4& labelPlaneMatrix,
|
||||
const mat4& glCoordMatrix,
|
||||
gl::VertexVector<SymbolDynamicLayoutAttributes::Vertex>& dynamicVertexArray,
|
||||
gl::VertexVector<gfx::Vertex<SymbolDynamicLayoutAttributes>>& dynamicVertexArray,
|
||||
const Point<float>& projectedAnchorPoint,
|
||||
const float aspectRatio) {
|
||||
const float fontScale = fontSize / 24.0;
|
||||
@@ -360,7 +360,7 @@ namespace mbgl {
|
||||
}
|
||||
|
||||
|
||||
void reprojectLineLabels(gl::VertexVector<SymbolDynamicLayoutAttributes::Vertex>& dynamicVertexArray, const std::vector<PlacedSymbol>& placedSymbols,
|
||||
void reprojectLineLabels(gl::VertexVector<gfx::Vertex<SymbolDynamicLayoutAttributes>>& dynamicVertexArray, const std::vector<PlacedSymbol>& placedSymbols,
|
||||
const mat4& posMatrix, const style::SymbolPropertyValues& values,
|
||||
const RenderTile& tile, const SymbolSizeBinder& sizeBinder, const TransformState& state) {
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace mbgl {
|
||||
using PointAndCameraDistance = std::pair<Point<float>,float>;
|
||||
PointAndCameraDistance project(const Point<float>& point, const mat4& matrix);
|
||||
|
||||
void reprojectLineLabels(gl::VertexVector<SymbolDynamicLayoutAttributes::Vertex>&, const std::vector<PlacedSymbol>&,
|
||||
void reprojectLineLabels(gl::VertexVector<gfx::Vertex<SymbolDynamicLayoutAttributes>>&, const std::vector<PlacedSymbol>&,
|
||||
const mat4& posMatrix, const style::SymbolPropertyValues&,
|
||||
const RenderTile&, const SymbolSizeBinder& sizeBinder, const TransformState&);
|
||||
|
||||
|
||||
@@ -1,23 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gl/attribute.hpp>
|
||||
#include <mbgl/gl/uniform.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <mbgl/gfx/attribute.hpp>
|
||||
|
||||
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);
|
||||
@@ -31,134 +18,40 @@ MBGL_DEFINE_ATTRIBUTE(uint16_t, 2, a_texture_pos);
|
||||
MBGL_DEFINE_ATTRIBUTE(int16_t, 4, a_normal_ed);
|
||||
MBGL_DEFINE_ATTRIBUTE(uint8_t, 1, a_fade_opacity);
|
||||
MBGL_DEFINE_ATTRIBUTE(uint8_t, 2, a_placed);
|
||||
MBGL_DEFINE_ATTRIBUTE(uint16_t, 3, a_size);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, a_offset);
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
struct a_data {
|
||||
using Type = gfx::AttributeType<T, N>;
|
||||
static auto name() { return "a_data"; }
|
||||
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>
|
||||
struct a_offset {
|
||||
static auto name() { return "a_offset"; }
|
||||
using Type = gl::Attribute<int16_t, N>;
|
||||
};
|
||||
|
||||
// Paint attributes
|
||||
|
||||
struct a_color {
|
||||
static auto name() { return "a_color"; }
|
||||
using Type = gl::Attribute<float, 2>;
|
||||
};
|
||||
|
||||
struct a_fill_color {
|
||||
static auto name() { return "a_fill_color"; }
|
||||
using Type = gl::Attribute<float, 2>;
|
||||
};
|
||||
|
||||
struct a_halo_color {
|
||||
static auto name() { return "a_halo_color"; }
|
||||
using Type = gl::Attribute<float, 2>;
|
||||
};
|
||||
|
||||
struct a_stroke_color {
|
||||
static auto name() { return "a_stroke_color"; }
|
||||
using Type = gl::Attribute<float, 2>;
|
||||
};
|
||||
|
||||
struct a_outline_color {
|
||||
static auto name() { return "a_outline_color"; }
|
||||
using Type = gl::Attribute<float, 2>;
|
||||
};
|
||||
|
||||
struct a_opacity {
|
||||
static auto name() { return "a_opacity"; }
|
||||
using Type = gl::Attribute<float, 1>;
|
||||
};
|
||||
|
||||
struct a_stroke_opacity {
|
||||
static auto name() { return "a_stroke_opacity"; }
|
||||
using Type = gl::Attribute<float, 1>;
|
||||
};
|
||||
|
||||
struct a_blur {
|
||||
static auto name() { return "a_blur"; }
|
||||
using Type = gl::Attribute<float, 1>;
|
||||
};
|
||||
|
||||
struct a_radius {
|
||||
static auto name() { return "a_radius"; }
|
||||
using Type = gl::Attribute<float, 1>;
|
||||
};
|
||||
|
||||
struct a_width {
|
||||
static auto name() { return "a_width"; }
|
||||
using Type = gl::Attribute<float, 1>;
|
||||
};
|
||||
|
||||
struct a_floorwidth {
|
||||
static auto name() { return "a_floorwidth"; }
|
||||
using Type = gl::Attribute<float, 1>;
|
||||
};
|
||||
|
||||
struct a_height {
|
||||
static auto name() { return "a_height"; }
|
||||
using Type = gl::Attribute<float, 1>;
|
||||
};
|
||||
|
||||
struct a_base {
|
||||
static auto name() { return "a_base"; }
|
||||
using Type = gl::Attribute<float, 1>;
|
||||
};
|
||||
|
||||
struct a_gapwidth {
|
||||
static auto name() { return "a_gapwidth"; }
|
||||
using Type = gl::Attribute<float, 1>;
|
||||
};
|
||||
|
||||
struct a_stroke_width {
|
||||
static auto name() { return "a_stroke_width"; }
|
||||
using Type = gl::Attribute<float, 1>;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct a_offset<1> {
|
||||
static auto name() { return "a_offset"; }
|
||||
using Type = gl::Attribute<float, 1>;
|
||||
};
|
||||
|
||||
struct a_halo_width {
|
||||
static auto name() { return "a_halo_width"; }
|
||||
using Type = gl::Attribute<float, 1>;
|
||||
};
|
||||
|
||||
struct a_halo_blur {
|
||||
static auto name() { return "a_halo_blur"; }
|
||||
using Type = gl::Attribute<float, 1>;
|
||||
};
|
||||
|
||||
struct a_weight {
|
||||
static auto name() { return "a_weight"; }
|
||||
using Type = gl::Attribute<float, 1>;
|
||||
};
|
||||
|
||||
struct a_pattern_to {
|
||||
static auto name() { return "a_pattern_to"; }
|
||||
using Type = gl::Attribute<uint16_t, 4>;
|
||||
};
|
||||
|
||||
struct a_pattern_from {
|
||||
static auto name() { return "a_pattern_from"; }
|
||||
using Type = gl::Attribute<uint16_t, 4>;
|
||||
};
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 2, a_color);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 2, a_fill_color);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 2, a_halo_color);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 2, a_stroke_color);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 2, a_outline_color);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, a_opacity);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, a_stroke_opacity);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, a_blur);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, a_radius);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, a_width);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, a_floorwidth);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, a_height);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, a_base);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, a_gapwidth);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, a_stroke_width);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, a_halo_width);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, a_halo_blur);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, a_weight);
|
||||
MBGL_DEFINE_ATTRIBUTE(uint16_t, 4, a_pattern_to);
|
||||
MBGL_DEFINE_ATTRIBUTE(uint16_t, 4, a_pattern_from);
|
||||
|
||||
} // namespace attributes
|
||||
|
||||
using PositionOnlyLayoutAttributes = gl::Attributes<attributes::a_pos>;
|
||||
using PositionOnlyLayoutAttributes = TypeList<attributes::a_pos>;
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -16,7 +16,7 @@ MBGL_DEFINE_UNIFORM_SCALAR(bool, u_scale_with_map);
|
||||
class CircleProgram : public Program<
|
||||
shaders::circle,
|
||||
gl::Triangle,
|
||||
gl::Attributes<
|
||||
TypeList<
|
||||
attributes::a_pos>,
|
||||
TypeList<
|
||||
uniforms::u_matrix,
|
||||
|
||||
@@ -12,17 +12,17 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
using CollisionBoxLayoutAttributes = gl::Attributes<
|
||||
using CollisionBoxLayoutAttributes = TypeList<
|
||||
attributes::a_pos,
|
||||
attributes::a_anchor_pos,
|
||||
attributes::a_extrude>;
|
||||
|
||||
using CollisionBoxDynamicAttributes = gl::Attributes<attributes::a_placed>;
|
||||
using CollisionBoxDynamicAttributes = TypeList<attributes::a_placed>;
|
||||
|
||||
class CollisionBoxProgram : public Program<
|
||||
shaders::collision_box,
|
||||
gl::Line,
|
||||
gl::ConcatenateAttributes<CollisionBoxLayoutAttributes, CollisionBoxDynamicAttributes>,
|
||||
TypeListConcat<CollisionBoxLayoutAttributes, CollisionBoxDynamicAttributes>,
|
||||
TypeList<
|
||||
uniforms::u_matrix,
|
||||
uniforms::u_extrude_scale,
|
||||
@@ -32,7 +32,7 @@ class CollisionBoxProgram : public Program<
|
||||
public:
|
||||
using Program::Program;
|
||||
|
||||
static CollisionBoxLayoutAttributes::Vertex layoutVertex(Point<float> a, Point<float> anchor, Point<float> o) {
|
||||
static gfx::Vertex<CollisionBoxLayoutAttributes> layoutVertex(Point<float> a, Point<float> anchor, Point<float> o) {
|
||||
return {
|
||||
{{
|
||||
static_cast<int16_t>(a.x),
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static CollisionBoxDynamicAttributes::Vertex dynamicVertex(bool placed, bool notUsed) {
|
||||
static gfx::Vertex<CollisionBoxDynamicAttributes> dynamicVertex(bool placed, bool notUsed) {
|
||||
return {
|
||||
{{ static_cast<uint8_t>(placed), static_cast<uint8_t>(notUsed) }}
|
||||
};
|
||||
@@ -63,19 +63,19 @@ public:
|
||||
gl::ColorMode colorMode,
|
||||
gl::CullFaceMode cullFaceMode,
|
||||
const UniformValues& uniformValues,
|
||||
const gl::VertexBuffer<CollisionBoxLayoutAttributes::Vertex>& layoutVertexBuffer,
|
||||
const gl::VertexBuffer<CollisionBoxDynamicAttributes::Vertex>& dynamicVertexBuffer,
|
||||
const gl::VertexBuffer<gfx::Vertex<CollisionBoxLayoutAttributes>>& layoutVertexBuffer,
|
||||
const gl::VertexBuffer<gfx::Vertex<CollisionBoxDynamicAttributes>>& dynamicVertexBuffer,
|
||||
const gl::IndexBuffer<DrawMode>& indexBuffer,
|
||||
const SegmentVector<Attributes>& segments,
|
||||
const PaintPropertyBinders& paintPropertyBinders,
|
||||
const Binders& paintPropertyBinders,
|
||||
const typename PaintProperties::PossiblyEvaluated& currentProperties,
|
||||
float currentZoom,
|
||||
const std::string& layerID) {
|
||||
typename AllUniforms::Values allUniformValues = uniformValues
|
||||
.concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties));
|
||||
|
||||
typename Attributes::Bindings allAttributeBindings = CollisionBoxLayoutAttributes::bindings(layoutVertexBuffer)
|
||||
.concat(CollisionBoxDynamicAttributes::bindings(dynamicVertexBuffer))
|
||||
typename Attributes::Bindings allAttributeBindings = gl::Attributes<CollisionBoxLayoutAttributes>::bindings(layoutVertexBuffer)
|
||||
.concat(gl::Attributes<CollisionBoxDynamicAttributes>::bindings(dynamicVertexBuffer))
|
||||
.concat(paintPropertyBinders.attributeBindings(currentProperties));
|
||||
|
||||
assert(layoutVertexBuffer.vertexCount == dynamicVertexBuffer.vertexCount);
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
class CollisionCircleProgram : public Program<
|
||||
shaders::collision_circle,
|
||||
gl::Triangle,
|
||||
gl::ConcatenateAttributes<CollisionBoxLayoutAttributes, CollisionBoxDynamicAttributes>,
|
||||
TypeListConcat<CollisionBoxLayoutAttributes, CollisionBoxDynamicAttributes>,
|
||||
TypeList<
|
||||
uniforms::u_matrix,
|
||||
uniforms::u_extrude_scale,
|
||||
@@ -119,7 +119,7 @@ class CollisionCircleProgram : public Program<
|
||||
public:
|
||||
using Program::Program;
|
||||
|
||||
static CollisionBoxLayoutAttributes::Vertex vertex(Point<float> a, Point<float> anchor, Point<float> o) {
|
||||
static gfx::Vertex<CollisionBoxLayoutAttributes> vertex(Point<float> a, Point<float> anchor, Point<float> o) {
|
||||
return {
|
||||
{{
|
||||
static_cast<int16_t>(a.x),
|
||||
@@ -144,19 +144,19 @@ public:
|
||||
gl::ColorMode colorMode,
|
||||
gl::CullFaceMode cullFaceMode,
|
||||
const UniformValues& uniformValues,
|
||||
const gl::VertexBuffer<CollisionBoxLayoutAttributes::Vertex>& layoutVertexBuffer,
|
||||
const gl::VertexBuffer<CollisionBoxDynamicAttributes::Vertex>& dynamicVertexBuffer,
|
||||
const gl::VertexBuffer<gfx::Vertex<CollisionBoxLayoutAttributes>>& layoutVertexBuffer,
|
||||
const gl::VertexBuffer<gfx::Vertex<CollisionBoxDynamicAttributes>>& dynamicVertexBuffer,
|
||||
const gl::IndexBuffer<DrawMode>& indexBuffer,
|
||||
const SegmentVector<Attributes>& segments,
|
||||
const PaintPropertyBinders& paintPropertyBinders,
|
||||
const Binders& paintPropertyBinders,
|
||||
const typename PaintProperties::PossiblyEvaluated& currentProperties,
|
||||
float currentZoom,
|
||||
const std::string& layerID) {
|
||||
typename AllUniforms::Values allUniformValues = uniformValues
|
||||
.concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties));
|
||||
|
||||
typename Attributes::Bindings allAttributeBindings = CollisionBoxLayoutAttributes::bindings(layoutVertexBuffer)
|
||||
.concat(CollisionBoxDynamicAttributes::bindings(dynamicVertexBuffer))
|
||||
typename Attributes::Bindings allAttributeBindings = gl::Attributes<CollisionBoxLayoutAttributes>::bindings(layoutVertexBuffer)
|
||||
.concat(gl::Attributes<CollisionBoxDynamicAttributes>::bindings(dynamicVertexBuffer))
|
||||
.concat(paintPropertyBinders.attributeBindings(currentProperties));
|
||||
|
||||
for (auto& segment : segments) {
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace mbgl {
|
||||
class DebugProgram : public Program<
|
||||
shaders::debug,
|
||||
gl::Line,
|
||||
gl::Attributes<
|
||||
TypeList<
|
||||
attributes::a_pos>,
|
||||
TypeList<
|
||||
uniforms::u_matrix,
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace mbgl {
|
||||
class ExtrusionTextureProgram : public Program<
|
||||
shaders::extrusion_texture,
|
||||
gl::Triangle,
|
||||
gl::Attributes<attributes::a_pos>,
|
||||
TypeList<attributes::a_pos>,
|
||||
TypeList<
|
||||
uniforms::u_matrix,
|
||||
uniforms::u_world,
|
||||
|
||||
@@ -29,7 +29,7 @@ MBGL_DEFINE_UNIFORM_SCALAR(float, u_lightintensity);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, u_height_factor);
|
||||
} // namespace uniforms
|
||||
|
||||
using FillExtrusionLayoutAttributes = gl::Attributes<
|
||||
using FillExtrusionLayoutAttributes = TypeList<
|
||||
attributes::a_pos,
|
||||
attributes::a_normal_ed>;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ MBGL_DEFINE_UNIFORM_SCALAR(float, u_intensity);
|
||||
class HeatmapProgram : public Program<
|
||||
shaders::heatmap,
|
||||
gl::Triangle,
|
||||
gl::Attributes<
|
||||
TypeList<
|
||||
attributes::a_pos>,
|
||||
TypeList<
|
||||
uniforms::u_intensity,
|
||||
|
||||
@@ -16,7 +16,7 @@ MBGL_DEFINE_UNIFORM_SCALAR(uint32_t, u_color_ramp);
|
||||
class HeatmapTextureProgram : public Program<
|
||||
shaders::heatmap_texture,
|
||||
gl::Triangle,
|
||||
gl::Attributes<attributes::a_pos>,
|
||||
TypeList<attributes::a_pos>,
|
||||
TypeList<
|
||||
uniforms::u_matrix,
|
||||
uniforms::u_world,
|
||||
|
||||
@@ -16,7 +16,7 @@ MBGL_DEFINE_UNIFORM_SCALAR(float, u_maxzoom);
|
||||
class HillshadePrepareProgram : public Program<
|
||||
shaders::hillshade_prepare,
|
||||
gl::Triangle,
|
||||
gl::Attributes<
|
||||
TypeList<
|
||||
attributes::a_pos,
|
||||
attributes::a_texture_pos>,
|
||||
TypeList<
|
||||
|
||||
@@ -21,7 +21,7 @@ MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_latrange);
|
||||
class HillshadeProgram : public Program<
|
||||
shaders::hillshade,
|
||||
gl::Triangle,
|
||||
gl::Attributes<
|
||||
TypeList<
|
||||
attributes::a_pos,
|
||||
attributes::a_texture_pos>,
|
||||
TypeList<
|
||||
|
||||
@@ -29,7 +29,7 @@ MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_patternscale_b);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_gl_units_to_pixels);
|
||||
} // namespace uniforms
|
||||
|
||||
using LineLayoutAttributes = gl::Attributes<
|
||||
using LineLayoutAttributes = TypeList<
|
||||
attributes::a_pos_normal,
|
||||
attributes::a_data<uint8_t, 4>>;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/program_parameters.hpp>
|
||||
#include <mbgl/style/paint_property.hpp>
|
||||
#include <mbgl/renderer/paint_property_binder.hpp>
|
||||
#include <mbgl/shaders/shaders.hpp>
|
||||
#include <mbgl/util/io.hpp>
|
||||
|
||||
@@ -16,22 +17,22 @@ namespace mbgl {
|
||||
|
||||
template <class Shaders,
|
||||
class Primitive,
|
||||
class LayoutAttrs,
|
||||
class UniformTypeList,
|
||||
class LayoutAttributeList,
|
||||
class UniformList,
|
||||
class PaintProps>
|
||||
class Program {
|
||||
public:
|
||||
using LayoutAttributes = LayoutAttrs;
|
||||
using LayoutVertex = typename LayoutAttributes::Vertex;
|
||||
using LayoutAttributes = gl::Attributes<LayoutAttributeList>;
|
||||
using LayoutVertex = gfx::Vertex<LayoutAttributeList>;
|
||||
|
||||
using PaintProperties = PaintProps;
|
||||
using PaintPropertyBinders = typename PaintProperties::Binders;
|
||||
using PaintAttributes = typename PaintPropertyBinders::Attributes;
|
||||
using Attributes = gl::ConcatenateAttributes<LayoutAttributes, PaintAttributes>;
|
||||
using Binders = PaintPropertyBinders<typename PaintProperties::DataDrivenProperties>;
|
||||
using PaintAttributeList = typename Binders::AttributeList;
|
||||
using Attributes = gl::Attributes<TypeListConcat<LayoutAttributeList, PaintAttributeList>>;
|
||||
|
||||
using UniformValues = gfx::UniformValues<UniformTypeList>;
|
||||
using PaintUniformTypeList = typename PaintPropertyBinders::UniformTypeList;
|
||||
using AllUniforms = typename TypeListConcat<UniformTypeList, PaintUniformTypeList>::template ExpandInto<gl::Uniforms>;
|
||||
using UniformValues = gfx::UniformValues<UniformList>;
|
||||
using PaintUniformList = typename Binders::UniformList;
|
||||
using AllUniforms = gl::Uniforms<TypeListConcat<UniformList, PaintUniformList>>;
|
||||
|
||||
using ProgramType = gl::Program<Primitive, Attributes, AllUniforms>;
|
||||
|
||||
@@ -48,7 +49,7 @@ public:
|
||||
|
||||
static typename AllUniforms::Values computeAllUniformValues(
|
||||
const UniformValues& uniformValues,
|
||||
const PaintPropertyBinders& paintPropertyBinders,
|
||||
const Binders& paintPropertyBinders,
|
||||
const typename PaintProperties::PossiblyEvaluated& currentProperties,
|
||||
float currentZoom) {
|
||||
return uniformValues
|
||||
@@ -57,7 +58,7 @@ public:
|
||||
|
||||
static typename Attributes::Bindings computeAllAttributeBindings(
|
||||
const gl::VertexBuffer<LayoutVertex>& layoutVertexBuffer,
|
||||
const PaintPropertyBinders& paintPropertyBinders,
|
||||
const Binders& paintPropertyBinders,
|
||||
const typename PaintProperties::PossiblyEvaluated& currentProperties) {
|
||||
return LayoutAttributes::bindings(layoutVertexBuffer)
|
||||
.concat(paintPropertyBinders.attributeBindings(currentProperties));
|
||||
@@ -107,8 +108,8 @@ template <class Program>
|
||||
class ProgramMap {
|
||||
public:
|
||||
using PaintProperties = typename Program::PaintProperties;
|
||||
using PaintPropertyBinders = typename Program::PaintPropertyBinders;
|
||||
using Bitset = typename PaintPropertyBinders::Bitset;
|
||||
using Binders = typename Program::Binders;
|
||||
using Bitset = typename Binders::Bitset;
|
||||
|
||||
ProgramMap(gl::Context& context_, ProgramParameters parameters_)
|
||||
: context(context_),
|
||||
@@ -116,7 +117,7 @@ public:
|
||||
}
|
||||
|
||||
Program& get(const typename PaintProperties::PossiblyEvaluated& currentProperties) {
|
||||
Bitset bits = PaintPropertyBinders::constants(currentProperties);
|
||||
Bitset bits = Binders::constants(currentProperties);
|
||||
auto it = programs.find(bits);
|
||||
if (it != programs.end()) {
|
||||
return it->second;
|
||||
@@ -124,7 +125,7 @@ public:
|
||||
return programs.emplace(std::piecewise_construct,
|
||||
std::forward_as_tuple(bits),
|
||||
std::forward_as_tuple(context,
|
||||
parameters.withAdditionalDefines(PaintPropertyBinders::defines(currentProperties)))).first->second;
|
||||
parameters.withAdditionalDefines(Binders::defines(currentProperties)))).first->second;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -26,7 +26,7 @@ MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_tl_parent);
|
||||
class RasterProgram : public Program<
|
||||
shaders::raster,
|
||||
gl::Triangle,
|
||||
gl::Attributes<
|
||||
TypeList<
|
||||
attributes::a_pos,
|
||||
attributes::a_texture_pos>,
|
||||
TypeList<
|
||||
|
||||
@@ -46,13 +46,13 @@ MBGL_DEFINE_UNIFORM_SCALAR(bool, u_rotate_symbol);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, u_aspect_ratio);
|
||||
} // namespace uniforms
|
||||
|
||||
using SymbolLayoutAttributes = gl::Attributes<
|
||||
using SymbolLayoutAttributes = TypeList<
|
||||
attributes::a_pos_offset,
|
||||
attributes::a_data<uint16_t, 4>>;
|
||||
|
||||
using SymbolDynamicLayoutAttributes = gl::Attributes<attributes::a_projected_pos>;
|
||||
using SymbolDynamicLayoutAttributes = TypeList<attributes::a_projected_pos>;
|
||||
|
||||
using SymbolOpacityAttributes = gl::Attributes<attributes::a_fade_opacity>;
|
||||
using SymbolOpacityAttributes = TypeList<attributes::a_fade_opacity>;
|
||||
|
||||
struct ZoomEvaluatedSize {
|
||||
bool isZoomConstant;
|
||||
@@ -69,12 +69,12 @@ class SymbolSizeBinder {
|
||||
public:
|
||||
virtual ~SymbolSizeBinder() = default;
|
||||
|
||||
using UniformTypeList = TypeList<
|
||||
using UniformList = TypeList<
|
||||
uniforms::u_is_size_zoom_constant,
|
||||
uniforms::u_is_size_feature_constant,
|
||||
uniforms::u_size_t,
|
||||
uniforms::u_size>;
|
||||
using UniformValues = gfx::UniformValues<UniformTypeList>;
|
||||
using UniformValues = gfx::UniformValues<UniformList>;
|
||||
|
||||
static std::unique_ptr<SymbolSizeBinder> create(const float tileZoom,
|
||||
const style::PropertyValue<float>& sizeProperty,
|
||||
@@ -146,10 +146,6 @@ public:
|
||||
|
||||
class SourceFunctionSymbolSizeBinder final : public SymbolSizeBinder {
|
||||
public:
|
||||
using Vertex = gl::detail::Vertex<gl::Attribute<uint16_t, 1>>;
|
||||
using VertexVector = gl::VertexVector<Vertex>;
|
||||
using VertexBuffer = gl::VertexBuffer<Vertex>;
|
||||
|
||||
SourceFunctionSymbolSizeBinder(const float /*tileZoom*/, style::PropertyExpression<float> expression_, const float defaultValue_)
|
||||
: expression(std::move(expression_)),
|
||||
defaultValue(defaultValue_) {
|
||||
@@ -204,7 +200,7 @@ public:
|
||||
|
||||
class SymbolProgramBase {
|
||||
public:
|
||||
static SymbolLayoutAttributes::Vertex layoutVertex(Point<float> labelAnchor,
|
||||
static gfx::Vertex<SymbolLayoutAttributes> layoutVertex(Point<float> labelAnchor,
|
||||
Point<float> o,
|
||||
float glyphOffsetY,
|
||||
uint16_t tx,
|
||||
@@ -227,7 +223,7 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static SymbolDynamicLayoutAttributes::Vertex dynamicLayoutVertex(Point<float> anchorPoint, float labelAngle) {
|
||||
static gfx::Vertex<SymbolDynamicLayoutAttributes> dynamicLayoutVertex(Point<float> anchorPoint, float labelAngle) {
|
||||
return {
|
||||
{{
|
||||
anchorPoint.x,
|
||||
@@ -237,7 +233,7 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static SymbolOpacityAttributes::Vertex opacityVertex(bool placed, float opacity) {
|
||||
static gfx::Vertex<SymbolOpacityAttributes> opacityVertex(bool placed, float opacity) {
|
||||
return {
|
||||
{{ static_cast<uint8_t>((static_cast<uint8_t>(opacity * 127) << 1) | static_cast<uint8_t>(placed)) }}
|
||||
};
|
||||
@@ -246,25 +242,25 @@ public:
|
||||
|
||||
template <class Shaders,
|
||||
class Primitive,
|
||||
class LayoutAttrs,
|
||||
class UniformTypeList,
|
||||
class LayoutAttributeList,
|
||||
class UniformList,
|
||||
class PaintProps>
|
||||
class SymbolProgram : public SymbolProgramBase {
|
||||
public:
|
||||
using LayoutAttributes = LayoutAttrs;
|
||||
using LayoutVertex = typename LayoutAttributes::Vertex;
|
||||
using LayoutAttributes = gl::Attributes<LayoutAttributeList>;
|
||||
using LayoutVertex = gfx::Vertex<LayoutAttributeList>;
|
||||
|
||||
using LayoutAndSizeAttributes = gl::ConcatenateAttributes<LayoutAttributes, SymbolDynamicLayoutAttributes, SymbolOpacityAttributes>;
|
||||
using LayoutAndSizeAttributeList = TypeListConcat<LayoutAttributeList, SymbolDynamicLayoutAttributes, SymbolOpacityAttributes>;
|
||||
|
||||
using PaintProperties = PaintProps;
|
||||
using PaintPropertyBinders = typename PaintProperties::Binders;
|
||||
using PaintAttributes = typename PaintPropertyBinders::Attributes;
|
||||
using Attributes = gl::ConcatenateAttributes<LayoutAndSizeAttributes, PaintAttributes>;
|
||||
using Binders = PaintPropertyBinders<typename PaintProperties::DataDrivenProperties>;
|
||||
using PaintAttributeList = typename Binders::AttributeList;
|
||||
using Attributes = gl::Attributes<TypeListConcat<LayoutAndSizeAttributeList, PaintAttributeList>>;
|
||||
|
||||
using UniformValues = gfx::UniformValues<UniformTypeList>;
|
||||
using SizeUniformTypeList = typename SymbolSizeBinder::UniformTypeList;
|
||||
using PaintUniformTypeList = typename PaintPropertyBinders::UniformTypeList;
|
||||
using AllUniforms = typename TypeListConcat<UniformTypeList, SizeUniformTypeList, PaintUniformTypeList>::template ExpandInto<gl::Uniforms>;
|
||||
using UniformValues = gfx::UniformValues<UniformList>;
|
||||
using SizeUniformList = typename SymbolSizeBinder::UniformList;
|
||||
using PaintUniformList = typename Binders::UniformList;
|
||||
using AllUniforms = gl::Uniforms<TypeListConcat<UniformList, SizeUniformList, PaintUniformList>>;
|
||||
|
||||
using ProgramType = gl::Program<Primitive, Attributes, AllUniforms>;
|
||||
|
||||
@@ -282,7 +278,7 @@ public:
|
||||
static typename AllUniforms::Values computeAllUniformValues(
|
||||
const UniformValues& uniformValues,
|
||||
const SymbolSizeBinder& symbolSizeBinder,
|
||||
const PaintPropertyBinders& paintPropertyBinders,
|
||||
const Binders& paintPropertyBinders,
|
||||
const typename PaintProperties::PossiblyEvaluated& currentProperties,
|
||||
float currentZoom) {
|
||||
return uniformValues.concat(symbolSizeBinder.uniformValues(currentZoom))
|
||||
@@ -291,15 +287,15 @@ public:
|
||||
|
||||
static typename Attributes::Bindings computeAllAttributeBindings(
|
||||
const gl::VertexBuffer<LayoutVertex>& layoutVertexBuffer,
|
||||
const gl::VertexBuffer<SymbolDynamicLayoutAttributes::Vertex>& dynamicLayoutVertexBuffer,
|
||||
const gl::VertexBuffer<SymbolOpacityAttributes::Vertex>& opacityVertexBuffer,
|
||||
const PaintPropertyBinders& paintPropertyBinders,
|
||||
const gl::VertexBuffer<gfx::Vertex<SymbolDynamicLayoutAttributes>>& dynamicLayoutVertexBuffer,
|
||||
const gl::VertexBuffer<gfx::Vertex<SymbolOpacityAttributes>>& opacityVertexBuffer,
|
||||
const Binders& paintPropertyBinders,
|
||||
const typename PaintProperties::PossiblyEvaluated& currentProperties) {
|
||||
assert(layoutVertexBuffer.vertexCount == dynamicLayoutVertexBuffer.vertexCount &&
|
||||
layoutVertexBuffer.vertexCount == opacityVertexBuffer.vertexCount);
|
||||
return LayoutAttributes::bindings(layoutVertexBuffer)
|
||||
.concat(SymbolDynamicLayoutAttributes::bindings(dynamicLayoutVertexBuffer))
|
||||
.concat(SymbolOpacityAttributes::bindings(opacityVertexBuffer))
|
||||
return gl::Attributes<LayoutAttributeList>::bindings(layoutVertexBuffer)
|
||||
.concat(gl::Attributes<SymbolDynamicLayoutAttributes>::bindings(dynamicLayoutVertexBuffer))
|
||||
.concat(gl::Attributes<SymbolOpacityAttributes>::bindings(opacityVertexBuffer))
|
||||
.concat(paintPropertyBinders.attributeBindings(currentProperties));
|
||||
}
|
||||
|
||||
@@ -446,7 +442,7 @@ public:
|
||||
using SymbolSDFIconProgram = SymbolSDFProgram<style::IconPaintProperties>;
|
||||
using SymbolSDFTextProgram = SymbolSDFProgram<style::TextPaintProperties>;
|
||||
|
||||
using SymbolLayoutVertex = SymbolLayoutAttributes::Vertex;
|
||||
using SymbolLayoutVertex = gfx::Vertex<SymbolLayoutAttributes>;
|
||||
using SymbolIconAttributes = SymbolIconProgram::Attributes;
|
||||
using SymbolTextAttributes = SymbolSDFTextProgram::Attributes;
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ void CircleBucket::addFeature(const GeometryTileFeature& feature,
|
||||
}
|
||||
|
||||
template <class Property>
|
||||
static float get(const RenderCircleLayer& layer, const std::map<std::string, CircleProgram::PaintPropertyBinders>& paintPropertyBinders) {
|
||||
static float get(const RenderCircleLayer& layer, const std::map<std::string, CircleProgram::Binders>& paintPropertyBinders) {
|
||||
auto it = paintPropertyBinders.find(layer.getID());
|
||||
if (it == paintPropertyBinders.end() || !it->second.statistics<Property>().max()) {
|
||||
return layer.evaluated.get<Property>().constantOr(Property::defaultValue());
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
optional<gl::VertexBuffer<CircleLayoutVertex>> vertexBuffer;
|
||||
optional<gl::IndexBuffer<gl::Triangles>> indexBuffer;
|
||||
|
||||
std::map<std::string, CircleProgram::PaintPropertyBinders> paintPropertyBinders;
|
||||
std::map<std::string, CircleProgram::Binders> paintPropertyBinders;
|
||||
|
||||
const MapMode mode;
|
||||
};
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
optional<gl::IndexBuffer<gl::Lines>> lineIndexBuffer;
|
||||
optional<gl::IndexBuffer<gl::Triangles>> triangleIndexBuffer;
|
||||
|
||||
std::map<std::string, FillProgram::PaintPropertyBinders> paintPropertyBinders;
|
||||
std::map<std::string, FillProgram::Binders> paintPropertyBinders;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
optional<gl::VertexBuffer<FillExtrusionLayoutVertex>> vertexBuffer;
|
||||
optional<gl::IndexBuffer<gl::Triangles>> indexBuffer;
|
||||
|
||||
std::unordered_map<std::string, FillExtrusionProgram::PaintPropertyBinders> paintPropertyBinders;
|
||||
std::unordered_map<std::string, FillExtrusionProgram::Binders> paintPropertyBinders;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
optional<gl::VertexBuffer<HeatmapLayoutVertex>> vertexBuffer;
|
||||
optional<gl::IndexBuffer<gl::Triangles>> indexBuffer;
|
||||
|
||||
std::map<std::string, HeatmapProgram::PaintPropertyBinders> paintPropertyBinders;
|
||||
std::map<std::string, HeatmapProgram::Binders> paintPropertyBinders;
|
||||
|
||||
const MapMode mode;
|
||||
};
|
||||
|
||||
@@ -528,7 +528,7 @@ bool LineBucket::supportsLayer(const style::Layer::Impl& impl) const {
|
||||
}
|
||||
|
||||
template <class Property>
|
||||
static float get(const RenderLineLayer& layer, const std::map<std::string, LineProgram::PaintPropertyBinders>& paintPropertyBinders) {
|
||||
static float get(const RenderLineLayer& layer, const std::map<std::string, LineProgram::Binders>& paintPropertyBinders) {
|
||||
auto it = paintPropertyBinders.find(layer.getID());
|
||||
if (it == paintPropertyBinders.end() || !it->second.statistics<Property>().max()) {
|
||||
return layer.evaluated.get<Property>().constantOr(Property::defaultValue());
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
optional<gl::VertexBuffer<LineLayoutVertex>> vertexBuffer;
|
||||
optional<gl::IndexBuffer<gl::Triangles>> indexBuffer;
|
||||
|
||||
std::map<std::string, LineProgram::PaintPropertyBinders> paintPropertyBinders;
|
||||
std::map<std::string, LineProgram::Binders> paintPropertyBinders;
|
||||
|
||||
private:
|
||||
void addGeometry(const GeometryCoordinates&, const GeometryTileFeature&);
|
||||
|
||||
@@ -80,8 +80,8 @@ public:
|
||||
|
||||
struct PaintProperties {
|
||||
style::SymbolPaintProperties::PossiblyEvaluated evaluated;
|
||||
SymbolIconProgram::PaintPropertyBinders iconBinders;
|
||||
SymbolSDFTextProgram::PaintPropertyBinders textBinders;
|
||||
SymbolIconProgram::Binders iconBinders;
|
||||
SymbolSDFTextProgram::Binders textBinders;
|
||||
};
|
||||
std::map<std::string, PaintProperties> paintProperties;
|
||||
|
||||
@@ -89,15 +89,15 @@ public:
|
||||
|
||||
struct TextBuffer {
|
||||
gl::VertexVector<SymbolLayoutVertex> vertices;
|
||||
gl::VertexVector<SymbolDynamicLayoutAttributes::Vertex> dynamicVertices;
|
||||
gl::VertexVector<SymbolOpacityAttributes::Vertex> opacityVertices;
|
||||
gl::VertexVector<gfx::Vertex<SymbolDynamicLayoutAttributes>> dynamicVertices;
|
||||
gl::VertexVector<gfx::Vertex<SymbolOpacityAttributes>> opacityVertices;
|
||||
gl::IndexVector<gl::Triangles> triangles;
|
||||
SegmentVector<SymbolTextAttributes> segments;
|
||||
std::vector<PlacedSymbol> placedSymbols;
|
||||
|
||||
optional<gl::VertexBuffer<SymbolLayoutVertex>> vertexBuffer;
|
||||
optional<gl::VertexBuffer<SymbolDynamicLayoutAttributes::Vertex>> dynamicVertexBuffer;
|
||||
optional<gl::VertexBuffer<SymbolOpacityAttributes::Vertex>> opacityVertexBuffer;
|
||||
optional<gl::VertexBuffer<gfx::Vertex<SymbolDynamicLayoutAttributes>>> dynamicVertexBuffer;
|
||||
optional<gl::VertexBuffer<gfx::Vertex<SymbolOpacityAttributes>>> opacityVertexBuffer;
|
||||
optional<gl::IndexBuffer<gl::Triangles>> indexBuffer;
|
||||
} text;
|
||||
|
||||
@@ -105,26 +105,26 @@ public:
|
||||
|
||||
struct IconBuffer {
|
||||
gl::VertexVector<SymbolLayoutVertex> vertices;
|
||||
gl::VertexVector<SymbolDynamicLayoutAttributes::Vertex> dynamicVertices;
|
||||
gl::VertexVector<SymbolOpacityAttributes::Vertex> opacityVertices;
|
||||
gl::VertexVector<gfx::Vertex<SymbolDynamicLayoutAttributes>> dynamicVertices;
|
||||
gl::VertexVector<gfx::Vertex<SymbolOpacityAttributes>> opacityVertices;
|
||||
gl::IndexVector<gl::Triangles> triangles;
|
||||
SegmentVector<SymbolIconAttributes> segments;
|
||||
std::vector<PlacedSymbol> placedSymbols;
|
||||
PremultipliedImage atlasImage;
|
||||
|
||||
optional<gl::VertexBuffer<SymbolLayoutVertex>> vertexBuffer;
|
||||
optional<gl::VertexBuffer<SymbolDynamicLayoutAttributes::Vertex>> dynamicVertexBuffer;
|
||||
optional<gl::VertexBuffer<SymbolOpacityAttributes::Vertex>> opacityVertexBuffer;
|
||||
optional<gl::VertexBuffer<gfx::Vertex<SymbolDynamicLayoutAttributes>>> dynamicVertexBuffer;
|
||||
optional<gl::VertexBuffer<gfx::Vertex<SymbolOpacityAttributes>>> opacityVertexBuffer;
|
||||
optional<gl::IndexBuffer<gl::Triangles>> indexBuffer;
|
||||
} icon;
|
||||
|
||||
struct CollisionBuffer {
|
||||
gl::VertexVector<CollisionBoxLayoutAttributes::Vertex> vertices;
|
||||
gl::VertexVector<CollisionBoxDynamicAttributes::Vertex> dynamicVertices;
|
||||
gl::VertexVector<gfx::Vertex<CollisionBoxLayoutAttributes>> vertices;
|
||||
gl::VertexVector<gfx::Vertex<CollisionBoxDynamicAttributes>> dynamicVertices;
|
||||
SegmentVector<CollisionBoxProgram::Attributes> segments;
|
||||
|
||||
optional<gl::VertexBuffer<CollisionBoxLayoutAttributes::Vertex>> vertexBuffer;
|
||||
optional<gl::VertexBuffer<CollisionBoxDynamicAttributes::Vertex>> dynamicVertexBuffer;
|
||||
optional<gl::VertexBuffer<gfx::Vertex<CollisionBoxLayoutAttributes>>> vertexBuffer;
|
||||
optional<gl::VertexBuffer<gfx::Vertex<CollisionBoxDynamicAttributes>>> dynamicVertexBuffer;
|
||||
};
|
||||
|
||||
struct CollisionBoxBuffer : public CollisionBuffer {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <mbgl/programs/background_program.hpp>
|
||||
#include <mbgl/util/tile_cover.hpp>
|
||||
#include <mbgl/map/transform_state.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -47,7 +48,7 @@ void RenderBackgroundLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
// glClear rather than this method.
|
||||
|
||||
const Properties<>::PossiblyEvaluated properties;
|
||||
const BackgroundProgram::PaintPropertyBinders paintAttributeData(properties, 0);
|
||||
const BackgroundProgram::Binders paintAttributeData(properties, 0);
|
||||
|
||||
auto draw = [&](auto& program, auto&& uniformValues) {
|
||||
const auto allUniformValues = program.computeAllUniformValues(
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <mbgl/platform/gl_functions.hpp>
|
||||
#include <mbgl/style/layers/custom_layer_impl.hpp>
|
||||
#include <mbgl/map/transform_state.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/util/mat4.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <mbgl/util/math.hpp>
|
||||
#include <mbgl/util/intersection_tests.hpp>
|
||||
#include <mbgl/tile/geometry_tile.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -168,7 +169,7 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource*
|
||||
matrix::ortho(viewportMat, 0, size.width, size.height, 0, 0, 1);
|
||||
|
||||
const Properties<>::PossiblyEvaluated properties;
|
||||
const ExtrusionTextureProgram::PaintPropertyBinders paintAttributeData{ properties, 0 };
|
||||
const ExtrusionTextureProgram::Binders paintAttributeData{ properties, 0 };
|
||||
|
||||
auto& programInstance = parameters.programs.getFillExtrusionLayerPrograms().extrusionTexture;
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
matrix::ortho(viewportMat, 0, size.width, size.height, 0, 0, 1);
|
||||
|
||||
const Properties<>::PossiblyEvaluated properties;
|
||||
const HeatmapTextureProgram::PaintPropertyBinders paintAttributeData{ properties, 0 };
|
||||
const HeatmapTextureProgram::Binders paintAttributeData{ properties, 0 };
|
||||
|
||||
auto& programInstance = parameters.programs.getHeatmapLayerPrograms().heatmapTexture;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <mbgl/renderer/render_layer.hpp>
|
||||
#include <mbgl/style/layers/heatmap_layer_impl.hpp>
|
||||
#include <mbgl/style/layers/heatmap_layer_properties.hpp>
|
||||
#include <mbgl/gl/texture.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
#include <mbgl/util/offscreen_texture.hpp>
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource* src
|
||||
const UnwrappedTileID& id) {
|
||||
auto& programInstance = parameters.programs.getHillshadeLayerPrograms().hillshade;
|
||||
|
||||
const HillshadeProgram::PaintPropertyBinders paintAttributeData{ evaluated, 0 };
|
||||
const HillshadeProgram::Binders paintAttributeData{ evaluated, 0 };
|
||||
|
||||
const auto allUniformValues = programInstance.computeAllUniformValues(
|
||||
HillshadeProgram::UniformValues {
|
||||
@@ -131,7 +131,7 @@ void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource* src
|
||||
|
||||
parameters.context.bindTexture(*bucket.dem, 0, gl::TextureFilter::Nearest, gl::TextureMipMap::No, gl::TextureWrap::Clamp, gl::TextureWrap::Clamp);
|
||||
const Properties<>::PossiblyEvaluated properties;
|
||||
const HillshadePrepareProgram::PaintPropertyBinders paintAttributeData{ properties, 0 };
|
||||
const HillshadePrepareProgram::Binders paintAttributeData{ properties, 0 };
|
||||
|
||||
auto& programInstance = parameters.programs.getHillshadeLayerPrograms().hillshadePrepare;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/style/image_impl.hpp>
|
||||
#include <mbgl/layout/pattern_layout.hpp>
|
||||
#include <mbgl/gl/texture.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ void RenderRasterLayer::render(PaintParameters& parameters, RenderSource* source
|
||||
if (parameters.pass != RenderPass::Translucent)
|
||||
return;
|
||||
|
||||
RasterProgram::PaintPropertyBinders paintAttributeData{ evaluated, 0 };
|
||||
RasterProgram::Binders paintAttributeData{ evaluated, 0 };
|
||||
|
||||
auto draw = [&] (const mat4& matrix,
|
||||
const auto& vertexBuffer,
|
||||
|
||||
@@ -239,7 +239,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
|
||||
if (bucket.hasCollisionBoxData()) {
|
||||
static const style::Properties<>::PossiblyEvaluated properties {};
|
||||
static const CollisionBoxProgram::PaintPropertyBinders paintAttributeData(properties, 0);
|
||||
static const CollisionBoxProgram::Binders paintAttributeData(properties, 0);
|
||||
|
||||
auto pixelRatio = tile.id.pixelsToTileUnits(1, parameters.state.getZoom());
|
||||
const float scale = std::pow(2, parameters.state.getZoom() - tile.tile.id.overscaledZ);
|
||||
@@ -273,7 +273,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
}
|
||||
if (bucket.hasCollisionCircleData()) {
|
||||
static const style::Properties<>::PossiblyEvaluated properties {};
|
||||
static const CollisionBoxProgram::PaintPropertyBinders paintAttributeData(properties, 0);
|
||||
static const CollisionBoxProgram::Binders paintAttributeData(properties, 0);
|
||||
|
||||
auto pixelRatio = tile.id.pixelsToTileUnits(1, parameters.state.getZoom());
|
||||
const float scale = std::pow(2, parameters.state.getZoom() - tile.tile.id.overscaledZ);
|
||||
|
||||
@@ -23,6 +23,10 @@ class ImageManager;
|
||||
class LineAtlas;
|
||||
class UnwrappedTileID;
|
||||
|
||||
namespace gl {
|
||||
class Context;
|
||||
}
|
||||
|
||||
class PaintParameters {
|
||||
public:
|
||||
PaintParameters(gl::Context&,
|
||||
|
||||
@@ -24,13 +24,23 @@ namespace mbgl {
|
||||
between zoom levels, without the need to repopulate vertex buffers each frame as the map is
|
||||
being zoomed.
|
||||
*/
|
||||
template <class A>
|
||||
using ZoomInterpolatedAttributeType = gl::Attribute<typename A::ValueType, A::Dimensions * 2>;
|
||||
template <class AttributeType>
|
||||
using ZoomInterpolatedAttributeType = gfx::AttributeType<typename AttributeType::ValueType, AttributeType::Dimensions * 2>;
|
||||
|
||||
inline std::array<float, 1> attributeValue(float v) {
|
||||
return {{ v }};
|
||||
}
|
||||
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
/*
|
||||
Encode a four-component color value into a pair of floats. Since csscolorparser
|
||||
uses 8-bit precision for each color component, for each float we use the upper 8
|
||||
@@ -40,8 +50,8 @@ inline std::array<float, 1> attributeValue(float v) {
|
||||
*/
|
||||
inline std::array<float, 2> attributeValue(const Color& color) {
|
||||
return {{
|
||||
static_cast<float>(mbgl::attributes::packUint8Pair(255 * color.r, 255 * color.g)),
|
||||
static_cast<float>(mbgl::attributes::packUint8Pair(255 * color.b, 255 * color.a))
|
||||
static_cast<float>(packUint8Pair(255 * color.r, 255 * color.g)),
|
||||
static_cast<float>(packUint8Pair(255 * color.b, 255 * color.a))
|
||||
}};
|
||||
}
|
||||
|
||||
@@ -163,8 +173,9 @@ private:
|
||||
template <class T, class A>
|
||||
class SourceFunctionPaintPropertyBinder : public PaintPropertyBinder<T, T, PossiblyEvaluatedPropertyValue<T>, A> {
|
||||
public:
|
||||
using BaseAttribute = A;
|
||||
using BaseVertex = gl::detail::Vertex<BaseAttribute>;
|
||||
using BaseAttributeType = A;
|
||||
using BaseAttributeValue = typename A::Value;
|
||||
using BaseVertex = gfx::Vertex<BaseAttributeValue>;
|
||||
|
||||
using AttributeType = ZoomInterpolatedAttributeType<A>;
|
||||
|
||||
@@ -190,7 +201,7 @@ public:
|
||||
if (currentValue.isConstant()) {
|
||||
return {};
|
||||
} else {
|
||||
return std::tuple<optional<gl::AttributeBinding>> { AttributeType::binding(*vertexBuffer, 0, BaseAttribute::Dimensions) };
|
||||
return std::tuple<optional<gl::AttributeBinding>> { gl::attributeBinding<AttributeType>(*vertexBuffer, 0, BaseAttributeType::Dimensions) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +231,7 @@ public:
|
||||
|
||||
using AttributeType = ZoomInterpolatedAttributeType<A>;
|
||||
using AttributeValue = typename AttributeType::Value;
|
||||
using Vertex = gl::detail::Vertex<AttributeType>;
|
||||
using Vertex = gfx::Vertex<AttributeValue>;
|
||||
|
||||
CompositeFunctionPaintPropertyBinder(style::PropertyExpression<T> expression_, float zoom, T defaultValue_)
|
||||
: expression(std::move(expression_)),
|
||||
@@ -248,7 +259,7 @@ public:
|
||||
if (currentValue.isConstant()) {
|
||||
return {};
|
||||
} else {
|
||||
return std::tuple<optional<gl::AttributeBinding>> { AttributeType::binding(*vertexBuffer, 0) };
|
||||
return std::tuple<optional<gl::AttributeBinding>> { gl::attributeBinding<AttributeType>(*vertexBuffer, 0) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,14 +294,14 @@ public:
|
||||
using AttributeType = ZoomInterpolatedAttributeType<A1>;
|
||||
using AttributeType2 = ZoomInterpolatedAttributeType<A2>;
|
||||
|
||||
using BaseAttribute = A1;
|
||||
using BaseAttributeValue = typename BaseAttribute::Value;
|
||||
using BaseAttributeType = A1;
|
||||
using BaseAttributeValue = typename BaseAttributeType::Value;
|
||||
|
||||
using BaseAttribute2 = A2;
|
||||
using BaseAttributeValue2 = typename BaseAttribute2::Value;
|
||||
using BaseAttributeType2 = A2;
|
||||
using BaseAttributeValue2 = typename BaseAttributeType2::Value;
|
||||
|
||||
using Vertex = gl::detail::Vertex<BaseAttribute>;
|
||||
using Vertex2 = gl::detail::Vertex<BaseAttribute2>;
|
||||
using Vertex = gfx::Vertex<BaseAttributeValue>;
|
||||
using Vertex2 = gfx::Vertex<BaseAttributeValue2>;
|
||||
|
||||
CompositeCrossFadedPaintPropertyBinder(style::PropertyExpression<T> expression_, float zoom, T defaultValue_)
|
||||
: expression(std::move(expression_)),
|
||||
@@ -344,10 +355,10 @@ public:
|
||||
return {};
|
||||
} else {
|
||||
return std::tuple<optional<gl::AttributeBinding>, optional<gl::AttributeBinding>> {
|
||||
AttributeType::binding(*patternToVertexBuffer, 0, BaseAttribute::Dimensions),
|
||||
AttributeType2::binding(
|
||||
gl::attributeBinding<AttributeType>(*patternToVertexBuffer, 0, BaseAttributeType::Dimensions),
|
||||
gl::attributeBinding<AttributeType2>(
|
||||
crossfade.fromScale == 2 ? *zoomInVertexBuffer : *zoomOutVertexBuffer,
|
||||
0, BaseAttribute2::Dimensions) };
|
||||
0, BaseAttributeType2::Dimensions) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,7 +431,7 @@ struct ZoomInterpolatedAttribute {
|
||||
};
|
||||
|
||||
template <class Attr>
|
||||
struct InterpolationUniformType {
|
||||
struct InterpolationUniform {
|
||||
using Value = float;
|
||||
static auto name() {
|
||||
static const std::string name = Attr::name() + std::string("_t");
|
||||
@@ -441,11 +452,11 @@ private:
|
||||
struct Detail<T, UniformValueType, PossiblyEvaluatedType, TypeList<As...>> {
|
||||
using Binder = PaintPropertyBinder<T, UniformValueType, PossiblyEvaluatedType, typename As::Type...>;
|
||||
using ZoomInterpolatedAttributeList = TypeList<ZoomInterpolatedAttribute<As>...>;
|
||||
using InterpolationUniformTypeList = TypeList<InterpolationUniformType<As>...>;
|
||||
using InterpolationUniformList = TypeList<InterpolationUniform<As>...>;
|
||||
};
|
||||
|
||||
template <class P>
|
||||
using Property = Detail<typename P::Type, typename P::Uniform::Value, typename P::PossiblyEvaluatedType, typename P::Attributes>;
|
||||
using Property = Detail<typename P::Type, typename P::Uniform::Value, typename P::PossiblyEvaluatedType, typename P::AttributeList>;
|
||||
|
||||
public:
|
||||
template <class P>
|
||||
@@ -485,9 +496,10 @@ public:
|
||||
template <class P>
|
||||
using ZoomInterpolatedAttributeList = typename Property<P>::ZoomInterpolatedAttributeList;
|
||||
template <class P>
|
||||
using InterpolationUniformTypeList = typename Property<P>::InterpolationUniformTypeList;
|
||||
using InterpolationUniformList = typename Property<P>::InterpolationUniformList;
|
||||
|
||||
using Attributes = typename TypeListConcat<ZoomInterpolatedAttributeList<Ps>...>::template ExpandInto<gl::Attributes>;
|
||||
using AttributeList = TypeListConcat<ZoomInterpolatedAttributeList<Ps>...>;
|
||||
using Attributes = gl::Attributes<AttributeList>;
|
||||
using AttributeBindings = typename Attributes::Bindings;
|
||||
|
||||
template <class EvaluatedProperties>
|
||||
@@ -497,9 +509,9 @@ public:
|
||||
) };
|
||||
}
|
||||
|
||||
using UniformTypeList = TypeListConcat<InterpolationUniformTypeList<Ps>..., typename Ps::Uniforms...>;
|
||||
using UniformValues = gfx::UniformValues<UniformTypeList>;
|
||||
using Uniforms = typename UniformTypeList::template ExpandInto<gl::Uniforms>;
|
||||
using UniformList = TypeListConcat<InterpolationUniformList<Ps>..., typename Ps::UniformList...>;
|
||||
using UniformValues = gfx::UniformValues<UniformList>;
|
||||
using Uniforms = gl::Uniforms<UniformList>;
|
||||
|
||||
template <class EvaluatedProperties>
|
||||
UniformValues uniformValues(float currentZoom, EvaluatedProperties& currentProperties) const {
|
||||
@@ -547,7 +559,7 @@ public:
|
||||
std::vector<std::string> result;
|
||||
util::ignore({
|
||||
(currentProperties.template get<Ps>().isConstant()
|
||||
? UniformDefines<typename Ps::Uniforms>::appendDefines(result)
|
||||
? UniformDefines<typename Ps::UniformList>::appendDefines(result)
|
||||
: (void) 0, 0)...
|
||||
});
|
||||
return result;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <mbgl/renderer/render_tile.hpp>
|
||||
#include <mbgl/style/types.hpp>
|
||||
#include <mbgl/tile/tile.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
static gl::VertexVector<PositionOnlyLayoutAttributes::Vertex> tileVertices() {
|
||||
gl::VertexVector<PositionOnlyLayoutAttributes::Vertex> result;
|
||||
result.emplace_back(PositionOnlyLayoutAttributes::Vertex({{{ 0, 0 }}}));
|
||||
result.emplace_back(PositionOnlyLayoutAttributes::Vertex({{{ util::EXTENT, 0 }}}));
|
||||
result.emplace_back(PositionOnlyLayoutAttributes::Vertex({{{ 0, util::EXTENT }}}));
|
||||
result.emplace_back(PositionOnlyLayoutAttributes::Vertex({{{ util::EXTENT, util::EXTENT }}}));
|
||||
static gl::VertexVector<gfx::Vertex<PositionOnlyLayoutAttributes>> tileVertices() {
|
||||
gl::VertexVector<gfx::Vertex<PositionOnlyLayoutAttributes>> result;
|
||||
result.emplace_back(gfx::Vertex<PositionOnlyLayoutAttributes>({{{ 0, 0 }}}));
|
||||
result.emplace_back(gfx::Vertex<PositionOnlyLayoutAttributes>({{{ util::EXTENT, 0 }}}));
|
||||
result.emplace_back(gfx::Vertex<PositionOnlyLayoutAttributes>({{{ 0, util::EXTENT }}}));
|
||||
result.emplace_back(gfx::Vertex<PositionOnlyLayoutAttributes>({{{ util::EXTENT, util::EXTENT }}}));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class RenderStaticData {
|
||||
public:
|
||||
RenderStaticData(gl::Context&, float pixelRatio, const optional<std::string>& programCacheDir);
|
||||
|
||||
gl::VertexBuffer<PositionOnlyLayoutAttributes::Vertex> tileVertexBuffer;
|
||||
gl::VertexBuffer<gfx::Vertex<PositionOnlyLayoutAttributes>> tileVertexBuffer;
|
||||
gl::VertexBuffer<RasterLayoutVertex> rasterVertexBuffer;
|
||||
gl::VertexBuffer<ExtrusionTextureLayoutVertex> extrusionTextureVertexBuffer;
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ void RenderTile::finishRender(PaintParameters& parameters) {
|
||||
return;
|
||||
|
||||
static const style::Properties<>::PossiblyEvaluated properties {};
|
||||
static const DebugProgram::PaintPropertyBinders paintAttributeData(properties, 0);
|
||||
static const DebugProgram::Binders paintAttributeData(properties, 0);
|
||||
|
||||
auto& program = parameters.programs.debug;
|
||||
|
||||
|
||||
@@ -435,7 +435,7 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
|
||||
MBGL_DEBUG_GROUP(parameters.context, "clipping masks");
|
||||
|
||||
static const Properties<>::PossiblyEvaluated properties {};
|
||||
static const ClippingMaskProgram::PaintPropertyBinders paintAttributeData(properties, 0);
|
||||
static const ClippingMaskProgram::Binders paintAttributeData(properties, 0);
|
||||
|
||||
for (const auto& clipID : parameters.clipIDGenerator.getClipIDs()) {
|
||||
auto& program = parameters.staticData.programs.clippingMask;
|
||||
|
||||
@@ -56,7 +56,7 @@ void RenderImageSource::finishRender(PaintParameters& parameters) {
|
||||
}
|
||||
|
||||
static const style::Properties<>::PossiblyEvaluated properties {};
|
||||
static const DebugProgram::PaintPropertyBinders paintAttributeData(properties, 0);
|
||||
static const DebugProgram::Binders paintAttributeData(properties, 0);
|
||||
|
||||
auto& programInstance = parameters.programs.debug;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ struct LineGapWidth : DataDrivenPaintProperty<float, attributes::a_gapwidth, uni
|
||||
static float defaultValue() { return 0; }
|
||||
};
|
||||
|
||||
struct LineOffset : DataDrivenPaintProperty<float, attributes::a_offset<1>, uniforms::u_offset> {
|
||||
struct LineOffset : DataDrivenPaintProperty<float, attributes::a_offset, uniforms::u_offset> {
|
||||
static float defaultValue() { return 0; }
|
||||
};
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ public:
|
||||
static constexpr bool IsDataDriven = true;
|
||||
|
||||
using Attribute = A;
|
||||
using Attributes = TypeList<A>;
|
||||
using AttributeList = TypeList<A>;
|
||||
using Uniform = U;
|
||||
using Uniforms = TypeList<U>;
|
||||
using UniformList = TypeList<U>;
|
||||
};
|
||||
|
||||
template <class T, class A1, class U1, class A2, class U2>
|
||||
@@ -50,9 +50,9 @@ public:
|
||||
static constexpr bool IsDataDriven = true;
|
||||
|
||||
using Attribute = A1;
|
||||
using Attributes = TypeList<A1, A2>;
|
||||
using Uniforms = TypeList<U1, U2>;
|
||||
using AttributeList = TypeList<A1, A2>;
|
||||
using Uniform = U1;
|
||||
using UniformList = TypeList<U1, U2>;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/conversion/stringify.hpp>
|
||||
#include <mbgl/renderer/transition_parameters.hpp>
|
||||
#include <mbgl/renderer/paint_property_binder.hpp>
|
||||
#include <mbgl/renderer/possibly_evaluated_property_value.hpp>
|
||||
#include <mbgl/renderer/property_evaluation_parameters.hpp>
|
||||
#include <mbgl/renderer/transition_parameters.hpp>
|
||||
#include <mbgl/util/indexed_tuple.hpp>
|
||||
@@ -122,7 +122,6 @@ public:
|
||||
using EvaluatedTypes = TypeList<typename Ps::Type...>;
|
||||
|
||||
using DataDrivenProperties = FilteredTypeList<PropertyTypes, IsDataDriven>;
|
||||
using Binders = PaintPropertyBinders<DataDrivenProperties>;
|
||||
|
||||
template <class TypeList>
|
||||
using Tuple = IndexedTuple<PropertyTypes, TypeList>;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gl/types.hpp>
|
||||
#include <mbgl/gl/renderbuffer.hpp>
|
||||
#include <mbgl/util/image.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -22,7 +22,7 @@ bool operator==(const Segment<Attributes>& lhs, const Segment<Attributes>& rhs)
|
||||
std::tie(rhs.vertexOffset, rhs.indexOffset, rhs.vertexLength, rhs.indexLength);
|
||||
}
|
||||
|
||||
namespace gl {
|
||||
namespace gfx {
|
||||
namespace detail {
|
||||
|
||||
template <class A1, class A2>
|
||||
@@ -31,7 +31,7 @@ bool operator==(const Vertex<A1, A2>& lhs, const Vertex<A1, A2>& rhs) {
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace gl
|
||||
} // namespace gfx
|
||||
} // namespace mbgl
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
Reference in New Issue
Block a user