From c41ac364405f62ef72beff5bd4ae3620dcbe8d19 Mon Sep 17 00:00:00 2001 From: rachytski Date: Wed, 31 Aug 2011 13:32:01 +0300 Subject: [PATCH] allocating renderTargets in TilingRenderPolicyXXX only --- iphone/Maps/Classes/EAGLView.mm | 3 --- map/tiling_render_policy_mt.cpp | 4 ++++ map/tiling_render_policy_st.cpp | 2 ++ qt/widgets.cpp | 1 - qt_tstfrm/tstwidgets.cpp | 1 - yg/resource_manager.cpp | 22 +++++++++++++--------- yg/resource_manager.hpp | 7 ++++--- yg/yg_tests/skin_loader_test.cpp | 2 +- yg/yg_tests/skin_test.cpp | 2 +- 9 files changed, 25 insertions(+), 19 deletions(-) diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm index 7dc7ee3cdc..e88cce9ed8 100644 --- a/iphone/Maps/Classes/EAGLView.mm +++ b/iphone/Maps/Classes/EAGLView.mm @@ -97,9 +97,6 @@ blitVBSize, blitIBSize, 15 * GetPlatform().CpuCores(), 512, 256, 10 * GetPlatform().CpuCores(), 512, 256, 10 * GetPlatform().CpuCores(), - GetPlatform().TileSize(), - GetPlatform().TileSize(), - GetPlatform().MaxTilesCount(), "unicode_blocks.txt", "fonts_whitelist.txt", "fonts_blacklist.txt", diff --git a/map/tiling_render_policy_mt.cpp b/map/tiling_render_policy_mt.cpp index 76e208c355..193cabb85a 100644 --- a/map/tiling_render_policy_mt.cpp +++ b/map/tiling_render_policy_mt.cpp @@ -27,12 +27,16 @@ TilingRenderPolicyMT::TilingRenderPolicyMT(shared_ptr const & wind &m_tileRenderer, windowHandle) { + } void TilingRenderPolicyMT::Initialize(shared_ptr const & primaryContext, shared_ptr const & resourceManager) { RenderPolicy::Initialize(primaryContext, resourceManager); + + resourceManager->initRenderTargets(GetPlatform().TileSize(), GetPlatform().TileSize(), GetPlatform().MaxTilesCount()); + m_tileRenderer.Initialize(primaryContext, resourceManager, GetPlatform().VisualScale()); m_coverageGenerator.Initialize(); } diff --git a/map/tiling_render_policy_st.cpp b/map/tiling_render_policy_st.cpp index 369189ec60..b929cab8c3 100644 --- a/map/tiling_render_policy_st.cpp +++ b/map/tiling_render_policy_st.cpp @@ -26,6 +26,8 @@ void TilingRenderPolicyST::Initialize(shared_ptr const & { RenderPolicy::Initialize(primaryContext, rm); + rm->initRenderTargets(GetPlatform().TileSize(), GetPlatform().TileSize(), GetPlatform().MaxTilesCount()); + /// render single tile on the same thread shared_ptr frameBuffer(new yg::gl::FrameBuffer()); diff --git a/qt/widgets.cpp b/qt/widgets.cpp index ce285f7798..5ec439e51e 100644 --- a/qt/widgets.cpp +++ b/qt/widgets.cpp @@ -52,7 +52,6 @@ namespace qt 10, 512, 256, 5, - GetPlatform().TileSize(), GetPlatform().TileSize(), GetPlatform().MaxTilesCount(), "unicode_blocks.txt", "fonts_whitelist.txt", "fonts_blacklist.txt", diff --git a/qt_tstfrm/tstwidgets.cpp b/qt_tstfrm/tstwidgets.cpp index e365d4a64c..2ab345b72b 100644 --- a/qt_tstfrm/tstwidgets.cpp +++ b/qt_tstfrm/tstwidgets.cpp @@ -56,7 +56,6 @@ void GLDrawWidget::initializeGL() 30, 512, 256, 10, 512, 256, 5, - GetPlatform().TileSize(), GetPlatform().TileSize(), GetPlatform().MaxTilesCount(), "unicode_blocks.txt", "fonts_whitelist.txt", "fonts_blacklist.txt", diff --git a/yg/resource_manager.cpp b/yg/resource_manager.cpp index debb58f271..442c11de91 100644 --- a/yg/resource_manager.cpp +++ b/yg/resource_manager.cpp @@ -24,7 +24,6 @@ namespace yg size_t blitVBSize, size_t blitIBSize, size_t blitStoragesCount, size_t dynamicTexWidth, size_t dynamicTexHeight, size_t dynamicTexCount, size_t fontTexWidth, size_t fontTexHeight, size_t fontTexCount, - size_t tileTexWidth, size_t tileTexHeight, size_t tileTexCount, char const * blocksFile, char const * whiteListFile, char const * blackListFile, size_t glyphCacheSize, size_t glyphCacheCount, @@ -32,7 +31,6 @@ namespace yg bool useVA) : m_dynamicTextureWidth(dynamicTexWidth), m_dynamicTextureHeight(dynamicTexHeight), m_fontTextureWidth(fontTexWidth), m_fontTextureHeight(fontTexHeight), - m_tileTextureWidth(tileTexWidth), m_tileTextureHeight(tileTexHeight), m_vbSize(vbSize), m_ibSize(ibSize), m_smallVBSize(smallVBSize), m_smallIBSize(smallIBSize), m_blitVBSize(blitVBSize), m_blitIBSize(blitIBSize), @@ -66,7 +64,7 @@ namespace yg m_dynamicTextures.PushBack(t); } - LOG(LINFO, ("allocating ", dynamicTexWidth * dynamicTexHeight * sizeof(TDynamicTexture::pixel_t), " bytes for textures")); + LOG(LINFO, ("allocating ", dynamicTexCount * dynamicTexWidth * dynamicTexHeight * sizeof(TDynamicTexture::pixel_t), " bytes for textures")); for (size_t i = 0; i < fontTexCount; ++i) { @@ -74,15 +72,21 @@ namespace yg m_fontTextures.PushBack(t); } - LOG(LINFO, ("allocating ", fontTexWidth * fontTexHeight * sizeof(TDynamicTexture::pixel_t), " bytes for font textures")); + LOG(LINFO, ("allocating ", fontTexCount * fontTexWidth * fontTexHeight * sizeof(TDynamicTexture::pixel_t), " bytes for font textures")); + } - for (size_t i = 0; i < tileTexCount; ++i) + void ResourceManager::initRenderTargets(size_t renderTargetWidth, size_t renderTargetHeight, size_t renderTargetsCount) + { + m_renderTargetWidth = renderTargetWidth; + m_renderTargetHeight = renderTargetHeight; + + for (size_t i = 0; i < renderTargetsCount; ++i) { - shared_ptr t(new TStaticTexture(tileTexWidth, tileTexHeight)); + shared_ptr t(new TStaticTexture(renderTargetWidth, renderTargetHeight)); m_renderTargets.PushBack(t); } - LOG(LINFO, ("allocating ", tileTexWidth * tileTexHeight * sizeof(TStaticTexture::pixel_t), " bytes for tiles")); + LOG(LINFO, ("allocating ", renderTargetsCount * renderTargetWidth * renderTargetHeight * sizeof(TStaticTexture::pixel_t), " bytes for render targets")); } shared_ptr const & ResourceManager::getTexture(string const & fileName) @@ -144,12 +148,12 @@ namespace yg size_t ResourceManager::tileTextureWidth() const { - return m_tileTextureWidth; + return m_renderTargetWidth; } size_t ResourceManager::tileTextureHeight() const { - return m_tileTextureHeight; + return m_renderTargetHeight; } GlyphCache * ResourceManager::glyphCache(int glyphCacheID) diff --git a/yg/resource_manager.hpp b/yg/resource_manager.hpp index 607fb9e3c9..e8d7f1af86 100644 --- a/yg/resource_manager.hpp +++ b/yg/resource_manager.hpp @@ -49,8 +49,8 @@ namespace yg ThreadedList > m_fontTextures; - size_t m_tileTextureWidth; - size_t m_tileTextureHeight; + size_t m_renderTargetWidth; + size_t m_renderTargetHeight; ThreadedList > m_renderTargets; @@ -86,13 +86,14 @@ namespace yg size_t blitVBSize, size_t blitIBSize, size_t blitStoragesCount, size_t texWidth, size_t texHeight, size_t texCount, size_t fontTexWidth, size_t fontTexHeight, size_t fontTexCount, - size_t tileTexWidth, size_t tileTexHeight, size_t tileTexCount, char const * blocksFile, char const * whileListFile, char const * blackListFile, size_t glyphCacheSize, size_t glyphCacheCount, RtFormat fmt, bool useVA); + void initRenderTargets(size_t renderTargetWidth, size_t renderTargetHeight, size_t renderTargetCount); + shared_ptr const & getTexture(string const & fileName); ThreadedList & storages(); diff --git a/yg/yg_tests/skin_loader_test.cpp b/yg/yg_tests/skin_loader_test.cpp index e305c250cb..a7172e246d 100644 --- a/yg/yg_tests/skin_loader_test.cpp +++ b/yg/yg_tests/skin_loader_test.cpp @@ -8,6 +8,6 @@ UNIT_TEST(SkinLoaderTest_Main) { GL_TEST_START; - shared_ptr rm(new yg::ResourceManager(1000, 1000, 2, 1000, 1000, 2, 1000, 1000, 2, 128, 128, 15, 256, 256, 5, 256, 256, 40, "unicode_blocks.txt", "fonts_whitelist.txt", "fonts_blacklist.txt", 2 * 1024 * 1024, 3, yg::Rt8Bpp, false)); + shared_ptr rm(new yg::ResourceManager(1000, 1000, 2, 1000, 1000, 2, 1000, 1000, 2, 128, 128, 15, 256, 256, 5, "unicode_blocks.txt", "fonts_whitelist.txt", "fonts_blacklist.txt", 2 * 1024 * 1024, 3, yg::Rt8Bpp, false)); loadSkin(rm, "basic.skn", 2, 2); }; diff --git a/yg/yg_tests/skin_test.cpp b/yg/yg_tests/skin_test.cpp index e4e15722e0..74f1890069 100644 --- a/yg/yg_tests/skin_test.cpp +++ b/yg/yg_tests/skin_test.cpp @@ -10,7 +10,7 @@ UNIT_TEST(SkinTest_Main) { GL_TEST_START; - shared_ptr rm(new yg::ResourceManager(100, 100, 1, 100, 100, 1, 100, 100, 1, 128, 128, 15, 256, 256, 5, 256, 256, 40, "unicode_blocks.txt", "fonts_whitelist.txt", "fonts_blacklist.txt", 2 * 1024 * 1024, 3, yg::Rt8Bpp, false)); + shared_ptr rm(new yg::ResourceManager(100, 100, 1, 100, 100, 1, 100, 100, 1, 128, 128, 15, 256, 256, 5, "unicode_blocks.txt", "fonts_whitelist.txt", "fonts_blacklist.txt", 2 * 1024 * 1024, 3, yg::Rt8Bpp, false)); yg::Skin * skin = loadSkin(rm, "basic.skn", 2, 2); double p0 [] = {1, 1};