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:
authorr.kuznetsov <r.kuznetsov@corp.mail.ru>2019-02-13 11:28:03 +0300
committerDaria Volvenkova <d.volvenkova@corp.mail.ru>2019-03-01 10:45:24 +0300
commitdf4fe61d87e410e4e34d213217ffa35b4326aef9 (patch)
tree742733955568c8367967e8f6abb6711191562c6f /drape/vertex_array_buffer.cpp
parent19fbb89df3e34b5d3fb173f3a2d189339d435db3 (diff)
[vulkan] Small refactoring and bugfixes
Diffstat (limited to 'drape/vertex_array_buffer.cpp')
-rw-r--r--drape/vertex_array_buffer.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/drape/vertex_array_buffer.cpp b/drape/vertex_array_buffer.cpp
index d847072e30..4375b404c1 100644
--- a/drape/vertex_array_buffer.cpp
+++ b/drape/vertex_array_buffer.cpp
@@ -11,6 +11,8 @@
#include "std/target_os.hpp"
+#include <algorithm>
+
namespace dp
{
namespace
@@ -215,7 +217,8 @@ void VertexArrayBuffer::Build(ref_ptr<GraphicsContext> context, ref_ptr<GpuProgr
}
else if (apiVersion == dp::ApiVersion::Vulkan)
{
- m_impl = CreateImplForVulkan(context, make_ref(this));
+ CHECK(!m_bindingInfo.empty(), ());
+ m_impl = CreateImplForVulkan(context, make_ref(this), std::move(m_bindingInfo));
}
else
{
@@ -242,7 +245,10 @@ void VertexArrayBuffer::UploadData(ref_ptr<GraphicsContext> context, BindingInfo
buffer = GetOrCreateStaticBuffer(bindingInfo);
else
buffer = GetOrCreateDynamicBuffer(bindingInfo);
- m_impl->AddBindingInfo(bindingInfo);
+
+ // For Vulkan rendering we have to know the whole collection of binding info.
+ if (context->GetApiVersion() == dp::ApiVersion::Vulkan && !m_impl)
+ CollectBindingInfo(bindingInfo);
if (count > 0)
m_isChanged = true;
@@ -427,4 +433,26 @@ ref_ptr<DataBufferBase> VertexArrayBuffer::GetIndexBuffer() const
CHECK(m_indexBuffer != nullptr, ());
return m_indexBuffer->GetBuffer();
}
+
+void VertexArrayBuffer::CollectBindingInfo(dp::BindingInfo const & bindingInfo)
+{
+ auto const id = bindingInfo.GetID();
+ auto const it = std::find_if(m_bindingInfo.begin(), m_bindingInfo.end(),
+ [id](dp::BindingInfo const & info)
+ {
+ return info.GetID() == id;
+ });
+ if (it != m_bindingInfo.end())
+ {
+ CHECK(*it == bindingInfo, ("Incorrect binding info."));
+ return;
+ }
+
+ m_bindingInfo.push_back(bindingInfo);
+ std::sort(m_bindingInfo.begin(), m_bindingInfo.end(),
+ [](dp::BindingInfo const & info1, dp::BindingInfo const & info2)
+ {
+ return info1.GetID() < info2.GetID();
+ });
+}
} // namespace dp