summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/attribute.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-11-14 12:11:53 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-11-15 13:55:08 -0800
commit58877d1b3ddf0e4521d680b85e31b7a4c6287302 (patch)
treef844c8a12f82e40b1777ae79fe416c1eaa714470 /src/mbgl/gl/attribute.hpp
parent0fe8d8d7b4bbf136e8fb0f972cc31a94ddc4b67e (diff)
downloadqtlocation-mapboxgl-58877d1b3ddf0e4521d680b85e31b7a4c6287302.tar.gz
[core] Assign attribute locations sequentially
Two reasons to prefer explicit sequential location assignment, rather than relying on the GLSL linker to assign locations: * For data-driven properties, we want to have the option to use glDisableVertexAttribArray plus glVertexAttrib*. In order to use glDisableVertexAttribArray, we must avoid using attribute location 0, which cannot be disabled. * We want to use the same VAO in cases where, say, a fill layer might be rendered with FillProgram at first, and then FillPatternProgram later. VAOs do not store the program binding, only the attribute bindings, so as long as the two programs have the same attributes and attribute locations, only a single VAO (per segment) is needed.
Diffstat (limited to 'src/mbgl/gl/attribute.hpp')
-rw-r--r--src/mbgl/gl/attribute.hpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mbgl/gl/attribute.hpp b/src/mbgl/gl/attribute.hpp
index df469fc6a2..e45014127b 100644
--- a/src/mbgl/gl/attribute.hpp
+++ b/src/mbgl/gl/attribute.hpp
@@ -17,6 +17,9 @@ public:
class State {
public:
+ explicit State(AttributeLocation location_)
+ : location(location_) {}
+
AttributeLocation location;
static constexpr std::size_t count = N;
static constexpr DataType type = DataTypeOf<T>::value;
@@ -130,7 +133,7 @@ const std::size_t Vertex<A1, A2, A3, A4, A5>::attributeOffsets[5] = {
} // namespace detail
-AttributeLocation attributeLocation(ProgramID, const char * name);
+AttributeLocation bindAttributeLocation(ProgramID, AttributeLocation, const char * name);
void bindAttribute(AttributeLocation location,
std::size_t count,
@@ -149,7 +152,7 @@ public:
static constexpr std::size_t Index = TypeIndex<A, As...>::value;
static State state(const ProgramID& id) {
- return State { { attributeLocation(id, As::name) }... };
+ return State { typename As::State(bindAttributeLocation(id, Index<As>, As::name))... };
}
static std::function<void (std::size_t)> binder(const State& state) {