diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-11-14 11:57:02 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-11-15 13:55:08 -0800 |
commit | 9d2be044614c3719a88523e32f4d8155bd6debb8 (patch) | |
tree | 718ec2f7adb7e73ef724ab070e7e7722247e338b /src/mbgl/gl/context.cpp | |
parent | 377d0fb0d20fa4129d867f0e8762ce208ccee14d (diff) | |
download | qtlocation-mapboxgl-9d2be044614c3719a88523e32f4d8155bd6debb8.tar.gz |
[core] Return to static, per-segment approach to VAOs
This is safer now -- it can be an implementation detail of Segment/Context. And the typing of SegmentVector now ensures that the attributes and program match.
Diffstat (limited to 'src/mbgl/gl/context.cpp')
-rw-r--r-- | src/mbgl/gl/context.cpp | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 3251be0c87..41e81a186f 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -6,7 +6,7 @@ #include <mbgl/util/std.hpp> #include <mbgl/platform/log.hpp> -#include <boost/functional/hash.hpp> +#include <cstring> namespace mbgl { namespace gl { @@ -434,15 +434,6 @@ PrimitiveType Context::operator()(const TriangleStrip&) { return PrimitiveType::TriangleStrip; } -std::size_t Context::VertexArrayObjectHash::operator()(const VertexArrayObjectKey& key) const { - std::size_t seed = 0; - boost::hash_combine(seed, std::get<0>(key)); - boost::hash_combine(seed, std::get<1>(key)); - boost::hash_combine(seed, std::get<2>(key)); - boost::hash_combine(seed, std::get<3>(key)); - return seed; -} - void Context::setDepthMode(const DepthMode& depth) { if (depth.func == DepthMode::Always && !depth.mask) { depthTest = false; @@ -503,23 +494,15 @@ void Context::draw(const Drawable& drawable) { return true; } - VertexArrayObjectKey vaoKey { - drawable.program, - drawable.vertexBuffer, - drawable.indexBuffer, - segment.vertexOffset - }; - - auto it = vaos.find(vaoKey); - if (it != vaos.end()) { - vertexArrayObject = it->second; + if (segment.vao) { + vertexArrayObject = *segment.vao; return false; } VertexArrayID id = 0; MBGL_CHECK_ERROR(gl::GenVertexArrays(1, &id)); vertexArrayObject = id; - vaos.emplace(vaoKey, UniqueVertexArray(std::move(id), { this })); + segment.vao = UniqueVertexArray(std::move(id), { this }); // If we are initializing a new VAO, we need to force the buffers // to be rebound. VAOs don't inherit the existing buffer bindings. @@ -555,9 +538,6 @@ void Context::performCleanup() { if (program == id) { program.setDirty(); } - mbgl::util::erase_if(vaos, [&] (const VertexArrayObjectMap::value_type& kv) { - return std::get<0>(kv.first) == id; - }); MBGL_CHECK_ERROR(glDeleteProgram(id)); } abandonedPrograms.clear(); @@ -574,10 +554,6 @@ void Context::performCleanup() { } else if (elementBuffer == id) { elementBuffer.setDirty(); } - mbgl::util::erase_if(vaos, [&] (const VertexArrayObjectMap::value_type& kv) { - return std::get<1>(kv.first) == id - || std::get<2>(kv.first) == id; - }); } MBGL_CHECK_ERROR(glDeleteBuffers(int(abandonedBuffers.size()), abandonedBuffers.data())); abandonedBuffers.clear(); |