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:
authorrachytski <siarhei.rachytski@gmail.com>2011-11-15 19:51:10 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:27:59 +0300
commitf3c52f5f480471698a8b5c432bea5f359fe1c318 (patch)
treee2cd75b316c9ce6900410524877d237feeb200cf
parent80197ff164e831d571ee4949583e48516e0aec43 (diff)
improved scaling of OpenGL resources allocation.
-rw-r--r--android/jni/com/mapswithme/maps/Framework.cpp6
-rw-r--r--iphone/Maps/Classes/EAGLView.mm6
-rw-r--r--map/partial_render_policy.cpp52
-rw-r--r--map/render_policy_mt.cpp79
-rw-r--r--map/render_policy_mt.hpp1
-rw-r--r--map/render_policy_st.cpp44
-rw-r--r--map/tiling_render_policy_mt.cpp70
-rw-r--r--map/tiling_render_policy_st.cpp66
-rw-r--r--platform/platform.hpp2
-rw-r--r--platform/platform_android.cpp5
-rw-r--r--platform/platform_ios.mm9
-rw-r--r--platform/platform_qt.cpp5
-rw-r--r--qt/draw_widget.cpp2
-rw-r--r--qt_tstfrm/tstwidgets.cpp50
-rw-r--r--yg/base_texture.cpp4
-rw-r--r--yg/renderbuffer.cpp2
-rw-r--r--yg/resource_manager.cpp420
-rw-r--r--yg/resource_manager.hpp71
18 files changed, 610 insertions, 284 deletions
diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp
index e8aab318bd..798001335b 100644
--- a/android/jni/com/mapswithme/maps/Framework.cpp
+++ b/android/jni/com/mapswithme/maps/Framework.cpp
@@ -92,7 +92,11 @@ namespace android
DrawerYG::Params params;
params.m_frameBuffer = make_shared_ptr(new yg::gl::FrameBuffer(true));
- m_work.SetRenderPolicy(new PartialRenderPolicy(m_videoTimer, params, make_shared_ptr(new android::RenderContext())));
+ yg::ResourceManager::Params rmParams;
+ rmParams.m_videoMemoryLimit = 15 * 1024 * 1024;
+ rmParams.m_rtTarget = yg::Rt8Bpp;
+
+ m_work.SetRenderPolicy(new PartialRenderPolicy(m_videoTimer, params, rmParams, make_shared_ptr(new android::RenderContext())));
m_work.SetUpdatesEnabled(true);
diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm
index 6f62c7165b..b7a7a05f47 100644
--- a/iphone/Maps/Classes/EAGLView.mm
+++ b/iphone/Maps/Classes/EAGLView.mm
@@ -98,7 +98,11 @@
videoTimer = CreateIOSVideoTimer(bind(drawFrameImpl, self, drawFrameSel));
- renderPolicy = CreateRenderPolicy(videoTimer, p, renderContext);
+ yg::ResourceManager::Params rmParams;
+ rmParams.m_videoMemoryLimit = GetPlatform().VideoMemoryLimit();
+ rmParams.m_rtFormat = fmt;
+
+ renderPolicy = CreateRenderPolicy(videoTimer, p, rmParams, renderContext);
framework->SetRenderPolicy(renderPolicy);
}
diff --git a/map/partial_render_policy.cpp b/map/partial_render_policy.cpp
index 6a15da7aaf..cbf1fff0aa 100644
--- a/map/partial_render_policy.cpp
+++ b/map/partial_render_policy.cpp
@@ -23,28 +23,60 @@ PartialRenderPolicy::PartialRenderPolicy(VideoTimer * videoTimer,
yg::ResourceManager::Params rmp = rmParams;
rmp.m_primaryStoragesParams = yg::ResourceManager::StoragePoolParams(5000 * sizeof(yg::gl::Vertex),
+ sizeof(yg::gl::Vertex),
10000 * sizeof(unsigned short),
+ sizeof(unsigned short),
15,
- false);
+ false,
+ 1,
+ "primaryStorage");
rmp.m_smallStoragesParams = yg::ResourceManager::StoragePoolParams(2000 * sizeof(yg::gl::Vertex),
+ sizeof(yg::gl::Vertex),
4000 * sizeof(unsigned short),
+ sizeof(unsigned short),
100,
- false);
+ false,
+ 1,
+ "smallStorage");
rmp.m_blitStoragesParams = yg::ResourceManager::StoragePoolParams(10 * sizeof(yg::gl::AuxVertex),
+ sizeof(yg::gl::AuxVertex),
10 * sizeof(unsigned short),
+ sizeof(unsigned short),
50,
- true);
+ true,
+ 1,
+ "blitStorage");
rmp.m_tinyStoragesParams = yg::ResourceManager::StoragePoolParams(300 * sizeof(yg::gl::Vertex),
+ sizeof(yg::gl::Vertex),
600 * sizeof(unsigned short),
+ sizeof(unsigned short),
20,
- true);
-
- rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512, 256, 10, rmp.m_rtFormat, true);
-
- rmp.m_fontTexturesParams = yg::ResourceManager::TexturePoolParams(512, 256, 5, rmp.m_rtFormat, true);
+ true,
+ 1,
+ "tinyStorage");
+
+ rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512,
+ 256,
+ 10,
+ rmp.m_rtFormat,
+ true,
+ true,
+ true,
+ 1,
+ "primaryTexture");
+
+ rmp.m_fontTexturesParams = yg::ResourceManager::TexturePoolParams(512,
+ 256,
+ 5,
+ rmp.m_rtFormat,
+ true,
+ true,
+ true,
+ 1,
+ "fontTextures");
rmp.m_glyphCacheParams = yg::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
"fonts_whitelist.txt",
@@ -53,7 +85,7 @@ PartialRenderPolicy::PartialRenderPolicy(VideoTimer * videoTimer,
2,
1);
- rmp.m_isMergeable = true;
+ rmp.m_useSingleThreadedOGL = true;
rmp.m_useVA = !yg::gl::g_isBufferObjectsSupported;
m_resourceManager.reset(new yg::ResourceManager(rmp));
@@ -70,7 +102,7 @@ PartialRenderPolicy::PartialRenderPolicy(VideoTimer * videoTimer,
p.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID();
p.m_skinName = GetPlatform().SkinName();
p.m_visualScale = GetPlatform().VisualScale();
- p.m_isSynchronized = true;
+ p.m_isSynchronized = false;
p.m_useTinyStorage = true;
m_drawer.reset(new DrawerYG(p));
diff --git a/map/render_policy_mt.cpp b/map/render_policy_mt.cpp
index da5446a2f1..2a31ec0261 100644
--- a/map/render_policy_mt.cpp
+++ b/map/render_policy_mt.cpp
@@ -18,34 +18,65 @@ RenderPolicyMT::RenderPolicyMT(VideoTimer * videoTimer,
yg::ResourceManager::Params const & rmParams,
shared_ptr<yg::gl::RenderContext> const & primaryRC)
: RenderPolicy(primaryRC, false),
- m_DoAddCommand(true),
- m_DoSynchronize(true)
+ m_DoAddCommand(true)
{
yg::ResourceManager::Params rmp = rmParams;
- rmp.m_primaryStoragesParams = yg::ResourceManager::StoragePoolParams(500 * sizeof(yg::gl::Vertex),
- 100 * sizeof(unsigned short),
- 15,
- false);
-
- rmp.m_smallStoragesParams = yg::ResourceManager::StoragePoolParams(50 * sizeof(yg::gl::Vertex),
- 10 * sizeof(unsigned short),
- 100,
- false);
+ rmp.m_primaryStoragesParams = yg::ResourceManager::StoragePoolParams(5000 * sizeof(yg::gl::Vertex),
+ sizeof(yg::gl::Vertex),
+ 10000 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 7,
+ false,
+ 10,
+ "primaryStorage");
+
+ rmp.m_smallStoragesParams = yg::ResourceManager::StoragePoolParams(500 * sizeof(yg::gl::Vertex),
+ sizeof(yg::gl::Vertex),
+ 1000 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 7,
+ false,
+ 5,
+ "smallStorage");
rmp.m_blitStoragesParams = yg::ResourceManager::StoragePoolParams(10 * sizeof(yg::gl::AuxVertex),
+ sizeof(yg::gl::AuxVertex),
10 * sizeof(unsigned short),
- 50,
- true);
+ sizeof(unsigned short),
+ 7,
+ true,
+ 1,
+ "blitStorage");
rmp.m_tinyStoragesParams = yg::ResourceManager::StoragePoolParams(300 * sizeof(yg::gl::Vertex),
+ sizeof(yg::gl::Vertex),
600 * sizeof(unsigned short),
- 20,
- true);
-
- rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512, 256, 10, rmp.m_rtFormat, true);
-
- rmp.m_fontTexturesParams = yg::ResourceManager::TexturePoolParams(512, 256, 5, rmp.m_rtFormat, true);
+ sizeof(unsigned short),
+ 7,
+ true,
+ 1,
+ "tinyStorage");
+
+ rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512,
+ 256,
+ 7,
+ rmp.m_rtFormat,
+ true,
+ true,
+ true,
+ 1,
+ "primaryTexture");
+
+ rmp.m_fontTexturesParams = yg::ResourceManager::TexturePoolParams(512,
+ 256,
+ 7,
+ rmp.m_rtFormat,
+ true,
+ true,
+ true,
+ 1,
+ "fontTexture");
rmp.m_glyphCacheParams = yg::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
"fonts_whitelist.txt",
@@ -54,7 +85,7 @@ RenderPolicyMT::RenderPolicyMT(VideoTimer * videoTimer,
3,
1);
- rmp.m_isMergeable = false;
+ rmp.m_useSingleThreadedOGL = false;
rmp.m_useVA = !yg::gl::g_isBufferObjectsSupported;
rmp.fitIntoLimits();
@@ -73,7 +104,7 @@ RenderPolicyMT::RenderPolicyMT(VideoTimer * videoTimer,
p.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID();
p.m_skinName = GetPlatform().SkinName();
p.m_visualScale = GetPlatform().VisualScale();
- p.m_isSynchronized = true;
+ p.m_isSynchronized = false;
p.m_useTinyStorage = true;
m_drawer.reset(new DrawerYG(p));
@@ -121,8 +152,7 @@ void RenderPolicyMT::BeginFrame(shared_ptr<PaintEvent> const & e,
void RenderPolicyMT::EndFrame(shared_ptr<PaintEvent> const & e,
ScreenBase const & s)
{
- if (m_DoSynchronize)
- m_renderQueue->renderState().m_mutex->Unlock();
+ m_renderQueue->renderState().m_mutex->Unlock();
}
void RenderPolicyMT::DrawFrame(shared_ptr<PaintEvent> const & e,
@@ -137,8 +167,7 @@ void RenderPolicyMT::DrawFrame(shared_ptr<PaintEvent> const & e,
e->drawer()->screen()->clear(m_bgColor);
- if (m_DoSynchronize)
- m_renderQueue->renderState().m_mutex->Lock();
+ m_renderQueue->renderState().m_mutex->Lock();
if (m_renderQueue->renderState().m_actualTarget.get() != 0)
{
diff --git a/map/render_policy_mt.hpp b/map/render_policy_mt.hpp
index 11fb1e0625..abe5ca738a 100644
--- a/map/render_policy_mt.hpp
+++ b/map/render_policy_mt.hpp
@@ -16,7 +16,6 @@ protected:
scoped_ptr<RenderQueue> m_renderQueue;
bool m_DoAddCommand;
- bool m_DoSynchronize;
public:
diff --git a/map/render_policy_st.cpp b/map/render_policy_st.cpp
index fd97e327eb..7960803355 100644
--- a/map/render_policy_st.cpp
+++ b/map/render_policy_st.cpp
@@ -21,23 +21,51 @@ RenderPolicyST::RenderPolicyST(VideoTimer * videoTimer,
yg::ResourceManager::Params rmp = rmParams;
rmp.m_primaryStoragesParams = yg::ResourceManager::StoragePoolParams(50000 * sizeof(yg::gl::Vertex),
+ sizeof(yg::gl::Vertex),
10000 * sizeof(unsigned short),
+ sizeof(unsigned short),
15,
- false);
+ false,
+ 1,
+ "primaryStorage");
rmp.m_smallStoragesParams = yg::ResourceManager::StoragePoolParams(5000 * sizeof(yg::gl::Vertex),
+ sizeof(yg::gl::Vertex),
10000 * sizeof(unsigned short),
+ sizeof(unsigned short),
100,
- false);
+ false,
+ 1,
+ "smallStorage");
rmp.m_blitStoragesParams = yg::ResourceManager::StoragePoolParams(10 * sizeof(yg::gl::AuxVertex),
+ sizeof(yg::gl::AuxVertex),
10 * sizeof(unsigned short),
+ sizeof(unsigned short),
50,
- true);
-
- rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512, 256, 10, rmp.m_rtFormat, true);
-
- rmp.m_fontTexturesParams = yg::ResourceManager::TexturePoolParams(512, 256, 5, rmp.m_rtFormat, true);
+ true,
+ 1,
+ "blitStorage");
+
+ rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512,
+ 256,
+ 10,
+ rmp.m_rtFormat,
+ true,
+ true,
+ true,
+ 1,
+ "primaryTexture");
+
+ rmp.m_fontTexturesParams = yg::ResourceManager::TexturePoolParams(512,
+ 256,
+ 5,
+ rmp.m_rtFormat,
+ true,
+ true,
+ true,
+ 1,
+ "fontTexture");
rmp.m_glyphCacheParams = yg::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
"fonts_whitelist.txt",
@@ -47,7 +75,7 @@ RenderPolicyST::RenderPolicyST(VideoTimer * videoTimer,
GetPlatform().CpuCores());
- rmp.m_isMergeable = false;
+ rmp.m_useSingleThreadedOGL = false;
rmp.m_useVA = !yg::gl::g_isBufferObjectsSupported;
m_resourceManager.reset(new yg::ResourceManager(rmp));
diff --git a/map/tiling_render_policy_mt.cpp b/map/tiling_render_policy_mt.cpp
index 7a8e653e02..a7efc36a91 100644
--- a/map/tiling_render_policy_mt.cpp
+++ b/map/tiling_render_policy_mt.cpp
@@ -23,45 +23,89 @@ TilingRenderPolicyMT::TilingRenderPolicyMT(VideoTimer * videoTimer,
yg::ResourceManager::Params rmp = rmParams;
rmp.m_primaryStoragesParams = yg::ResourceManager::StoragePoolParams(50000 * sizeof(yg::gl::Vertex),
- 10000 * sizeof(unsigned short),
+ sizeof(yg::gl::Vertex),
+ 100000 * sizeof(unsigned short),
+ sizeof(unsigned short),
15,
- false);
+ false,
+ 1,
+ "primaryStorage");
rmp.m_smallStoragesParams = yg::ResourceManager::StoragePoolParams(5000 * sizeof(yg::gl::Vertex),
+ sizeof(yg::gl::Vertex),
10000 * sizeof(unsigned short),
+ sizeof(unsigned short),
100,
- false);
+ false,
+ 1,
+ "smallStorage");
rmp.m_blitStoragesParams = yg::ResourceManager::StoragePoolParams(10 * sizeof(yg::gl::AuxVertex),
+ sizeof(yg::gl::AuxVertex),
10 * sizeof(unsigned short),
+ sizeof(unsigned short),
50,
- true);
+ true,
+ 1,
+ "blitStorage");
rmp.m_multiBlitStoragesParams = yg::ResourceManager::StoragePoolParams(500 * sizeof(yg::gl::AuxVertex),
+ sizeof(yg::gl::AuxVertex),
500 * sizeof(unsigned short),
+ sizeof(unsigned short),
10,
- true);
+ true,
+ 1,
+ "multiBlitStorage");
rmp.m_tinyStoragesParams = yg::ResourceManager::StoragePoolParams(300 * sizeof(yg::gl::Vertex),
+ sizeof(yg::gl::Vertex),
600 * sizeof(unsigned short),
+ sizeof(unsigned short),
20,
- true);
-
- rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512, 256, 10, rmp.m_rtFormat, true);
-
- rmp.m_fontTexturesParams = yg::ResourceManager::TexturePoolParams(512, 256, 5, rmp.m_rtFormat, true);
+ true,
+ 1,
+ "tinyStorage");
+
+ rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512,
+ 256,
+ 10,
+ rmp.m_rtFormat,
+ true,
+ true,
+ true,
+ 1,
+ "primaryTexture");
+
+ rmp.m_fontTexturesParams = yg::ResourceManager::TexturePoolParams(512,
+ 256,
+ 5,
+ rmp.m_rtFormat,
+ true,
+ true,
+ true,
+ 1,
+ "fontTexture");
rmp.m_renderTargetTexturesParams = yg::ResourceManager::TexturePoolParams(GetPlatform().TileSize(),
GetPlatform().TileSize(),
GetPlatform().MaxTilesCount(),
rmp.m_rtFormat,
- true);
+ true,
+ true,
+ false,
+ 5,
+ "renderTargetTexture");
rmp.m_styleCacheTexturesParams = yg::ResourceManager::TexturePoolParams(rmp.m_fontTexturesParams.m_texWidth,
rmp.m_fontTexturesParams.m_texHeight,
2,
rmp.m_rtFormat,
- true);
+ true,
+ true,
+ true,
+ 1,
+ "styleCacheTexture");
rmp.m_glyphCacheParams = yg::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
"fonts_whitelist.txt",
@@ -70,7 +114,7 @@ TilingRenderPolicyMT::TilingRenderPolicyMT(VideoTimer * videoTimer,
GetPlatform().CpuCores() + 2,
GetPlatform().CpuCores());
- rmp.m_isMergeable = false;
+ rmp.m_useSingleThreadedOGL = false;
rmp.m_useVA = !yg::gl::g_isBufferObjectsSupported;
m_resourceManager.reset(new yg::ResourceManager(rmp));
diff --git a/map/tiling_render_policy_st.cpp b/map/tiling_render_policy_st.cpp
index f55947668d..786b94da9c 100644
--- a/map/tiling_render_policy_st.cpp
+++ b/map/tiling_render_policy_st.cpp
@@ -25,34 +25,79 @@ TilingRenderPolicyST::TilingRenderPolicyST(VideoTimer * videoTimer,
yg::ResourceManager::Params rmp = rmParams;
rmp.m_primaryStoragesParams = yg::ResourceManager::StoragePoolParams(50000 * sizeof(yg::gl::Vertex),
+ sizeof(yg::gl::Vertex),
10000 * sizeof(unsigned short),
+ sizeof(unsigned short),
15,
- false);
+ false,
+ 1,
+ "primaryStorage");
rmp.m_smallStoragesParams = yg::ResourceManager::StoragePoolParams(5000 * sizeof(yg::gl::Vertex),
+ sizeof(yg::gl::Vertex),
10000 * sizeof(unsigned short),
+ sizeof(unsigned short),
100,
- false);
+ false,
+ 1,
+ "smallStorage");
rmp.m_blitStoragesParams = yg::ResourceManager::StoragePoolParams(10 * sizeof(yg::gl::AuxVertex),
+ sizeof(yg::gl::AuxVertex),
10 * sizeof(unsigned short),
+ sizeof(unsigned short),
50,
- true);
+ true,
+ 1,
+ "blitStorage");
rmp.m_multiBlitStoragesParams = yg::ResourceManager::StoragePoolParams(500 * sizeof(yg::gl::AuxVertex),
+ sizeof(yg::gl::AuxVertex),
500 * sizeof(unsigned short),
+ sizeof(unsigned short),
10,
- true);
-
- rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512, 256, 10, rmp.m_rtFormat, true);
-
- rmp.m_fontTexturesParams = yg::ResourceManager::TexturePoolParams(512, 256, 5, rmp.m_rtFormat, true);
+ true,
+ 1,
+ "multiBlitStorage");
+
+ rmp.m_tinyStoragesParams = yg::ResourceManager::StoragePoolParams(300 * sizeof(yg::gl::Vertex),
+ sizeof(yg::gl::Vertex),
+ 600 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 20,
+ true,
+ 1,
+ "tinyStorage");
+
+ rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512,
+ 256,
+ 10,
+ rmp.m_rtFormat,
+ true,
+ true,
+ true,
+ 1,
+ "primaryTexture");
+
+ rmp.m_fontTexturesParams = yg::ResourceManager::TexturePoolParams(512,
+ 256,
+ 5,
+ rmp.m_rtFormat,
+ true,
+ true,
+ true,
+ 1,
+ "fontTexture");
rmp.m_renderTargetTexturesParams = yg::ResourceManager::TexturePoolParams(GetPlatform().TileSize(),
GetPlatform().TileSize(),
GetPlatform().MaxTilesCount(),
rmp.m_rtFormat,
- true);
+ true,
+ true,
+ false,
+ 5,
+ "renderTargetTexture");
rmp.m_glyphCacheParams = yg::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
"fonts_whitelist.txt",
@@ -62,7 +107,7 @@ TilingRenderPolicyST::TilingRenderPolicyST(VideoTimer * videoTimer,
GetPlatform().CpuCores());
- rmp.m_isMergeable = false;
+ rmp.m_useSingleThreadedOGL = false;
rmp.m_useVA = !yg::gl::g_isBufferObjectsSupported;
m_resourceManager.reset(new yg::ResourceManager(rmp));
@@ -80,6 +125,7 @@ TilingRenderPolicyST::TilingRenderPolicyST(VideoTimer * videoTimer,
p.m_skinName = GetPlatform().SkinName();
p.m_visualScale = GetPlatform().VisualScale();
p.m_isSynchronized = true;
+ p.m_useTinyStorage = true;
m_drawer.reset(new DrawerYG(p));
diff --git a/platform/platform.hpp b/platform/platform.hpp
index ad745ae478..1b1b57aca8 100644
--- a/platform/platform.hpp
+++ b/platform/platform.hpp
@@ -77,6 +77,8 @@ public:
int MaxTilesCount() const;
+ int VideoMemoryLimit() const;
+
string DeviceName() const;
int ScaleEtalonSize() const;
diff --git a/platform/platform_android.cpp b/platform/platform_android.cpp
index 3665b295e6..7295f80bf0 100644
--- a/platform/platform_android.cpp
+++ b/platform/platform_android.cpp
@@ -123,6 +123,11 @@ int Platform::MaxTilesCount() const
return 120;
}
+int Platform::VideoMemoryLimit() const
+{
+ return 10 * 1024 * 1024;
+}
+
bool Platform::GetFileSize(string const & file, uint64_t & size) const
{
try
diff --git a/platform/platform_ios.mm b/platform/platform_ios.mm
index 21e5714762..73ba4316a4 100644
--- a/platform/platform_ios.mm
+++ b/platform/platform_ios.mm
@@ -25,8 +25,6 @@
#import <UIKit/UIScreen.h>
#import <UIKit/UIScreenMode.h>
-
-
class Platform::PlatformImpl
{
public:
@@ -34,6 +32,7 @@ public:
int m_scaleEtalonSize;
string m_skinName;
string m_deviceName;
+ int m_videoMemoryLimit;
};
Platform::Platform()
@@ -55,6 +54,7 @@ Platform::Platform()
// Hardcoding screen resolution depending on the device we are running.
m_impl->m_visualScale = 1.0;
m_impl->m_skinName = "basic.skn";
+ m_impl->m_videoMemoryLimit = 8 * 1024 * 1024;
// Calculating resolution
UIDevice * device = [UIDevice currentDevice];
@@ -178,6 +178,11 @@ int Platform::ScaleEtalonSize() const
return m_impl->m_scaleEtalonSize;
}
+int Platform::VideoMemoryLimit() const
+{
+ return m_impl->m_videoMemoryLimit;
+}
+
int Platform::MaxTilesCount() const
{
return 60;
diff --git a/platform/platform_qt.cpp b/platform/platform_qt.cpp
index 8df08314cf..dc0b649fa1 100644
--- a/platform/platform_qt.cpp
+++ b/platform/platform_qt.cpp
@@ -76,6 +76,11 @@ int Platform::ScaleEtalonSize() const
return 512 + 256;
}
+int Platform::VideoMemoryLimit() const
+{
+ return 20 * 1024 * 1024;
+}
+
///////////////////////////////////////////////////////////////////////////////
extern "C" Platform & GetPlatform()
{
diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp
index ddf1d49ec4..fd14e51682 100644
--- a/qt/draw_widget.cpp
+++ b/qt/draw_widget.cpp
@@ -210,7 +210,7 @@ namespace qt
yg::ResourceManager::Params rmParams;
rmParams.m_rtFormat = yg::Rt8Bpp;
- rmParams.m_videoMemoryLimit = 30 * 1024 * 1024;
+ rmParams.m_videoMemoryLimit = GetPlatform().VideoMemoryLimit();
m_framework->SetRenderPolicy(CreateRenderPolicy(m_videoTimer.get(), params, rmParams, primaryRC));
diff --git a/qt_tstfrm/tstwidgets.cpp b/qt_tstfrm/tstwidgets.cpp
index 972a260fd2..f117ac8f01 100644
--- a/qt_tstfrm/tstwidgets.cpp
+++ b/qt_tstfrm/tstwidgets.cpp
@@ -46,28 +46,60 @@ void GLDrawWidget::initializeGL()
rmp.m_videoMemoryLimit = 20 * 1024 * 1024;
rmp.m_primaryStoragesParams = yg::ResourceManager::StoragePoolParams(30000 * sizeof(yg::gl::Vertex),
+ sizeof(yg::gl::Vertex),
50000 * sizeof(unsigned short),
+ sizeof(unsigned short),
20,
- false);
+ false,
+ 1,
+ "primaryStorage");
rmp.m_smallStoragesParams = yg::ResourceManager::StoragePoolParams(3000 * sizeof(yg::gl::Vertex),
+ sizeof(yg::gl::Vertex),
5000 * sizeof(unsigned short),
+ sizeof(unsigned short),
100,
- false);
+ false,
+ 1,
+ "smallStorage");
rmp.m_blitStoragesParams = yg::ResourceManager::StoragePoolParams(10 * sizeof(yg::gl::AuxVertex),
+ sizeof(yg::gl::AuxVertex),
10 * sizeof(unsigned short),
+ sizeof(unsigned short),
30,
- true);
+ true,
+ 1,
+ "blitStorage");
rmp.m_multiBlitStoragesParams = yg::ResourceManager::StoragePoolParams(500 * sizeof(yg::gl::AuxVertex),
+ sizeof(yg::gl::AuxVertex),
500 * sizeof(unsigned short),
+ sizeof(unsigned short),
10,
- true);
-
- rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512, 256, 10, rmp.m_rtFormat, true);
-
- rmp.m_fontTexturesParams = yg::ResourceManager::TexturePoolParams(512, 256, 5, rmp.m_rtFormat, true);
+ true,
+ 1,
+ "multiBlitStorage");
+
+ rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512,
+ 256,
+ 10,
+ rmp.m_rtFormat,
+ true,
+ true,
+ true,
+ 1,
+ "primaryTexture");
+
+ rmp.m_fontTexturesParams = yg::ResourceManager::TexturePoolParams(512,
+ 256,
+ 5,
+ rmp.m_rtFormat,
+ true,
+ true,
+ true,
+ 1,
+ "fontTexture");
rmp.m_glyphCacheParams = yg::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
"fonts_whitelist.txt",
@@ -76,7 +108,7 @@ void GLDrawWidget::initializeGL()
1,
0);
- rmp.m_isMergeable = false;
+ rmp.m_useSingleThreadedOGL = false;
rmp.m_useVA = !yg::gl::g_isBufferObjectsSupported;
rmp.m_rtFormat = yg::Rt8Bpp;
diff --git a/yg/base_texture.cpp b/yg/base_texture.cpp
index fc7d3a5bf5..4826433d85 100644
--- a/yg/base_texture.cpp
+++ b/yg/base_texture.cpp
@@ -31,13 +31,13 @@ namespace yg
}
BaseTexture::BaseTexture(m2::PointU const & size)
- : m_width(size.x), m_height(size.y), m_id(0), m_hasID(false)
+ : m_id(0), m_hasID(false), m_width(size.x), m_height(size.y)
{
// init();
}
BaseTexture::BaseTexture(unsigned width, unsigned height)
- : m_width(width), m_height(height), m_id(0), m_hasID(false)
+ : m_id(0), m_hasID(false), m_width(width), m_height(height)
{
// init();
}
diff --git a/yg/renderbuffer.cpp b/yg/renderbuffer.cpp
index d0450dee83..d65ae5b710 100644
--- a/yg/renderbuffer.cpp
+++ b/yg/renderbuffer.cpp
@@ -58,7 +58,7 @@ namespace yg
}
RenderBuffer::RenderBuffer(size_t width, size_t height, bool isDepthBuffer)
- : m_isDepthBuffer(isDepthBuffer), m_width(width), m_height(height), m_hasID(false), m_id(0)
+ : m_hasID(false), m_id(0), m_isDepthBuffer(isDepthBuffer), m_width(width), m_height(height)
{}
RenderBuffer::~RenderBuffer()
diff --git a/yg/resource_manager.cpp b/yg/resource_manager.cpp
index dc6c30847b..bc589f4832 100644
--- a/yg/resource_manager.cpp
+++ b/yg/resource_manager.cpp
@@ -31,19 +31,19 @@ namespace yg
return shared_ptr<gl::BaseTexture>(new TDynamicTexture(m_w, m_h));
}
- TStorageFactory::TStorageFactory(size_t vbSize, size_t ibSize, bool useVA, bool isMergeable, char const * resName)
+ TStorageFactory::TStorageFactory(size_t vbSize, size_t ibSize, bool useVA, bool useSingleThreadedOGL, char const * resName)
: BasePoolElemFactory(resName, vbSize + ibSize),
m_vbSize(vbSize),
m_ibSize(ibSize),
m_useVA(useVA),
- m_isMergeable(isMergeable)
+ m_useSingleThreadedOGL(useSingleThreadedOGL)
{}
gl::Storage const TStorageFactory::Create()
{
gl::Storage res(m_vbSize, m_ibSize, m_useVA);
- if (m_isMergeable)
+ if (m_useSingleThreadedOGL)
{
res.m_indices->lock();
res.m_vertices->lock();
@@ -54,7 +54,7 @@ namespace yg
void TStorageFactory::BeforeMerge(gl::Storage const & e)
{
- if (m_isMergeable)
+ if (m_useSingleThreadedOGL)
{
if (e.m_indices->isLocked())
e.m_indices->unlock();
@@ -68,14 +68,40 @@ namespace yg
}
}
- ResourceManager::StoragePoolParams::StoragePoolParams()
- : m_vbSize(0), m_ibSize(0), m_storagesCount(0), m_isFixed(true)
+ ResourceManager::StoragePoolParams::StoragePoolParams(string const & poolName)
+ : m_vbSize(0),
+ m_vertexSize(0),
+ m_ibSize(0),
+ m_indexSize(0),
+ m_storagesCount(0),
+ m_isFixed(true),
+ m_scalePriority(0),
+ m_poolName(poolName)
{}
- ResourceManager::StoragePoolParams::StoragePoolParams(size_t vbSize, size_t ibSize, size_t storagesCount, bool isFixed)
- : m_vbSize(vbSize), m_ibSize(ibSize), m_storagesCount(storagesCount), m_isFixed(isFixed)
+ ResourceManager::StoragePoolParams::StoragePoolParams(size_t vbSize,
+ size_t vertexSize,
+ size_t ibSize,
+ size_t indexSize,
+ size_t storagesCount,
+ bool isFixed,
+ int scalePriority,
+ string const & poolName)
+ : m_vbSize(vbSize),
+ m_vertexSize(vertexSize),
+ m_ibSize(ibSize),
+ m_indexSize(indexSize),
+ m_storagesCount(storagesCount),
+ m_isFixed(isFixed),
+ m_scalePriority(scalePriority),
+ m_poolName(poolName)
{}
+ bool ResourceManager::StoragePoolParams::isFixed() const
+ {
+ return m_isFixed;
+ }
+
bool ResourceManager::StoragePoolParams::isValid() const
{
return m_vbSize && m_ibSize && m_storagesCount;
@@ -88,18 +114,68 @@ namespace yg
void ResourceManager::StoragePoolParams::scaleMemoryUsage(double k)
{
+ int oldMemoryUsage = memoryUsage();
+ int oldVBSize = m_vbSize;
+ int oldIBSize = m_ibSize;
+
m_vbSize *= k;
m_ibSize *= k;
+ LOG(LINFO, ("resizing ", m_poolName));
+ LOG(LINFO, (" from : ", oldVBSize / m_vertexSize, " vertices, ", oldIBSize / m_indexSize, " indices, ", m_storagesCount, " storages, ", oldMemoryUsage, " bytes total"));
+ LOG(LINFO, (" to : ", m_vbSize / m_vertexSize, " vertices, ", m_ibSize / m_indexSize, " indices, ", m_storagesCount, " storages, ", memoryUsage(), " bytes total"));
+ }
+
+ void ResourceManager::StoragePoolParams::distributeFreeMemory(int freeVideoMemory)
+ {
+ if (!isFixed())
+ {
+ double k = (freeVideoMemory * m_scaleFactor + memoryUsage()) / memoryUsage();
+ scaleMemoryUsage(k);
+ }
+ else
+ {
+ if (m_vbSize && m_vertexSize && m_ibSize && m_indexSize)
+ LOG(LINFO, (m_poolName, " : ", m_vbSize / m_vertexSize, " vertices, ", m_ibSize / m_indexSize, " indices, ", m_storagesCount, " storages, ", memoryUsage(), " bytes total"));
+ }
}
- ResourceManager::TexturePoolParams::TexturePoolParams()
- : m_texWidth(0), m_texHeight(0), m_texCount(0), m_rtFormat(yg::Rt8Bpp), m_isFixed(true)
+ ResourceManager::TexturePoolParams::TexturePoolParams(string const & poolName)
+ : m_texWidth(0),
+ m_texHeight(0),
+ m_texCount(0),
+ m_rtFormat(yg::Rt8Bpp),
+ m_isWidthFixed(true),
+ m_isHeightFixed(true),
+ m_isCountFixed(true),
+ m_scalePriority(0),
+ m_poolName(poolName)
{}
- ResourceManager::TexturePoolParams::TexturePoolParams(size_t texWidth, size_t texHeight, size_t texCount, yg::RtFormat rtFormat, bool isFixed)
- : m_texWidth(texWidth), m_texHeight(texHeight), m_texCount(texCount), m_rtFormat(rtFormat), m_isFixed(isFixed)
+ ResourceManager::TexturePoolParams::TexturePoolParams(size_t texWidth,
+ size_t texHeight,
+ size_t texCount,
+ yg::RtFormat rtFormat,
+ bool isWidthFixed,
+ bool isHeightFixed,
+ bool isCountFixed,
+ int scalePriority,
+ string const & poolName)
+ : m_texWidth(texWidth),
+ m_texHeight(texHeight),
+ m_texCount(texCount),
+ m_rtFormat(rtFormat),
+ m_isWidthFixed(isWidthFixed),
+ m_isHeightFixed(isHeightFixed),
+ m_isCountFixed(isCountFixed),
+ m_scalePriority(scalePriority),
+ m_poolName(poolName)
{}
+ bool ResourceManager::TexturePoolParams::isFixed() const
+ {
+ return m_isWidthFixed && m_isHeightFixed && m_isCountFixed;
+ }
+
bool ResourceManager::TexturePoolParams::isValid() const
{
return m_texWidth && m_texHeight && m_texCount;
@@ -121,47 +197,74 @@ namespace yg
return m_texWidth * m_texHeight * pixelSize * m_texCount;
}
- void ResourceManager::TexturePoolParams::scaleMemoryUsage(double k)
+ void ResourceManager::TexturePoolParams::distributeFreeMemory(int freeVideoMemory)
{
- if (k > 1)
+ if (!isFixed())
{
- while (k > 2)
- {
- if (k > 2)
- {
- m_texWidth *= 2;
- k /= 2;
- }
-
- if (k > 2)
- {
- m_texHeight *= 2;
- k /= 2;
- }
- }
+ double k = (freeVideoMemory * m_scaleFactor + memoryUsage()) / memoryUsage();
+ scaleMemoryUsage(k);
}
else
{
- if (k < 1)
+ if (m_texWidth && m_texHeight && m_texCount)
+ LOG(LINFO, (m_poolName, " : ", m_texWidth, "x", m_texHeight, ", ", m_texCount, " textures, ", memoryUsage(), " bytes total"));
+ }
+ }
+
+ void ResourceManager::TexturePoolParams::scaleMemoryUsage(double k)
+ {
+ int oldTexCount = m_texCount;
+ int oldTexWidth = m_texWidth;
+ int oldTexHeight = m_texHeight;
+ int oldMemoryUsage = memoryUsage();
+
+ if (!m_isWidthFixed || !m_isHeightFixed)
+ {
+ if (k > 1)
{
- while (k < 1)
+ while (k > 2)
{
- if (k < 0.5)
+ if ((k > 2) && (!m_isWidthFixed))
{
- m_texHeight /= 2;
- k *= 2;
+ m_texWidth *= 2;
+ k /= 2;
}
- if (k < 0.5)
+ if ((k > 2) && (!m_isHeightFixed))
+ {
+ m_texHeight *= 2;
+ k /= 2;
+ }
+ }
+ }
+ else
+ {
+ if (k < 1)
+ {
+ while (k < 1)
{
- m_texWidth /= 2;
- k *= 2;
+ if ((k < 0.5) && (!m_isWidthFixed))
+ {
+ m_texHeight /= 2;
+ k *= 2;
+ }
+
+ if ((k < 0.5) && (!m_isHeightFixed))
+ {
+ m_texWidth /= 2;
+ k *= 2;
+ }
}
}
}
}
- m_texCount *= k;
+ if (!m_isCountFixed)
+ m_texCount *= k;
+
+ LOG(LINFO, ("scaling memory usage for ", m_poolName));
+ LOG(LINFO, (" from : ", oldTexWidth, "x", oldTexHeight, ", ", oldTexCount, " textures, ", oldMemoryUsage, " bytes total"));
+ LOG(LINFO, (" to : ", m_texWidth, "x", m_texHeight, ", ", m_texCount, " textures, ", memoryUsage(), " bytes total"));
}
ResourceManager::GlyphCacheParams::GlyphCacheParams()
@@ -186,81 +289,86 @@ namespace yg
ResourceManager::Params::Params()
: m_rtFormat(yg::Rt8Bpp),
- m_isMergeable(false),
+ m_useSingleThreadedOGL(false),
m_useVA(true),
- m_videoMemoryLimit(0)
+ m_videoMemoryLimit(0),
+ m_primaryStoragesParams("primaryStorage"),
+ m_smallStoragesParams("smallStorage"),
+ m_blitStoragesParams("blitStorage"),
+ m_multiBlitStoragesParams("multiBlitStorage"),
+ m_tinyStoragesParams("tinyStorage"),
+ m_primaryTexturesParams("primaryTexture"),
+ m_fontTexturesParams("fontTexture"),
+ m_renderTargetTexturesParams("renderTargetTexture"),
+ m_styleCacheTexturesParams("styleCacheTexture")
{}
void ResourceManager::Params::fitIntoLimits()
{
- size_t storageMemoryUsage = m_primaryStoragesParams.memoryUsage()
- + m_smallStoragesParams.memoryUsage()
- + m_blitStoragesParams.memoryUsage()
- + m_multiBlitStoragesParams.memoryUsage()
- + m_tinyStoragesParams.memoryUsage();
+ initScaleWeights();
- size_t fixedStorageMemoryUsage = (m_primaryStoragesParams.m_isFixed ? m_primaryStoragesParams.memoryUsage() : 0)
- + (m_smallStoragesParams.m_isFixed ? m_smallStoragesParams.memoryUsage() : 0)
- + (m_blitStoragesParams.m_isFixed ? m_blitStoragesParams.memoryUsage() : 0)
- + (m_multiBlitStoragesParams.m_isFixed ? m_multiBlitStoragesParams.memoryUsage() : 0)
- + (m_tinyStoragesParams.m_isFixed ? m_tinyStoragesParams.memoryUsage() : 0);
+ int oldMemoryUsage = memoryUsage();
- size_t textureMemoryUsage = m_primaryTexturesParams.memoryUsage()
- + m_fontTexturesParams.memoryUsage()
- + m_renderTargetTexturesParams.memoryUsage()
- + m_styleCacheTexturesParams.memoryUsage();
+ int videoMemoryLimit = m_videoMemoryLimit;
- size_t fixedTextureMemoryUsage = (m_primaryTexturesParams.m_isFixed ? m_primaryTexturesParams.memoryUsage() : 0)
- + (m_fontTexturesParams.m_isFixed ? m_fontTexturesParams.memoryUsage() : 0)
- + (m_renderTargetTexturesParams.m_isFixed ? m_renderTargetTexturesParams.memoryUsage() : 0)
- + (m_styleCacheTexturesParams.m_isFixed ? m_styleCacheTexturesParams.memoryUsage() : 0);
-
- size_t videoMemoryLimit = m_videoMemoryLimit;
if (videoMemoryLimit == 0)
- videoMemoryLimit = storageMemoryUsage + textureMemoryUsage;
+ {
+ videoMemoryLimit = memoryUsage();
+ LOG(LINFO, ("videoMemoryLimit is not set. will not scale resource usage."));
+ }
- double k = ((int)videoMemoryLimit - (int)fixedStorageMemoryUsage - (int)fixedTextureMemoryUsage)* 1.0 / ((int)storageMemoryUsage + (int)textureMemoryUsage - (int)fixedStorageMemoryUsage - (int)fixedTextureMemoryUsage);
+ if (videoMemoryLimit < fixedMemoryUsage())
+ {
+ LOG(LINFO, ("videoMemoryLimit ", videoMemoryLimit," is less than an amount of fixed resources ", fixedMemoryUsage()));
+ videoMemoryLimit = memoryUsage();
+ }
+
+ int freeVideoMemory = m_videoMemoryLimit - oldMemoryUsage;
- if (k < 0)
- k = 1;
+ /// distributing free memory according to the weights
+ distributeFreeMemory(freeVideoMemory);
- scaleMemoryUsage(k);
+ LOG(LINFO, ("resizing from ", oldMemoryUsage, " bytes to ", memoryUsage(), " bytes of video memory"));
+ }
- storageMemoryUsage = m_primaryStoragesParams.memoryUsage()
+ int ResourceManager::Params::memoryUsage() const
+ {
+ return m_primaryStoragesParams.memoryUsage()
+ m_smallStoragesParams.memoryUsage()
+ m_blitStoragesParams.memoryUsage()
+ m_multiBlitStoragesParams.memoryUsage()
- + m_tinyStoragesParams.memoryUsage();
-
- textureMemoryUsage = m_primaryTexturesParams.memoryUsage()
+ + m_tinyStoragesParams.memoryUsage()
+ + m_primaryTexturesParams.memoryUsage()
+ m_fontTexturesParams.memoryUsage()
+ m_renderTargetTexturesParams.memoryUsage()
+ m_styleCacheTexturesParams.memoryUsage();
+ }
- LOG(LINFO, ("allocating ", storageMemoryUsage + textureMemoryUsage, " bytes of videoMemory, with initial limit ", m_videoMemoryLimit));
+ int ResourceManager::Params::fixedMemoryUsage() const
+ {
+ return (m_primaryStoragesParams.isFixed() ? m_primaryStoragesParams.memoryUsage() : 0)
+ + (m_smallStoragesParams.isFixed() ? m_smallStoragesParams.memoryUsage() : 0)
+ + (m_blitStoragesParams.isFixed() ? m_blitStoragesParams.memoryUsage() : 0)
+ + (m_multiBlitStoragesParams.isFixed() ? m_multiBlitStoragesParams.memoryUsage() : 0)
+ + (m_tinyStoragesParams.isFixed() ? m_tinyStoragesParams.memoryUsage() : 0)
+ + (m_primaryTexturesParams.isFixed() ? m_primaryTexturesParams.memoryUsage() : 0)
+ + (m_fontTexturesParams.isFixed() ? m_fontTexturesParams.memoryUsage() : 0)
+ + (m_renderTargetTexturesParams.isFixed() ? m_renderTargetTexturesParams.memoryUsage() : 0)
+ + (m_styleCacheTexturesParams.isFixed() ? m_styleCacheTexturesParams.memoryUsage() : 0);
}
- void ResourceManager::Params::scaleMemoryUsage(double k)
+ void ResourceManager::Params::distributeFreeMemory(int freeVideoMemory)
{
- if (!m_primaryStoragesParams.m_isFixed)
- m_primaryStoragesParams.scaleMemoryUsage(k);
- if (!m_smallStoragesParams.m_isFixed)
- m_smallStoragesParams.scaleMemoryUsage(k);
- if (!m_blitStoragesParams.m_isFixed)
- m_blitStoragesParams.scaleMemoryUsage(k);
- if (!m_multiBlitStoragesParams.m_isFixed)
- m_multiBlitStoragesParams.scaleMemoryUsage(k);
- if (!m_tinyStoragesParams.m_isFixed)
- m_tinyStoragesParams.scaleMemoryUsage(k);
+ m_primaryStoragesParams.distributeFreeMemory(freeVideoMemory);
+ m_smallStoragesParams.distributeFreeMemory(freeVideoMemory);
+ m_blitStoragesParams.distributeFreeMemory(freeVideoMemory);
+ m_multiBlitStoragesParams.distributeFreeMemory(freeVideoMemory);
+ m_tinyStoragesParams.distributeFreeMemory(freeVideoMemory);
- if (!m_primaryTexturesParams.m_isFixed)
- m_primaryTexturesParams.scaleMemoryUsage(k);
- if (!m_fontTexturesParams.m_isFixed)
- m_fontTexturesParams.scaleMemoryUsage(k);
- if (!m_renderTargetTexturesParams.m_isFixed)
- m_renderTargetTexturesParams.scaleMemoryUsage(k);
- if (!m_styleCacheTexturesParams.m_isFixed)
- m_styleCacheTexturesParams.scaleMemoryUsage(k);
+ m_primaryTexturesParams.distributeFreeMemory(freeVideoMemory);
+ m_fontTexturesParams.distributeFreeMemory(freeVideoMemory);
+ m_renderTargetTexturesParams.distributeFreeMemory(freeVideoMemory);
+ m_styleCacheTexturesParams.distributeFreeMemory(freeVideoMemory);
}
ResourceManager::ResourceManager(Params const & p)
@@ -268,21 +376,47 @@ namespace yg
{
initGlyphCaches(p.m_glyphCacheParams);
- initPrimaryStorage(p.m_primaryStoragesParams);
- initSmallStorage(p.m_smallStoragesParams);
- initBlitStorage(p.m_blitStoragesParams);
- initMultiBlitStorage(p.m_multiBlitStoragesParams);
- initTinyStorage(p.m_tinyStoragesParams);
+ initStoragePool(p.m_primaryStoragesParams, m_primaryStorages);
+ initStoragePool(p.m_smallStoragesParams, m_smallStorages);
+ initStoragePool(p.m_blitStoragesParams, m_blitStorages);
+ initStoragePool(p.m_multiBlitStoragesParams, m_multiBlitStorages);
+ initStoragePool(p.m_tinyStoragesParams, m_tinyStorages);
- initPrimaryTextures(p.m_primaryTexturesParams);
- initFontTextures(p.m_fontTexturesParams);
- initRenderTargetTextures(p.m_renderTargetTexturesParams);
- initStyleCacheTextures(p.m_styleCacheTexturesParams);
+ initTexturePool(p.m_primaryTexturesParams, m_primaryTextures);
+ initTexturePool(p.m_fontTexturesParams, m_fontTextures);
+ initTexturePool(p.m_renderTargetTexturesParams, m_renderTargets);
+ initTexturePool(p.m_styleCacheTexturesParams, m_styleCacheTextures);
if (p.m_useVA)
LOG(LINFO, ("buffer objects are unsupported. using client vertex array instead."));
}
+ void ResourceManager::Params::initScaleWeights()
+ {
+ double prioritySum = (m_primaryStoragesParams.isFixed() ? 0 : m_primaryStoragesParams.m_scalePriority)
+ + (m_smallStoragesParams.isFixed() ? 0 : m_smallStoragesParams.m_scalePriority)
+ + (m_blitStoragesParams.isFixed() ? 0 : m_blitStoragesParams.m_scalePriority)
+ + (m_multiBlitStoragesParams.isFixed() ? 0 : m_multiBlitStoragesParams.m_scalePriority)
+ + (m_tinyStoragesParams.isFixed() ? 0 : m_tinyStoragesParams.m_scalePriority)
+ + (m_primaryTexturesParams.isFixed() ? 0 : m_primaryTexturesParams.m_scalePriority)
+ + (m_fontTexturesParams.isFixed() ? 0 : m_fontTexturesParams.m_scalePriority)
+ + (m_renderTargetTexturesParams.isFixed() ? 0 : m_renderTargetTexturesParams.m_scalePriority)
+ + (m_styleCacheTexturesParams.isFixed() ? 0 : m_styleCacheTexturesParams.m_scalePriority);
+
+ if (prioritySum == 0)
+ return;
+
+ m_primaryStoragesParams.m_scaleFactor = m_primaryStoragesParams.m_scalePriority / prioritySum;
+ m_smallStoragesParams.m_scaleFactor = m_smallStoragesParams.m_scalePriority / prioritySum;
+ m_blitStoragesParams.m_scaleFactor = m_blitStoragesParams.m_scalePriority / prioritySum;
+ m_multiBlitStoragesParams.m_scaleFactor = m_multiBlitStoragesParams.m_scalePriority / prioritySum;
+ m_tinyStoragesParams.m_scaleFactor = m_tinyStoragesParams.m_scalePriority / prioritySum;
+ m_primaryTexturesParams.m_scaleFactor = m_primaryTexturesParams.m_scalePriority / prioritySum;
+ m_fontTexturesParams.m_scaleFactor = m_fontTexturesParams.m_scalePriority / prioritySum;
+ m_renderTargetTexturesParams.m_scaleFactor = m_renderTargetTexturesParams.m_scalePriority / prioritySum;
+ m_styleCacheTexturesParams.m_scaleFactor = m_styleCacheTexturesParams.m_scalePriority / prioritySum;
+ }
+
void ResourceManager::initGlyphCaches(GlyphCacheParams const & p)
{
if (p.m_glyphCacheMemoryLimit && p.m_glyphCacheCount)
@@ -296,101 +430,25 @@ namespace yg
LOG(LERROR, ("no params to init glyph caches."));
}
- void ResourceManager::initPrimaryStorage(StoragePoolParams const & p)
- {
- if (p.isValid())
- {
- if (m_params.m_isMergeable)
- m_primaryStorages.reset(new TMergeableStoragePoolImpl(new TMergeableStoragePoolTraits(TStorageFactory(p.m_vbSize, p.m_ibSize, m_params.m_useVA, m_params.m_isMergeable, "primaryStorage"), p.m_storagesCount)));
- else
- m_primaryStorages.reset(new TNonMergeableStoragePoolImpl(new TNonMergeableStoragePoolTraits(TStorageFactory(p.m_vbSize, p.m_ibSize, m_params.m_useVA, m_params.m_isMergeable, "primaryStorage"), p.m_storagesCount)));
- }
- else
- LOG(LINFO, ("no primary storages"));
- }
-
- void ResourceManager::initSmallStorage(StoragePoolParams const & p)
- {
- if (p.isValid())
- {
- if (m_params.m_isMergeable)
- m_smallStorages.reset(new TMergeableStoragePoolImpl(new TMergeableStoragePoolTraits(TStorageFactory(p.m_vbSize, p.m_ibSize, m_params.m_useVA, m_params.m_isMergeable, "smallStorage"), p.m_storagesCount)));
- else
- m_smallStorages.reset(new TNonMergeableStoragePoolImpl(new TNonMergeableStoragePoolTraits(TStorageFactory(p.m_vbSize, p.m_ibSize, m_params.m_useVA, m_params.m_isMergeable, "smallStorage"), p.m_storagesCount)));
- }
- else
- LOG(LINFO, ("no small storages"));
- }
-
- void ResourceManager::initBlitStorage(StoragePoolParams const & p)
- {
- if (p.isValid())
- {
- if (m_params.m_isMergeable)
- m_blitStorages.reset(new TMergeableStoragePoolImpl(new TMergeableStoragePoolTraits(TStorageFactory(p.m_vbSize, p.m_ibSize, m_params.m_useVA, m_params.m_isMergeable, "blitStorage"), p.m_storagesCount)));
- else
- m_blitStorages.reset(new TNonMergeableStoragePoolImpl(new TNonMergeableStoragePoolTraits(TStorageFactory(p.m_vbSize, p.m_ibSize, m_params.m_useVA, m_params.m_isMergeable, "blitStorage"), p.m_storagesCount)));
- }
- else
- LOG(LINFO, ("no blit storages"));
- }
-
- void ResourceManager::initMultiBlitStorage(StoragePoolParams const & p)
- {
- if (p.isValid())
- {
- if (m_params.m_isMergeable)
- m_multiBlitStorages.reset(new TMergeableStoragePoolImpl(new TMergeableStoragePoolTraits(TStorageFactory(p.m_vbSize, p.m_ibSize, m_params.m_useVA, m_params.m_isMergeable, "multiBlitStorage"), p.m_storagesCount)));
- else
- m_multiBlitStorages.reset(new TNonMergeableStoragePoolImpl(new TNonMergeableStoragePoolTraits(TStorageFactory(p.m_vbSize, p.m_ibSize, m_params.m_useVA, m_params.m_isMergeable, "multiBlitStorage"), p.m_storagesCount)));
- }
- else
- LOG(LINFO, ("no multiBlit storages"));
- }
-
- void ResourceManager::initTinyStorage(StoragePoolParams const & p)
+ void ResourceManager::initStoragePool(StoragePoolParams const & p, auto_ptr<TStoragePool> & pool)
{
if (p.isValid())
{
- if (m_params.m_isMergeable)
- m_tinyStorages.reset(new TMergeableStoragePoolImpl(new TMergeableStoragePoolTraits(TStorageFactory(p.m_vbSize, p.m_ibSize, m_params.m_useVA, m_params.m_isMergeable, "tinyStorage"), p.m_storagesCount)));
+ if (m_params.m_useSingleThreadedOGL)
+ pool.reset(new TMergeableStoragePoolImpl(new TMergeableStoragePoolTraits(TStorageFactory(p.m_vbSize, p.m_ibSize, m_params.m_useVA, m_params.m_useSingleThreadedOGL, p.m_poolName.c_str()), p.m_storagesCount)));
else
- m_tinyStorages.reset(new TNonMergeableStoragePoolImpl(new TNonMergeableStoragePoolTraits(TStorageFactory(p.m_vbSize, p.m_ibSize, m_params.m_useVA, m_params.m_isMergeable, "tinyStorage"), p.m_storagesCount)));
+ pool.reset(new TNonMergeableStoragePoolImpl(new TNonMergeableStoragePoolTraits(TStorageFactory(p.m_vbSize, p.m_ibSize, m_params.m_useVA, m_params.m_useSingleThreadedOGL, p.m_poolName.c_str()), p.m_storagesCount)));
}
else
- LOG(LINFO, ("no tiny storages"));
- }
-
- void ResourceManager::initPrimaryTextures(TexturePoolParams const & p)
- {
- if (p.isValid())
- m_primaryTextures.reset(new TTexturePoolImpl(new TTexturePoolTraits(TTextureFactory(p.m_texWidth, p.m_texHeight, "primaryTextures"), p.m_texCount)));
- else
- LOG(LINFO, ("no primary textures"));
- }
-
- void ResourceManager::initFontTextures(TexturePoolParams const & p)
- {
- if (p.isValid())
- m_fontTextures.reset(new TTexturePoolImpl(new TTexturePoolTraits(TTextureFactory(p.m_texWidth, p.m_texHeight, "fontTextures"), p.m_texCount)));
- else
- LOG(LINFO, ("no font textures"));
- }
-
- void ResourceManager::initRenderTargetTextures(TexturePoolParams const & p)
- {
- if (p.isValid())
- m_renderTargets.reset(new TTexturePoolImpl(new TTexturePoolTraits(TTextureFactory(p.m_texWidth, p.m_texHeight, "renderTargets"), p.m_texCount)));
- else
- LOG(LINFO, ("no renderTarget textures"));
+ LOG(LINFO, ("no ", p.m_poolName, " resource"));
}
- void ResourceManager::initStyleCacheTextures(TexturePoolParams const & p)
+ void ResourceManager::initTexturePool(TexturePoolParams const & p, auto_ptr<TTexturePool> & pool)
{
if (p.isValid())
- m_styleCacheTextures.reset(new TTexturePoolImpl(new TTexturePoolTraits(TTextureFactory(p.m_texWidth, p.m_texHeight, "styleCacheTextures"), p.m_texCount)));
+ pool.reset(new TTexturePoolImpl(new TTexturePoolTraits(TTextureFactory(p.m_texWidth, p.m_texHeight, p.m_poolName.c_str()), p.m_texCount)));
else
- LOG(LINFO, ("no styleCache textures"));
+ LOG(LINFO, ("no ", p.m_poolName, " resource"));
}
shared_ptr<gl::BaseTexture> const & ResourceManager::getTexture(string const & fileName)
diff --git a/yg/resource_manager.hpp b/yg/resource_manager.hpp
index 00e33149a2..b503086188 100644
--- a/yg/resource_manager.hpp
+++ b/yg/resource_manager.hpp
@@ -43,8 +43,8 @@ namespace yg
size_t m_vbSize;
size_t m_ibSize;
bool m_useVA;
- bool m_isMergeable;
- TStorageFactory(size_t vbSize, size_t ibSize, bool useVA, bool isMergeable, char const * resName);
+ bool m_useSingleThreadedOGL;
+ TStorageFactory(size_t vbSize, size_t ibSize, bool useVA, bool useSingleThreadedOGL, char const * resName);
gl::Storage const Create();
void BeforeMerge(gl::Storage const & e);
};
@@ -75,15 +75,33 @@ namespace yg
struct StoragePoolParams
{
size_t m_vbSize;
+ size_t m_vertexSize;
size_t m_ibSize;
+ size_t m_indexSize;
size_t m_storagesCount;
- bool m_isFixed; //< should this params be scaled while fitting into videoMemoryLimit
- StoragePoolParams(size_t vbSize, size_t ibSize, size_t storagesCount, bool isFixed);
- StoragePoolParams();
+ bool m_isFixed;
+ int m_scalePriority;
+ double m_scaleFactor;
+
+ string m_poolName;
+
+ StoragePoolParams(size_t vbSize,
+ size_t vertexSize,
+ size_t ibSize,
+ size_t indexSize,
+ size_t storagesCount,
+ bool isFixed,
+ int scalePriority,
+ string const & poolName);
+
+ StoragePoolParams(string const & poolName);
+
+ bool isFixed() const;
bool isValid() const;
void scaleMemoryUsage(double k);
+ void distributeFreeMemory(int freeVideoMemory);
size_t memoryUsage() const;
};
@@ -93,13 +111,32 @@ namespace yg
size_t m_texHeight;
size_t m_texCount;
yg::RtFormat m_rtFormat;
- bool m_isFixed; //< should this params be scaled while fitting into videoMemoryLimit
- TexturePoolParams(size_t texWidth, size_t texHeight, size_t texCount, yg::RtFormat rtFormat, bool isFixed);
- TexturePoolParams();
+ bool m_isWidthFixed;
+ bool m_isHeightFixed;
+ bool m_isCountFixed;
+
+ int m_scalePriority;
+ double m_scaleFactor;
+ string m_poolName;
+
+ TexturePoolParams(size_t texWidth,
+ size_t texHeight,
+ size_t texCount,
+ yg::RtFormat rtFormat,
+ bool isWidthFixed,
+ bool isHeightFixed,
+ bool isCountFixed,
+ int scalePriority,
+ string const & poolName);
+
+ TexturePoolParams(string const & poolName);
+
+ bool isFixed() const;
bool isValid() const;
void scaleMemoryUsage(double k);
+ void distributeFreeMemory(int freeVideoMemory);
size_t memoryUsage() const;
};
@@ -125,7 +162,7 @@ namespace yg
struct Params
{
RtFormat m_rtFormat;
- bool m_isMergeable;
+ bool m_useSingleThreadedOGL;
bool m_useVA;
size_t m_videoMemoryLimit;
@@ -151,8 +188,11 @@ namespace yg
Params();
- void scaleMemoryUsage(double k);
+ void distributeFreeMemory(int freeVideoMemory);
void fitIntoLimits();
+ int memoryUsage() const;
+ int fixedMemoryUsage() const;
+ void initScaleWeights();
};
private:
@@ -184,11 +224,7 @@ namespace yg
void initGlyphCaches(GlyphCacheParams const & p);
- void initPrimaryStorage(StoragePoolParams const & p);
- void initSmallStorage(StoragePoolParams const & p);
- void initBlitStorage(StoragePoolParams const & p);
- void initMultiBlitStorage(StoragePoolParams const & p);
- void initTinyStorage(StoragePoolParams const & p);
+ void initStoragePool(StoragePoolParams const & p, auto_ptr<TStoragePool> & pool);
TStoragePool * primaryStorages();
TStoragePool * smallStorages();
@@ -196,10 +232,7 @@ namespace yg
TStoragePool * multiBlitStorages();
TStoragePool * tinyStorages();
- void initPrimaryTextures(TexturePoolParams const & p);
- void initFontTextures(TexturePoolParams const & p);
- void initRenderTargetTextures(TexturePoolParams const & p);
- void initStyleCacheTextures(TexturePoolParams const & p);
+ void initTexturePool(TexturePoolParams const & p, auto_ptr<TTexturePool> & pool);
TTexturePool * primaryTextures();
TTexturePool * fontTextures();