diff options
author | Lauren Budorick <lauren@mapbox.com> | 2017-06-29 11:29:48 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-29 11:29:48 -0700 |
commit | b5fed1172d77bac0ba122c73a9d30739a51e5028 (patch) | |
tree | 525af4167d907342f3c1ff00d9cf5ef7bbc6f385 /src/mbgl/gl/attribute.hpp | |
parent | f836425be467ac9830d8f6b4caa98700ce87c19b (diff) | |
download | qtlocation-mapboxgl-b5fed1172d77bac0ba122c73a9d30739a51e5028.tar.gz |
[core] Bind only active attributes in order to avoid exceeding attribute limits (#9373)
Introducing two new attributes to enable property functions for line-width (#9250) pushed the attribute count over GL_MAX_VERTEX_ATTRIBS on some devices. Now we selectively bind only attributes that are used, making it unlikely to surpass GL_MAX_VERTEX_ATTRIBS.
Diffstat (limited to 'src/mbgl/gl/attribute.hpp')
-rw-r--r-- | src/mbgl/gl/attribute.hpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/mbgl/gl/attribute.hpp b/src/mbgl/gl/attribute.hpp index 48222146fa..f018a1d261 100644 --- a/src/mbgl/gl/attribute.hpp +++ b/src/mbgl/gl/attribute.hpp @@ -8,6 +8,7 @@ #include <cstddef> #include <vector> +#include <set> #include <functional> namespace mbgl { @@ -223,6 +224,7 @@ const std::size_t Vertex<A1, A2, A3, A4, A5>::attributeOffsets[5] = { } // namespace detail AttributeLocation bindAttributeLocation(ProgramID, AttributeLocation, const char * name); +std::set<std::string> getActiveAttributes(ProgramID); template <class... As> class Attributes { @@ -242,7 +244,15 @@ public: static constexpr std::size_t Index = TypeIndex<A, As...>::value; static Locations bindLocations(const ProgramID& id) { - return Locations { bindAttributeLocation(id, Index<As>, As::name())... }; + std::set<std::string> activeAttributes = getActiveAttributes(id); + + AttributeLocation location = -1; + auto bindAndIncrement = [&](const char* name) { + location++; + return bindAttributeLocation(id, location, name); + }; + return Locations{ (activeAttributes.count(As::name()) ? bindAndIncrement(As::name()) + : -1)... }; } template <class Program> |