forked from organicmaps/organicmaps
added tiny storage for low-overhead rendering on GUI thread.
This commit is contained in:
parent
386807a9e2
commit
9350472797
5 changed files with 63 additions and 9 deletions
|
@ -90,16 +90,27 @@
|
|||
int multiBlitVBSize = pow(2, ceil(log2(300 * sizeof(yg::gl::AuxVertex))));
|
||||
int multiBlitIBSize = pow(2, ceil(log2(300 * sizeof(unsigned short))));
|
||||
|
||||
int tinyVBSize = pow(2, ceil(log2(300 * sizeof(yg::gl::AuxVertex))));
|
||||
int tinyIBSize = pow(2, ceil(log2(300 * sizeof(unsigned short))));
|
||||
|
||||
NSLog(@"Vendor: %s, Renderer: %s", glGetString(GL_VENDOR), glGetString(GL_RENDERER));
|
||||
|
||||
Platform & pl = GetPlatform();
|
||||
|
||||
size_t dynTexWidth = 512;
|
||||
size_t dynTexHeight = 256;
|
||||
size_t dynTexCount = 10;
|
||||
|
||||
size_t fontTexWidth = 512;
|
||||
size_t fontTexHeight = 256;
|
||||
size_t fontTexCount = 10;
|
||||
|
||||
resourceManager = shared_ptr<yg::ResourceManager>(new yg::ResourceManager(
|
||||
bigVBSize, bigIBSize, 6 * GetPlatform().CpuCores(),
|
||||
smallVBSize, smallIBSize, 15 * GetPlatform().CpuCores(),
|
||||
blitVBSize, blitIBSize, 15 * GetPlatform().CpuCores(),
|
||||
512, 256, 10 * GetPlatform().CpuCores(),
|
||||
512, 256, 10 * GetPlatform().CpuCores(),
|
||||
dynTexWidth, dynTexHeight, dynTexCount * GetPlatform().CpuCores(),
|
||||
fontTexWidth, fontTexHeight, fontTexCount * GetPlatform().CpuCores(),
|
||||
"unicode_blocks.txt",
|
||||
"fonts_whitelist.txt",
|
||||
"fonts_blacklist.txt",
|
||||
|
@ -109,6 +120,7 @@
|
|||
!yg::gl::g_isBufferObjectsSupported));
|
||||
|
||||
resourceManager->initMultiBlitStorage(multiBlitVBSize, multiBlitIBSize, 10);
|
||||
resourceManager->initTinyStorage(tinyVBSize, tinyIBSize, 10);
|
||||
|
||||
Platform::FilesList fonts;
|
||||
pl.GetFontNames(fonts);
|
||||
|
@ -121,6 +133,7 @@
|
|||
p.m_skinName = pl.SkinName();
|
||||
p.m_visualScale = pl.VisualScale();
|
||||
p.m_isSynchronized = false;
|
||||
p.m_useTinyStorage = true; //< use tiny buffers to minimize CPU->GPU data transfer overhead.
|
||||
|
||||
drawer = shared_ptr<DrawerYG>(new DrawerYG(p));
|
||||
|
||||
|
|
|
@ -22,11 +22,16 @@ namespace yg
|
|||
{
|
||||
namespace gl
|
||||
{
|
||||
GeometryBatcher::Params::Params() : m_isSynchronized(true)
|
||||
GeometryBatcher::Params::Params()
|
||||
: m_isSynchronized(true),
|
||||
m_useTinyStorage(false)
|
||||
{}
|
||||
|
||||
GeometryBatcher::GeometryBatcher(Params const & params)
|
||||
: base_t(params), m_isAntiAliased(true), m_isSynchronized(params.m_isSynchronized)
|
||||
: base_t(params),
|
||||
m_isAntiAliased(true),
|
||||
m_isSynchronized(params.m_isSynchronized),
|
||||
m_useTinyStorage(params.m_useTinyStorage)
|
||||
{
|
||||
reset(-1);
|
||||
applyStates();
|
||||
|
@ -77,8 +82,11 @@ namespace yg
|
|||
{
|
||||
if (!m_hasStorage)
|
||||
{
|
||||
m_storage = usage != SkinPage::EStaticUsage ? resourceManager->storages()->Reserve()
|
||||
: resourceManager->smallStorages()->Reserve();
|
||||
if (m_useTinyStorage)
|
||||
m_storage = resourceManager->tinyStorages()->Reserve();
|
||||
else
|
||||
m_storage = usage != SkinPage::EStaticUsage ? resourceManager->storages()->Reserve()
|
||||
: resourceManager->smallStorages()->Reserve();
|
||||
|
||||
m_maxVertices = m_storage.m_vertices->size() / sizeof(Vertex);
|
||||
m_maxIndices = m_storage.m_indices->size() / sizeof(unsigned short);
|
||||
|
@ -103,6 +111,7 @@ namespace yg
|
|||
|
||||
for (size_t i = 0; i < m_pipelines.size(); ++i)
|
||||
{
|
||||
m_pipelines[i].m_useTinyStorage = m_useTinyStorage;
|
||||
m_pipelines[i].m_currentVertex = 0;
|
||||
m_pipelines[i].m_currentIndex = 0;
|
||||
|
||||
|
@ -223,10 +232,13 @@ namespace yg
|
|||
|
||||
renderedData = true;
|
||||
|
||||
if (skinPage->usage() != SkinPage::EStaticUsage)
|
||||
resourceManager()->storages()->Free(pipeline.m_storage);
|
||||
if (m_useTinyStorage)
|
||||
resourceManager()->tinyStorages()->Free(pipeline.m_storage);
|
||||
else
|
||||
resourceManager()->smallStorages()->Free(pipeline.m_storage);
|
||||
if (skinPage->usage() != SkinPage::EStaticUsage)
|
||||
resourceManager()->storages()->Free(pipeline.m_storage);
|
||||
else
|
||||
resourceManager()->smallStorages()->Free(pipeline.m_storage);
|
||||
|
||||
pipeline.m_hasStorage = false;
|
||||
pipeline.m_storage = Storage();
|
||||
|
|
|
@ -62,6 +62,8 @@ namespace yg
|
|||
mutable unsigned short * m_indices;
|
||||
/// @}
|
||||
|
||||
bool m_useTinyStorage;
|
||||
|
||||
size_t verticesLeft();
|
||||
size_t indicesLeft();
|
||||
|
||||
|
@ -79,6 +81,7 @@ namespace yg
|
|||
|
||||
bool m_isAntiAliased;
|
||||
bool m_isSynchronized;
|
||||
bool m_useTinyStorage;
|
||||
|
||||
int m_aaShift;
|
||||
|
||||
|
@ -94,6 +97,7 @@ namespace yg
|
|||
struct Params : public base_t::Params
|
||||
{
|
||||
bool m_isSynchronized;
|
||||
bool m_useTinyStorage;
|
||||
Params();
|
||||
};
|
||||
|
||||
|
|
|
@ -79,6 +79,14 @@ namespace yg
|
|||
m_multiBlitStorages.reset(new TStoragePool(TStoragePoolTraits(TStorageFactory(multiBlitVBSize, multiBlitIBSize, m_useVA, "multiBlitStorage"), multiBlitStoragesCount)));
|
||||
}
|
||||
|
||||
void ResourceManager::initTinyStorage(size_t tinyVBSize, size_t tinyIBSize, size_t tinyStoragesCount)
|
||||
{
|
||||
m_tinyVBSize = tinyVBSize;
|
||||
m_tinyIBSize = tinyIBSize;
|
||||
|
||||
m_tinyStorages.reset(new TStoragePool(TStoragePoolTraits(TStorageFactory(tinyVBSize, tinyIBSize, m_useVA, "tinyStorage"), tinyStoragesCount)));
|
||||
}
|
||||
|
||||
void ResourceManager::initRenderTargets(size_t renderTargetWidth, size_t renderTargetHeight, size_t renderTargetsCount)
|
||||
{
|
||||
m_renderTargetWidth = renderTargetWidth;
|
||||
|
@ -185,6 +193,9 @@ namespace yg
|
|||
if (m_multiBlitStorages.get())
|
||||
m_multiBlitStorages->EnterBackground();
|
||||
|
||||
if (m_tinyStorages.get())
|
||||
m_tinyStorages->EnterBackground();
|
||||
|
||||
if (m_dynamicTextures.get())
|
||||
m_dynamicTextures->EnterBackground();
|
||||
|
||||
|
@ -211,6 +222,9 @@ namespace yg
|
|||
if (m_multiBlitStorages.get())
|
||||
m_multiBlitStorages->EnterForeground();
|
||||
|
||||
if (m_tinyStorages.get())
|
||||
m_tinyStorages->EnterForeground();
|
||||
|
||||
if (m_dynamicTextures.get())
|
||||
m_dynamicTextures->EnterForeground();
|
||||
|
||||
|
@ -264,6 +278,11 @@ namespace yg
|
|||
return m_multiBlitStorages.get();
|
||||
}
|
||||
|
||||
ResourceManager::TStoragePool * ResourceManager::tinyStorages()
|
||||
{
|
||||
return m_tinyStorages.get();
|
||||
}
|
||||
|
||||
ResourceManager::TTexturePool * ResourceManager::dynamicTextures()
|
||||
{
|
||||
return m_dynamicTextures.get();
|
||||
|
|
|
@ -92,10 +92,14 @@ namespace yg
|
|||
size_t m_multiBlitVBSize;
|
||||
size_t m_multiBlitIBSize;
|
||||
|
||||
size_t m_tinyVBSize;
|
||||
size_t m_tinyIBSize;
|
||||
|
||||
auto_ptr<TStoragePool> m_storages;
|
||||
auto_ptr<TStoragePool> m_smallStorages;
|
||||
auto_ptr<TStoragePool> m_blitStorages;
|
||||
auto_ptr<TStoragePool> m_multiBlitStorages;
|
||||
auto_ptr<TStoragePool> m_tinyStorages;
|
||||
|
||||
vector<GlyphCache> m_glyphCaches;
|
||||
|
||||
|
@ -118,6 +122,7 @@ namespace yg
|
|||
|
||||
void initMultiBlitStorage(size_t multiBlitVBSize, size_t multiBlitIBSize, size_t multiBlitStoragesCount);
|
||||
void initRenderTargets(size_t renderTargetWidth, size_t renderTargetHeight, size_t renderTargetCount);
|
||||
void initTinyStorage(size_t tinyVBSize, size_t tinyIBSize, size_t tinyStoragesCount);
|
||||
|
||||
shared_ptr<gl::BaseTexture> const & getTexture(string const & fileName);
|
||||
|
||||
|
@ -125,6 +130,7 @@ namespace yg
|
|||
TStoragePool * smallStorages();
|
||||
TStoragePool * blitStorages();
|
||||
TStoragePool * multiBlitStorages();
|
||||
TStoragePool * tinyStorages();
|
||||
|
||||
TTexturePool * dynamicTextures();
|
||||
TTexturePool * fontTextures();
|
||||
|
|
Loading…
Add table
Reference in a new issue