Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drape/batcher.cpp2
-rw-r--r--drape/batcher_helpers.cpp13
-rw-r--r--drape/batcher_helpers.hpp2
-rw-r--r--drape/drape_tests/glfunctions.cpp2
-rw-r--r--drape/glfunctions.cpp5
-rw-r--r--drape/glfunctions.hpp2
-rw-r--r--drape/index_storage.cpp38
-rw-r--r--drape/index_storage.hpp8
-rw-r--r--drape/vertex_array_buffer.cpp6
-rw-r--r--drape_frontend/backend_renderer.cpp6
10 files changed, 45 insertions, 39 deletions
diff --git a/drape/batcher.cpp b/drape/batcher.cpp
index 0b45528e4d..d27232dbc3 100644
--- a/drape/batcher.cpp
+++ b/drape/batcher.cpp
@@ -251,7 +251,7 @@ Batcher * BatcherFactory::GetNew() const
{
uint32_t indexBufferSize = 65000;
uint32_t vertexBufferSize = 65000;
- if (GLExtensionsList::Instance().IsSupported(GLExtensionsList::UintIndices))
+ if (dp::IndexStorage::IsSupported32bit())
{
indexBufferSize = 65000 * 2;
vertexBufferSize = 65000 * 2;
diff --git a/drape/batcher_helpers.cpp b/drape/batcher_helpers.cpp
index c3c3d1392d..3d3b1c9930 100644
--- a/drape/batcher_helpers.cpp
+++ b/drape/batcher_helpers.cpp
@@ -1,6 +1,7 @@
#include "drape/batcher_helpers.hpp"
#include "drape/attribute_provider.hpp"
#include "drape/cpu_buffer.hpp"
+#include "drape/index_storage.hpp"
#include "drape/glextensions_list.hpp"
#include "base/assert.hpp"
@@ -19,12 +20,6 @@ bool IsEnoughMemory(uint32_t avVertex, uint32_t existVertex, uint32_t avIndex, u
return avVertex >= existVertex && avIndex >= existIndex;
}
-bool IsSupported32bit()
-{
- static bool const supports32bit = GLExtensionsList::Instance().IsSupported(GLExtensionsList::UintIndices);
- return supports32bit;
-}
-
template<typename TGenerator> void GenerateIndices(void * indexStorage, uint32_t count, uint32_t startIndex)
{
GenerateIndices<TGenerator>(indexStorage, count, TGenerator(startIndex));
@@ -32,7 +27,7 @@ template<typename TGenerator> void GenerateIndices(void * indexStorage, uint32_t
template<typename TGenerator> void GenerateIndices(void * indexStorage, uint32_t count, TGenerator const & generator)
{
- if (IsSupported32bit())
+ if (dp::IndexStorage::IsSupported32bit())
{
uint32_t * pIndexStorage = static_cast<uint32_t *>(indexStorage);
generate(pIndexStorage, pIndexStorage + count, generator);
@@ -166,10 +161,10 @@ void TriangleBatch::SetVertexStride(uint8_t vertexStride)
m_vertexStride = vertexStride;
}
-void TriangleBatch::FlushData(ref_ptr<AttributeProvider> streams, uint32_t vertexVount) const
+void TriangleBatch::FlushData(ref_ptr<AttributeProvider> streams, uint32_t vertexCount) const
{
for (uint8_t i = 0; i < streams->GetStreamCount(); ++i)
- FlushData(streams->GetBindingInfo(i), streams->GetRawPointer(i), vertexVount);
+ FlushData(streams->GetBindingInfo(i), streams->GetRawPointer(i), vertexCount);
}
void TriangleBatch::FlushData(BindingInfo const & info, void const * data, uint32_t elementCount) const
diff --git a/drape/batcher_helpers.hpp b/drape/batcher_helpers.hpp
index b9214001e0..2f91685f8e 100644
--- a/drape/batcher_helpers.hpp
+++ b/drape/batcher_helpers.hpp
@@ -39,7 +39,7 @@ public:
void SetVertexStride(uint8_t vertexStride);
protected:
- void FlushData(ref_ptr<AttributeProvider> streams, uint32_t vertexVount) const;
+ void FlushData(ref_ptr<AttributeProvider> streams, uint32_t vertexCount) const;
void FlushData(BindingInfo const & info, void const * data, uint32_t elementCount) const;
void * GetIndexStorage(uint32_t indexCount, uint32_t & startIndex);
void SubmitIndex();
diff --git a/drape/drape_tests/glfunctions.cpp b/drape/drape_tests/glfunctions.cpp
index 16c39fd67b..f2bf7aeec2 100644
--- a/drape/drape_tests/glfunctions.cpp
+++ b/drape/drape_tests/glfunctions.cpp
@@ -255,7 +255,7 @@ void * GLFunctions::glMapBuffer(glConst target) { return 0; }
void GLFunctions::glUnmapBuffer(glConst target) {}
-void GLFunctions::glDrawElements(bool use32bits, uint32_t indexCount, uint32_t startIndex) {}
+void GLFunctions::glDrawElements(uint32_t sizeOfIndex, uint32_t indexCount, uint32_t startIndex) {}
void GLFunctions::glPixelStore(glConst name, uint32_t value) {}
diff --git a/drape/glfunctions.cpp b/drape/glfunctions.cpp
index 95515416af..517854aa93 100644
--- a/drape/glfunctions.cpp
+++ b/drape/glfunctions.cpp
@@ -777,10 +777,9 @@ void GLFunctions::glTexParameter(glConst param, glConst value)
GLCHECK(::glTexParameteri(GL_TEXTURE_2D, param, value));
}
-void GLFunctions::glDrawElements(bool use32bits, uint32_t indexCount, uint32_t startIndex)
+void GLFunctions::glDrawElements(uint32_t sizeOfIndex, uint32_t indexCount, uint32_t startIndex)
{
- uint32_t const sizeOfIndex = use32bits ? sizeof(uint32_t) : sizeof(uint16_t);
- GLCHECK(::glDrawElements(GL_TRIANGLES, indexCount, use32bits ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT,
+ GLCHECK(::glDrawElements(GL_TRIANGLES, indexCount, sizeOfIndex == sizeof(uint32_t) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT,
reinterpret_cast<GLvoid *>(startIndex * sizeOfIndex)));
}
diff --git a/drape/glfunctions.hpp b/drape/glfunctions.hpp
index 7ad2e0150c..605b6612ee 100644
--- a/drape/glfunctions.hpp
+++ b/drape/glfunctions.hpp
@@ -121,7 +121,7 @@ public:
static void glTexParameter(glConst param, glConst value);
// Draw support
- static void glDrawElements(bool use32bits, uint32_t indexCount, uint32_t startIndex = 0);
+ static void glDrawElements(uint32_t sizeOfIndex, uint32_t indexCount, uint32_t startIndex = 0);
};
void CheckGLError(my::SrcPoint const &src);
diff --git a/drape/index_storage.cpp b/drape/index_storage.cpp
index 3b08dd0b88..2cd090f09f 100644
--- a/drape/index_storage.cpp
+++ b/drape/index_storage.cpp
@@ -6,43 +6,52 @@
namespace dp
{
+IndexStorage::IndexStorage()
+ : m_size(0)
+{}
+
IndexStorage::IndexStorage(vector<uint32_t> && initial)
{
+ m_size = (uint32_t)initial.size();
if (IsSupported32bit())
{
- m_storage32bit = move(initial);
+ m_storage = move(initial);
}
else
{
- m_storage16bit.reserve(initial.size());
+ /// we pack 2 uint16_t indices into single m_storage element
+ /// every element of "initial" vector is single index
+ m_storage.resize(GetStorageSize(m_size));
for (size_t i = 0; i < initial.size(); i++)
- m_storage16bit.push_back((uint16_t)initial[i]);
+ {
+ uint16_t * ptr = reinterpret_cast<uint16_t *>(m_storage.data()) + i;
+ *ptr = (uint16_t)initial[i];
+ }
}
}
void IndexStorage::Resize(uint32_t size)
{
- if (IsSupported32bit())
- m_storage32bit.resize(size);
- else
- m_storage16bit.resize(size);
+ m_size = size;
+ m_storage.resize(GetStorageSize(m_size));
}
uint32_t IndexStorage::Size() const
{
- return IsSupported32bit() ? (uint32_t)m_storage32bit.size() : (uint32_t)m_storage16bit.size();
+ return m_size;
}
void * IndexStorage::GetRaw(uint32_t offsetInElements)
{
- return IsSupported32bit() ? static_cast<void *>(&m_storage32bit[offsetInElements]) :
- static_cast<void *>(&m_storage16bit[offsetInElements]);
+ if (IsSupported32bit())
+ return &m_storage[offsetInElements];
+
+ return reinterpret_cast<uint16_t *>(m_storage.data()) + offsetInElements;
}
void const * IndexStorage::GetRawConst() const
{
- return IsSupported32bit() ? static_cast<void const *>(m_storage32bit.data()) :
- static_cast<void const *>(m_storage16bit.data());
+ return static_cast<void const *>(m_storage.data());
}
bool IndexStorage::IsSupported32bit()
@@ -56,4 +65,9 @@ uint32_t IndexStorage::SizeOfIndex()
return IsSupported32bit() ? sizeof(uint32_t) : sizeof(uint16_t);
}
+uint32_t IndexStorage::GetStorageSize(uint32_t elementsCount) const
+{
+ return IsSupported32bit() ? elementsCount : (elementsCount / 2 + 1);
+}
+
}
diff --git a/drape/index_storage.hpp b/drape/index_storage.hpp
index 6ae9d8c3a7..79225b5a74 100644
--- a/drape/index_storage.hpp
+++ b/drape/index_storage.hpp
@@ -8,7 +8,7 @@ namespace dp
class IndexStorage
{
public:
- IndexStorage() = default;
+ IndexStorage();
IndexStorage(vector<uint32_t> && initial);
uint32_t Size() const;
@@ -21,8 +21,10 @@ public:
static uint32_t SizeOfIndex();
private:
- vector<uint16_t> m_storage16bit;
- vector<uint32_t> m_storage32bit;
+ vector<uint32_t> m_storage;
+ uint32_t m_size;
+
+ uint32_t GetStorageSize(uint32_t elementsCount) const;
};
diff --git a/drape/vertex_array_buffer.cpp b/drape/vertex_array_buffer.cpp
index 2b4625c3a2..f2c6b8bd9f 100644
--- a/drape/vertex_array_buffer.cpp
+++ b/drape/vertex_array_buffer.cpp
@@ -1,6 +1,7 @@
#include "drape/vertex_array_buffer.hpp"
#include "drape/glfunctions.hpp"
#include "drape/glextensions_list.hpp"
+#include "drape/index_storage.hpp"
#include "base/stl_add.hpp"
#include "base/assert.hpp"
@@ -65,12 +66,9 @@ void VertexArrayBuffer::RenderRange(IndicesRange const & range)
else
BindStaticBuffers();
- // here we have to be sure that 32-bit indices are supported
- bool const supports32bit = GLExtensionsList::Instance().IsSupported(GLExtensionsList::UintIndices);
-
BindDynamicBuffers();
GetIndexBuffer()->Bind();
- GLFunctions::glDrawElements(supports32bit, range.m_idxCount, range.m_idxStart);
+ GLFunctions::glDrawElements(dp::IndexStorage::SizeOfIndex(), range.m_idxCount, range.m_idxStart);
}
}
diff --git a/drape_frontend/backend_renderer.cpp b/drape_frontend/backend_renderer.cpp
index 0689927769..92ee52a5af 100644
--- a/drape_frontend/backend_renderer.cpp
+++ b/drape_frontend/backend_renderer.cpp
@@ -232,10 +232,6 @@ void BackendRenderer::Routine::Do()
m_renderer.m_contextFactory->getResourcesUploadContext()->makeCurrent();
GLFunctions::Init();
- // initialize batchers pool after OGL context creation
- m_renderer.m_batchersPool = make_unique_dp<BatchersPool>(ReadManager::ReadCount(),
- bind(&BackendRenderer::FlushGeometry, &m_renderer, _1));
-
m_renderer.InitGLDependentResource();
while (!IsCancelled())
@@ -249,6 +245,8 @@ void BackendRenderer::Routine::Do()
void BackendRenderer::InitGLDependentResource()
{
+ m_batchersPool = make_unique_dp<BatchersPool>(ReadManager::ReadCount(), bind(&BackendRenderer::FlushGeometry, this, _1));
+
dp::TextureManager::Params params;
params.m_resPrefix = VisualParams::Instance().GetResourcePostfix();
params.m_glyphMngParams.m_uniBlocks = "unicode_blocks.txt";