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
path: root/map
diff options
context:
space:
mode:
authorrachytski <siarhei.rachytski@gmail.com>2012-12-06 18:14:47 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:47:49 +0300
commit06ec326bc42521dcf3a32fba3736ca636dfbd88a (patch)
tree3bab700564fc5e68f420985e752d0d784af42567 /map
parent24dd26625caeccbaadd9a7681422b30d0b303e4b (diff)
refactored allocation of OpenGL resources in ResourceManager.
Diffstat (limited to 'map')
-rw-r--r--map/simple_render_policy.cpp111
-rw-r--r--map/tile_cache.cpp2
-rw-r--r--map/tile_cache.hpp5
-rw-r--r--map/tile_renderer.cpp27
-rw-r--r--map/tiling_render_policy_mt.cpp183
-rw-r--r--map/tiling_render_policy_st.cpp172
-rw-r--r--map/tiling_render_policy_st.hpp4
7 files changed, 226 insertions, 278 deletions
diff --git a/map/simple_render_policy.cpp b/map/simple_render_policy.cpp
index be0fd5369f..e65d387175 100644
--- a/map/simple_render_policy.cpp
+++ b/map/simple_render_policy.cpp
@@ -20,65 +20,57 @@ SimpleRenderPolicy::SimpleRenderPolicy(Params const & p)
rmp.checkDeviceCaps();
- rmp.m_primaryStoragesParams = graphics::ResourceManager::StoragePoolParams(50000 * sizeof(graphics::gl::Vertex),
- sizeof(graphics::gl::Vertex),
- 10000 * sizeof(unsigned short),
- sizeof(unsigned short),
- 15,
- false,
- true,
- 1,
- "primaryStorage",
- false,
- false);
-
- rmp.m_smallStoragesParams = graphics::ResourceManager::StoragePoolParams(5000 * sizeof(graphics::gl::Vertex),
- sizeof(graphics::gl::Vertex),
- 10000 * sizeof(unsigned short),
- sizeof(unsigned short),
- 100,
- false,
- true,
- 1,
- "smallStorage",
- false,
- false);
-
- rmp.m_blitStoragesParams = graphics::ResourceManager::StoragePoolParams(10 * sizeof(graphics::gl::Vertex),
- sizeof(graphics::gl::Vertex),
- 10 * sizeof(unsigned short),
- sizeof(unsigned short),
- 50,
- true,
- true,
- 1,
- "blitStorage",
- false,
- false);
-
- rmp.m_primaryTexturesParams = graphics::ResourceManager::TexturePoolParams(512,
- 256,
- 10,
- rmp.m_texFormat,
- true,
- true,
- true,
- 1,
- "primaryTexture",
- false,
- false);
-
- rmp.m_fontTexturesParams = graphics::ResourceManager::TexturePoolParams(512,
- 256,
- 5,
- rmp.m_texFormat,
- true,
- true,
- true,
- 1,
- "fontTexture",
- false,
- false);
+ graphics::ResourceManager::TexturePoolParams tpp;
+ graphics::ResourceManager::StoragePoolParams spp;
+
+ spp = graphics::ResourceManager::StoragePoolParams(50000 * sizeof(graphics::gl::Vertex),
+ sizeof(graphics::gl::Vertex),
+ 10000 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 15,
+ graphics::ELargeStorage,
+ false);
+
+ rmp.m_storageParams[spp.m_storageType] = spp;
+
+ spp = graphics::ResourceManager::StoragePoolParams(5000 * sizeof(graphics::gl::Vertex),
+ sizeof(graphics::gl::Vertex),
+ 10000 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 100,
+ graphics::EMediumStorage,
+ false);
+
+ rmp.m_storageParams[spp.m_storageType] = spp;
+
+ spp = graphics::ResourceManager::StoragePoolParams(2000 * sizeof(graphics::gl::Vertex),
+ sizeof(graphics::gl::Vertex),
+ 6000 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 10,
+ graphics::ESmallStorage,
+ false);
+
+ rmp.m_storageParams[spp.m_storageType] = spp;
+
+
+ tpp = graphics::ResourceManager::TexturePoolParams(512,
+ 256,
+ 10,
+ rmp.m_texFormat,
+ graphics::ELargeTexture,
+ false);
+
+ rmp.m_textureParams[tpp.m_textureType] = tpp;
+
+ tpp = graphics::ResourceManager::TexturePoolParams(512,
+ 256,
+ 5,
+ rmp.m_texFormat,
+ graphics::EMediumTexture,
+ false);
+
+ rmp.m_textureParams[tpp.m_textureType] = tpp;
rmp.m_glyphCacheParams = graphics::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
"fonts_whitelist.txt",
@@ -89,7 +81,6 @@ SimpleRenderPolicy::SimpleRenderPolicy(Params const & p)
rmp.m_threadSlotsCount = 1;
rmp.m_useSingleThreadedOGL = false;
- rmp.fitIntoLimits();
m_resourceManager.reset(new graphics::ResourceManager(rmp));
diff --git a/map/tile_cache.cpp b/map/tile_cache.cpp
index 85a4bf3540..802fc3d93f 100644
--- a/map/tile_cache.cpp
+++ b/map/tile_cache.cpp
@@ -3,7 +3,7 @@
void TileCache::EntryValueTraits::Evict(Entry &val)
{
if (val.m_rm)
- val.m_rm->renderTargetTextures()->Free(val.m_tile.m_renderTarget);
+ val.m_rm->texturePool(graphics::ERenderTargetTexture)->Free(val.m_tile.m_renderTarget);
}
TileCache::Entry::Entry()
diff --git a/map/tile_cache.hpp b/map/tile_cache.hpp
index 68b6941e7a..7bd5fb8432 100644
--- a/map/tile_cache.hpp
+++ b/map/tile_cache.hpp
@@ -10,7 +10,10 @@
#include "../std/bind.hpp"
-class ResourceManager;
+namespace graphics
+{
+ class ResourceManager;
+}
class TileCache
{
diff --git a/map/tile_renderer.cpp b/map/tile_renderer.cpp
index fe41db585d..9f1034ca45 100644
--- a/map/tile_renderer.cpp
+++ b/map/tile_renderer.cpp
@@ -9,6 +9,7 @@
#include "../graphics/packets_queue.hpp"
#include "../graphics/skin.hpp"
+#include "../graphics/defines.hpp"
#include "../std/bind.hpp"
@@ -44,8 +45,8 @@ TileRenderer::TileRenderer(
LOG(LINFO, ("initializing ", m_queue.ExecutorsCount(), " rendering threads"));
- int tileWidth = m_resourceManager->params().m_renderTargetTexturesParams.m_texWidth;
- int tileHeight = m_resourceManager->params().m_renderTargetTexturesParams.m_texHeight;
+ int tileWidth = m_resourceManager->params().m_textureParams[graphics::ERenderTargetTexture].m_texWidth;
+ int tileHeight = m_resourceManager->params().m_textureParams[graphics::ERenderTargetTexture].m_texHeight;
for (unsigned i = 0; i < m_threadData.size(); ++i)
{
@@ -99,8 +100,8 @@ void TileRenderer::InitializeThreadGL(core::CommandsQueue::Environment const & e
{
ThreadData & threadData = m_threadData[env.threadNum()];
- int tileWidth = m_resourceManager->params().m_renderTargetTexturesParams.m_texWidth;
- int tileHeight = m_resourceManager->params().m_renderTargetTexturesParams.m_texHeight;
+ int tileWidth = m_resourceManager->params().m_textureParams[graphics::ERenderTargetTexture].m_texWidth;
+ int tileHeight = m_resourceManager->params().m_textureParams[graphics::ERenderTargetTexture].m_texHeight;
if (threadData.m_renderContext)
{
@@ -134,8 +135,8 @@ void TileRenderer::ReadPixels(graphics::PacketsQueue * glQueue, core::CommandsQu
if (!env.isCancelled())
{
- unsigned tileWidth = m_resourceManager->params().m_renderTargetTexturesParams.m_texWidth;
- unsigned tileHeight = m_resourceManager->params().m_renderTargetTexturesParams.m_texHeight;
+ unsigned tileWidth = m_resourceManager->params().m_textureParams[graphics::ERenderTargetTexture].m_texWidth;
+ unsigned tileHeight = m_resourceManager->params().m_textureParams[graphics::ERenderTargetTexture].m_texHeight;
shared_ptr<vector<unsigned char> > buf = SharedBufferManager::instance().reserveSharedBuffer(tileWidth * tileHeight * 4);
drawer->screen()->readPixels(m2::RectU(0, 0, tileWidth, tileHeight), &(buf->at(0)), true);
@@ -165,8 +166,8 @@ void TileRenderer::DrawTile(core::CommandsQueue::Environment const & env,
ScreenBase frameScreen;
- unsigned tileWidth = m_resourceManager->params().m_renderTargetTexturesParams.m_texWidth;
- unsigned tileHeight = m_resourceManager->params().m_renderTargetTexturesParams.m_texHeight;
+ unsigned tileWidth = m_resourceManager->params().m_textureParams[graphics::ERenderTargetTexture].m_texWidth;
+ unsigned tileHeight = m_resourceManager->params().m_textureParams[graphics::ERenderTargetTexture].m_texHeight;
m2::RectI renderRect(1, 1, tileWidth - 1, tileHeight - 1);
@@ -176,9 +177,11 @@ void TileRenderer::DrawTile(core::CommandsQueue::Environment const & env,
my::Timer timer;
- shared_ptr<graphics::gl::BaseTexture> tileTarget = m_resourceManager->renderTargetTextures()->Reserve();
+ graphics::TTexturePool * texturePool = m_resourceManager->texturePool(graphics::ERenderTargetTexture);
- if (m_resourceManager->renderTargetTextures()->IsCancelled())
+ shared_ptr<graphics::gl::BaseTexture> tileTarget = texturePool->Reserve();
+
+ if (texturePool->IsCancelled())
return;
drawer->screen()->setRenderTarget(tileTarget);
@@ -258,7 +261,7 @@ void TileRenderer::DrawTile(core::CommandsQueue::Environment const & env,
if (env.isCancelled())
{
if (!m_isExiting)
- m_resourceManager->renderTargetTextures()->Free(tileTarget);
+ texturePool->Free(tileTarget);
}
else
{
@@ -337,7 +340,7 @@ void TileRenderer::AddActiveTile(Tile const & tile)
Tiler::RectInfo const & key = tile.m_rectInfo;
if (m_tileSet.HasTile(key) || m_tileCache.HasTile(key))
- m_resourceManager->renderTargetTextures()->Free(tile.m_renderTarget);
+ m_resourceManager->texturePool(graphics::ERenderTargetTexture)->Free(tile.m_renderTarget);
else
{
m_tileSet.AddTile(tile);
diff --git a/map/tiling_render_policy_mt.cpp b/map/tiling_render_policy_mt.cpp
index ae4beb7a58..2be69b396f 100644
--- a/map/tiling_render_policy_mt.cpp
+++ b/map/tiling_render_policy_mt.cpp
@@ -9,6 +9,8 @@
#include "tile_renderer.hpp"
#include "coverage_generator.hpp"
+using namespace graphics;
+
TilingRenderPolicyMT::TilingRenderPolicyMT(Params const & p)
: BasicTilingRenderPolicy(p,
false)
@@ -19,112 +21,95 @@ TilingRenderPolicyMT::TilingRenderPolicyMT(Params const & p)
rmp.checkDeviceCaps();
- rmp.m_primaryTexturesParams = graphics::ResourceManager::TexturePoolParams(512,
- 256,
- 1,
- rmp.m_texFormat,
- true,
- true,
- true,
- 1,
- "primaryTexture",
- false,
- true);
-
- rmp.m_fontTexturesParams = graphics::ResourceManager::TexturePoolParams(256,
- 256,
- 1,
- rmp.m_texFormat,
- true,
- true,
- true,
- 1,
- "fontTexture",
- true,
- true);
-
- rmp.m_primaryStoragesParams = graphics::ResourceManager::StoragePoolParams(50000 * sizeof(graphics::gl::Vertex),
- sizeof(graphics::gl::Vertex),
- 100000 * sizeof(unsigned short),
- sizeof(unsigned short),
- 5,
- true,
- true,
- 1,
- "primaryStorage",
- false,
- true);
-
- rmp.m_smallStoragesParams = graphics::ResourceManager::StoragePoolParams(6000 * sizeof(graphics::gl::Vertex),
- sizeof(graphics::gl::Vertex),
- 9000 * sizeof(unsigned short),
- sizeof(unsigned short),
- 1,
- true,
- true,
- 1,
- "smallStorage",
- true,
- true);
-
- rmp.m_multiBlitStoragesParams = graphics::ResourceManager::StoragePoolParams(500 * sizeof(graphics::gl::Vertex),
- sizeof(graphics::gl::Vertex),
- 750 * sizeof(unsigned short),
- sizeof(unsigned short),
- 1,
- true,
- true,
- 1,
- "multiBlitStorage",
- false,
- true);
-
- rmp.m_renderTargetTexturesParams = graphics::ResourceManager::TexturePoolParams(TileSize(),
- TileSize(),
- 1,
- rmp.m_texRtFormat,
- true,
- true,
- true,
- 5,
- "renderTargetTexture",
- false,
- true);
-
- rmp.m_guiThreadStoragesParams = graphics::ResourceManager::StoragePoolParams(2000 * sizeof(graphics::gl::Vertex),
- sizeof(graphics::gl::Vertex),
- 4000 * sizeof(unsigned short),
- sizeof(unsigned short),
- 5,
- true,
- true,
- 1,
- "guiThreadStorage",
- true,
- true);
-
- rmp.m_guiThreadTexturesParams = graphics::ResourceManager::TexturePoolParams(256,
- 128,
- 4,
- rmp.m_texFormat,
- true,
- true,
- true,
- 1,
- "guiThreadTexture",
- true,
- true);
+ ResourceManager::TexturePoolParams tpp;
+ ResourceManager::StoragePoolParams spp;
+
+ tpp = ResourceManager::TexturePoolParams(512,
+ 256,
+ 1,
+ rmp.m_texFormat,
+ ELargeTexture,
+ true);
+
+ rmp.m_textureParams[tpp.m_textureType] = tpp;
+
+ tpp = ResourceManager::TexturePoolParams(256,
+ 256,
+ 1,
+ rmp.m_texFormat,
+ EMediumTexture,
+ true);
+
+ rmp.m_textureParams[tpp.m_textureType] = tpp;
+
+ tpp = ResourceManager::TexturePoolParams(TileSize(),
+ TileSize(),
+ 1,
+ rmp.m_texRtFormat,
+ ERenderTargetTexture,
+ true);
+
+ rmp.m_textureParams[tpp.m_textureType] = tpp;
+
+ tpp = ResourceManager::TexturePoolParams(256,
+ 128,
+ 4,
+ rmp.m_texFormat,
+ ESmallTexture,
+ true);
+
+ rmp.m_textureParams[tpp.m_textureType] = tpp;
+
+ spp = ResourceManager::StoragePoolParams(50000 * sizeof(graphics::gl::Vertex),
+ sizeof(graphics::gl::Vertex),
+ 100000 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 5,
+ ELargeStorage,
+ true);
+
+ rmp.m_storageParams[spp.m_storageType] = spp;
+
+ spp = ResourceManager::StoragePoolParams(6000 * sizeof(graphics::gl::Vertex),
+ sizeof(graphics::gl::Vertex),
+ 9000 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 1,
+ EMediumStorage,
+ true);
+
+ rmp.m_storageParams[spp.m_storageType] = spp;
+
+ spp = ResourceManager::StoragePoolParams(2000 * sizeof(graphics::gl::Vertex),
+ sizeof(graphics::gl::Vertex),
+ 4000 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 5,
+ ESmallStorage,
+ true);
+
+ rmp.m_storageParams[spp.m_storageType] = spp;
+
+ spp = ResourceManager::StoragePoolParams(500 * sizeof(graphics::gl::Vertex),
+ sizeof(graphics::gl::Vertex),
+ 750 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 1,
+ ETinyStorage,
+ true);
+
+ rmp.m_storageParams[spp.m_storageType] = spp;
+
rmp.m_glyphCacheParams = graphics::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
- "fonts_whitelist.txt",
- "fonts_blacklist.txt",
- 2 * 1024 * 1024);
+ "fonts_whitelist.txt",
+ "fonts_blacklist.txt",
+ 2 * 1024 * 1024);
rmp.m_threadSlotsCount = cpuCores + 2;
rmp.m_renderThreadsCount = cpuCores;
rmp.m_useSingleThreadedOGL = false;
- rmp.fitIntoLimits();
m_resourceManager.reset(new graphics::ResourceManager(rmp));
diff --git a/map/tiling_render_policy_st.cpp b/map/tiling_render_policy_st.cpp
index 54259b745b..04038d74a3 100644
--- a/map/tiling_render_policy_st.cpp
+++ b/map/tiling_render_policy_st.cpp
@@ -21,114 +21,84 @@ TilingRenderPolicyST::TilingRenderPolicyST(Params const & p)
rmp.checkDeviceCaps();
- rmp.m_primaryTexturesParams = graphics::ResourceManager::TexturePoolParams(512,
- 256,
- 1,
- rmp.m_texFormat,
- true,
- true,
- true,
- 1,
- "primaryTexture",
- true,
- true);
-
- rmp.m_fontTexturesParams = graphics::ResourceManager::TexturePoolParams(256,
- 256,
- 10,
- rmp.m_texFormat,
- true,
- true,
- true,
- 1,
- "fontTexture",
- true,
- true);
-
- rmp.m_primaryStoragesParams = graphics::ResourceManager::StoragePoolParams(6000 * sizeof(graphics::gl::Vertex),
- sizeof(graphics::gl::Vertex),
- 9000 * sizeof(unsigned short),
- sizeof(unsigned short),
- 10,
- true,
- true,
- 2,
- "primaryStorage",
- true,
- true);
-
- rmp.m_smallStoragesParams = graphics::ResourceManager::StoragePoolParams(6000 * sizeof(graphics::gl::Vertex),
- sizeof(graphics::gl::Vertex),
- 9000 * sizeof(unsigned short),
- sizeof(unsigned short),
- 1,
- true,
- true,
- 1,
- "smallStorage",
- true,
- true);
-
- rmp.m_multiBlitStoragesParams = graphics::ResourceManager::StoragePoolParams(1500 * sizeof(graphics::gl::Vertex),
- sizeof(graphics::gl::Vertex),
- 2500 * sizeof(unsigned short),
- sizeof(unsigned short),
- 1,
- true,
- true,
- 1,
- "multiBlitStorage",
- true,
- true);
-
- rmp.m_renderTargetTexturesParams = graphics::ResourceManager::TexturePoolParams(TileSize(),
- TileSize(),
- 1,
- rmp.m_texRtFormat,
- true,
- true,
- true,
- 4,
- "renderTargetTexture",
- true,
- true);
-
- rmp.m_guiThreadStoragesParams = graphics::ResourceManager::StoragePoolParams(2000 * sizeof(graphics::gl::Vertex),
- sizeof(graphics::gl::Vertex),
- 4000 * sizeof(unsigned short),
- sizeof(unsigned short),
- 5,
- true,
- true,
- 1,
- "guiThreadStorage",
- true,
- true);
-
- rmp.m_guiThreadTexturesParams = graphics::ResourceManager::TexturePoolParams(256,
- 128,
- 2,
- rmp.m_texFormat,
- true,
- true,
- true,
- 1,
- "guiThreadTexture",
- true,
- true);
+ graphics::ResourceManager::TexturePoolParams tpp;
+ graphics::ResourceManager::StoragePoolParams spp;
+
+ tpp = graphics::ResourceManager::TexturePoolParams(512,
+ 256,
+ 1,
+ rmp.m_texFormat,
+ graphics::ELargeTexture,
+ true);
+
+ rmp.m_textureParams[tpp.m_textureType] = tpp;
+
+ tpp = graphics::ResourceManager::TexturePoolParams(256,
+ 256,
+ 10,
+ rmp.m_texFormat,
+ graphics::EMediumTexture,
+ true);
+
+ rmp.m_textureParams[tpp.m_textureType] = tpp;
+
+ tpp = graphics::ResourceManager::TexturePoolParams(TileSize(),
+ TileSize(),
+ 1,
+ rmp.m_texRtFormat,
+ graphics::ERenderTargetTexture,
+ true);
+
+ rmp.m_textureParams[tpp.m_textureType] = tpp;
+
+ tpp = graphics::ResourceManager::TexturePoolParams(256,
+ 128,
+ 2,
+ rmp.m_texFormat,
+ graphics::ESmallTexture,
+ true);
+
+ rmp.m_textureParams[tpp.m_textureType] = tpp;
+
+ spp = graphics::ResourceManager::StoragePoolParams(6000 * sizeof(graphics::gl::Vertex),
+ sizeof(graphics::gl::Vertex),
+ 9000 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 10,
+ graphics::ELargeStorage,
+ true);
+
+ rmp.m_storageParams[spp.m_storageType] = spp;
+
+ spp = graphics::ResourceManager::StoragePoolParams(6000 * sizeof(graphics::gl::Vertex),
+ sizeof(graphics::gl::Vertex),
+ 9000 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 1,
+ graphics::EMediumStorage,
+ true);
+
+ rmp.m_storageParams[spp.m_storageType] = spp;
+
+ spp = graphics::ResourceManager::StoragePoolParams(2000 * sizeof(graphics::gl::Vertex),
+ sizeof(graphics::gl::Vertex),
+ 4000 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 5,
+ graphics::ESmallStorage,
+ true);
+
+ rmp.m_storageParams[spp.m_storageType] = spp;
rmp.m_glyphCacheParams = graphics::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
- "fonts_whitelist.txt",
- "fonts_blacklist.txt",
- 2 * 1024 * 1024);
+ "fonts_whitelist.txt",
+ "fonts_blacklist.txt",
+ 2 * 1024 * 1024);
rmp.m_threadSlotsCount = cpuCores + 2;
rmp.m_renderThreadsCount = cpuCores;
rmp.m_useSingleThreadedOGL = true;
- rmp.fitIntoLimits();
-
- m_maxTilesCount = rmp.m_renderTargetTexturesParams.m_texCount;
m_resourceManager.reset(new graphics::ResourceManager(rmp));
diff --git a/map/tiling_render_policy_st.hpp b/map/tiling_render_policy_st.hpp
index e5dadf13a7..157d312a9a 100644
--- a/map/tiling_render_policy_st.hpp
+++ b/map/tiling_render_policy_st.hpp
@@ -4,10 +4,6 @@
class TilingRenderPolicyST : public BasicTilingRenderPolicy
{
-private:
-
- int m_maxTilesCount;
-
public:
TilingRenderPolicyST(Params const & p);