allocating opengl resources in AllocateOnDemandSingleThreadedPoolTraits directly in Reserve method if we're calling it from primary OpenGL thread.

This commit is contained in:
rachytski 2012-09-29 20:07:45 +03:00 committed by Alex Zolotarev
parent 7ea55eff17
commit 499af27e6a
3 changed files with 27 additions and 10 deletions

View file

@ -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

View file

@ -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<TElem> 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();

View file

@ -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)