diff --git a/base/resource_pool.cpp b/base/resource_pool.cpp index 90220e667b..46ce9d46d5 100644 --- a/base/resource_pool.cpp +++ b/base/resource_pool.cpp @@ -2,8 +2,12 @@ #include "resource_pool.hpp" -BasePoolElemFactory::BasePoolElemFactory(char const * resName, size_t elemSize, size_t batchSize) - : m_resName(resName), m_elemSize(elemSize), m_batchSize(batchSize) +BasePoolElemFactory::BasePoolElemFactory(char const * resName, + size_t elemSize, + size_t batchSize) + : m_resName(resName), + m_elemSize(elemSize), + m_batchSize(batchSize) {} char const * BasePoolElemFactory::ResName() const diff --git a/base/resource_pool.hpp b/base/resource_pool.hpp index fdb354e21f..75f824ca40 100644 --- a/base/resource_pool.hpp +++ b/base/resource_pool.hpp @@ -1,5 +1,6 @@ #pragma once +#include "thread.hpp" #include "threaded_list.hpp" #include "logging.hpp" #include "../std/bind.hpp" @@ -25,11 +26,14 @@ struct BasePoolTraits TElemFactory m_factory; ThreadedList m_pool; bool m_IsDebugging; + threads::ThreadID m_MainThreadID; typedef TElem elem_t; BasePoolTraits(TElemFactory const & factory) - : m_factory(factory), m_IsDebugging(false) + : m_factory(factory), + m_IsDebugging(false), + m_MainThreadID(threads::GetCurrentThreadID()) { m_pool.SetName(factory.ResName()); } @@ -220,6 +224,15 @@ struct AllocateOnDemandSingleThreadedPoolTraits : TBase } } + elem_t const Reserve() + { + /// allocate resources if needed if we're on the main thread. + if (threads::GetCurrentThreadID() == base_t::m_MainThreadID) + base_t::m_pool.ProcessList(bind(&self_t::AllocateIfNeeded, this, _1)); + + return base_t::Reserve(); + } + void UpdateState() { base_t::UpdateState(); diff --git a/map/tiling_render_policy_st.cpp b/map/tiling_render_policy_st.cpp index 3b4ceb5c4b..18ad07be01 100644 --- a/map/tiling_render_policy_st.cpp +++ b/map/tiling_render_policy_st.cpp @@ -77,7 +77,7 @@ TilingRenderPolicyST::TilingRenderPolicyST(Params const & p) true, 1, "multiBlitStorage", - false, + true, true); rmp.m_renderTargetTexturesParams = yg::ResourceManager::TexturePoolParams(TileSize(), @@ -89,32 +89,32 @@ TilingRenderPolicyST::TilingRenderPolicyST(Params const & p) true, 4, "renderTargetTexture", - false, + true, true); rmp.m_guiThreadStoragesParams = yg::ResourceManager::StoragePoolParams(2000 * sizeof(yg::gl::Vertex), sizeof(yg::gl::Vertex), 4000 * sizeof(unsigned short), sizeof(unsigned short), - 20, + 5, true, true, 1, "guiThreadStorage", true, - false); + true); rmp.m_guiThreadTexturesParams = yg::ResourceManager::TexturePoolParams(256, 128, - 4, + 2, rmp.m_texFormat, true, true, true, 1, "guiThreadTexture", - false, - false); + true, + true); /* bool * debuggingFlags = new bool[cpuCores + 2]; for (unsigned i = 0; i < cpuCores + 2; ++i)