diff --git a/3party/sdf_image/sdf_image.cpp b/3party/sdf_image/sdf_image.cpp index 9e259dc644..9732e6b694 100644 --- a/3party/sdf_image/sdf_image.cpp +++ b/3party/sdf_image/sdf_image.cpp @@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "drape/sdf_image.h" +#include "drape/sdf_image.hpp" #include "base/math.hpp" #include "base/scope_guard.hpp" diff --git a/drape/batcher.cpp b/drape/batcher.cpp index 0d76cf2cf7..2184a79f88 100644 --- a/drape/batcher.cpp +++ b/drape/batcher.cpp @@ -17,13 +17,19 @@ public: CallbacksWrapper(GLState const & state, RefPointer overlay) : m_state(state) , m_overlay(overlay) + , m_vaoChanged(false) { - } void SetVAO(RefPointer buffer) { + // invocation with non-null VAO will cause to invalid range of indices. + // It means that VAO has been changed during batching + if (!m_buffer.IsNull()) + m_vaoChanged = true; + m_buffer = buffer; + m_indicesRange.m_idxStart = m_buffer->GetIndexCount(); } bool IsVAOFilled() const @@ -74,11 +80,23 @@ public: return m_state; } + IndicesRange const & Finish() + { + if (!m_vaoChanged) + m_indicesRange.m_idxCount = m_buffer->GetIndexCount() - m_indicesRange.m_idxStart; + else + m_indicesRange = IndicesRange(); + + return m_indicesRange; + } + private: GLState const & m_state; RefPointer m_buffer; - RefPointer m_overlay; - vector m_indexStorage; + RefPointer m_overlay; + vector m_indexStorage; + IndicesRange m_indicesRange; + bool m_vaoChanged; }; //////////////////////////////////////////////////////////////// @@ -203,7 +221,6 @@ IndicesRange Batcher::InsertTriangles(GLState const & state, RefPointer bucket = GetBucket(state); RefPointer vao = bucket->GetBuffer(); IndicesRange range; - range.m_idxStart = vao->GetIndexCount(); MasterPointer handle(transferHandle); @@ -223,12 +240,13 @@ IndicesRange Batcher::InsertTriangles(GLState const & state, RefPointerAddOverlayHandle(handle.Move()); - range.m_idxCount = vao->GetIndexCount() - range.m_idxStart; return range; } diff --git a/drape/vertex_array_buffer.cpp b/drape/vertex_array_buffer.cpp index 2146043a94..f062960908 100644 --- a/drape/vertex_array_buffer.cpp +++ b/drape/vertex_array_buffer.cpp @@ -50,7 +50,7 @@ void VertexArrayBuffer::Preflush() void VertexArrayBuffer::Render() { - RenderRange({ 0, GetIndexBuffer().GetCurrentSize() }); + RenderRange(IndicesRange(0, GetIndexBuffer().GetCurrentSize())); } void VertexArrayBuffer::RenderRange(IndicesRange const & range) diff --git a/drape/vertex_array_buffer.hpp b/drape/vertex_array_buffer.hpp index 3e821c9ea3..c398a0845b 100644 --- a/drape/vertex_array_buffer.hpp +++ b/drape/vertex_array_buffer.hpp @@ -17,6 +17,16 @@ struct IndicesRange { uint16_t m_idxStart; uint16_t m_idxCount; + + IndicesRange() + : m_idxStart(0), m_idxCount(0) + {} + + IndicesRange(uint16_t idxStart, uint16_t idxCount) + : m_idxStart(idxStart), m_idxCount(idxCount) + {} + + bool IsValid() const { return m_idxCount != 0; } }; class VertexArrayBuffer diff --git a/drape_frontend/my_position.cpp b/drape_frontend/my_position.cpp index 9dfdeb4070..d97500dd3f 100644 --- a/drape_frontend/my_position.cpp +++ b/drape_frontend/my_position.cpp @@ -144,6 +144,7 @@ void MyPosition::CacheAccuracySector(dp::RefPointer mng) provider.InitStream(0 /*stream index*/, GetBindingInfo(), dp::StackVoidRef(buffer.data())); m_parts[MY_POSITION_ACCURACY].first = batcher.InsertTriangleFan(state, dp::MakeStackRefPointer(&provider)); + ASSERT(m_parts[MY_POSITION_ACCURACY].first.IsValid(), ()); } } @@ -199,7 +200,9 @@ void MyPosition::CachePointPosition(dp::RefPointer mng) m_parts[MY_POSITION_POINT].second = m_nodes.size(); m_parts[MY_POSITION_ARROW].second = m_nodes.size(); m_parts[MY_POSITION_POINT].first = batcher.InsertTriangleStrip(state, dp::MakeStackRefPointer(&pointProvider)); + ASSERT(m_parts[MY_POSITION_POINT].first.IsValid(), ()); m_parts[MY_POSITION_ARROW].first = batcher.InsertTriangleStrip(state, dp::MakeStackRefPointer(&arrowProvider)); + ASSERT(m_parts[MY_POSITION_ARROW].first.IsValid(), ()); } }