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:
-rw-r--r--graphics/blitter.cpp7
-rw-r--r--graphics/defines.cpp45
-rw-r--r--graphics/defines.hpp28
-rw-r--r--graphics/geometry_batcher.cpp80
-rw-r--r--graphics/geometry_batcher.hpp3
-rw-r--r--graphics/opengl/geometry_renderer.cpp8
-rw-r--r--graphics/opengl/storage.cpp5
-rw-r--r--graphics/opengl/storage.hpp2
-rw-r--r--graphics/resource_cache.cpp58
-rw-r--r--graphics/resource_cache.hpp22
-rw-r--r--graphics/resource_manager.cpp619
-rw-r--r--graphics/resource_manager.hpp116
-rw-r--r--graphics/skin.cpp4
-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
-rw-r--r--qt_tstfrm/tstwidgets.cpp122
21 files changed, 572 insertions, 1051 deletions
diff --git a/graphics/blitter.cpp b/graphics/blitter.cpp
index 3280b1a2b5..ae34f8971f 100644
--- a/graphics/blitter.cpp
+++ b/graphics/blitter.cpp
@@ -46,9 +46,10 @@ namespace graphics
idxData[i * 4 + 3] = i * 4 + 3;
}
- graphics::gl::Storage storage = resourceManager()->multiBlitStorages()->Reserve();
+ TStoragePool * storagePool = resourceManager()->storagePool(ESmallStorage);
+ gl::Storage storage = storagePool->Reserve();
- if (resourceManager()->multiBlitStorages()->IsCancelled())
+ if (storagePool->IsCancelled())
{
LOG(LINFO, ("skipping multiBlit on cancelled multiBlitStorages pool"));
return;
@@ -89,7 +90,7 @@ namespace graphics
base_t::applyStates();
base_t::discardStorage(storage);
- base_t::freeStorage(storage, resourceManager()->multiBlitStorages());
+ base_t::freeStorage(storage, storagePool);
}
void Blitter::calcPoints(m2::RectI const & srcRect,
diff --git a/graphics/defines.cpp b/graphics/defines.cpp
index 4ffd88ef6a..55e7835b19 100644
--- a/graphics/defines.cpp
+++ b/graphics/defines.cpp
@@ -8,7 +8,7 @@ namespace graphics
namespace {
struct Data
{
- ESemantic m_val;
+ int m_val;
char const * m_name;
};
}
@@ -28,11 +28,52 @@ namespace graphics
{
if (strcmp(name, s_semantics[i].m_name) == 0)
{
- sem = s_semantics[i].m_val;
+ sem = (ESemantic)s_semantics[i].m_val;
return;
}
}
LOG(LINFO, ("Unknown Semantics=", name, "specified!"));
}
+
+ Data s_storages [] = {
+ {ETinyStorage, "TinyStorage"},
+ {ESmallStorage, "SmallStorage"},
+ {EMediumStorage, "MediumStorage"},
+ {ELargeStorage, "LargeStorage"},
+ {EInvalidStorage, "InvalidStorage"}
+ };
+
+ char const * convert(EStorageType type)
+ {
+ for (unsigned i = 0; i < ARRAY_SIZE(s_storages); ++i)
+ {
+ if (s_storages[i].m_val == type)
+ return s_storages[i].m_name;
+ }
+
+ LOG(LINFO, ("Unknown StorageType=", type, "specified!"));
+ return "UnknownStorage";
+ }
+
+ Data s_textures [] = {
+ {ESmallTexture, "SmallTexture"},
+ {EMediumTexture, "MediumTexture"},
+ {ELargeTexture, "LargeTexture"},
+ {ERenderTargetTexture, "RenderTargetTexture"},
+ {EStaticTexture, "StaticTexture"},
+ {EInvalidTexture, "InvalidTexture"}
+ };
+
+ char const * convert(ETextureType type)
+ {
+ for (unsigned i = 0; i < ARRAY_SIZE(s_textures); ++i)
+ {
+ if (s_textures[i].m_val == type)
+ return s_textures[i].m_name;
+ }
+
+ LOG(LERROR, ("Unknown TextureType=", type, "specified!"));
+ return "UnknownTexture";
+ }
}
diff --git a/graphics/defines.hpp b/graphics/defines.hpp
index 37b9e91a2e..bb96a87043 100644
--- a/graphics/defines.hpp
+++ b/graphics/defines.hpp
@@ -4,6 +4,34 @@ namespace graphics
{
static const int maxDepth = 20000;
+ /// When adding values here,
+ /// please check constructor of ResourceManager,
+ /// and defines.cpp
+ enum ETextureType
+ {
+ ESmallTexture = 0,
+ EMediumTexture,
+ ELargeTexture,
+ ERenderTargetTexture,
+ EStaticTexture,
+ EInvalidTexture //< Should be last
+ };
+
+ char const * convert(ETextureType type);
+
+ /// When adding values here,
+ /// please check constructor of ResourceManager.
+ enum EStorageType
+ {
+ ETinyStorage = 0,
+ ESmallStorage,
+ EMediumStorage,
+ ELargeStorage,
+ EInvalidStorage //< Should be last
+ };
+
+ char const * convert(EStorageType type);
+
enum EShaderType
{
EVertexShader,
diff --git a/graphics/geometry_batcher.cpp b/graphics/geometry_batcher.cpp
index 1d59777d59..3ef9577aab 100644
--- a/graphics/geometry_batcher.cpp
+++ b/graphics/geometry_batcher.cpp
@@ -45,7 +45,7 @@ namespace graphics
{
discardPipeline(i);
freePipeline(i);
- if (m_skin->page(i)->type() != ResourceCache::EStatic)
+ if (m_skin->page(i)->type() != EStaticTexture)
freeTexture(i);
}
}
@@ -67,22 +67,15 @@ namespace graphics
if (!m_hasStorage)
{
if (m_useGuiResources)
- m_storage = resourceManager->guiThreadStorages()->Reserve();
+ m_storage = resourceManager->storagePool(ESmallStorage)->Reserve();
else
{
- switch (m_type)
+ if (m_storageType != EInvalidStorage)
+ m_storage = resourceManager->storagePool(m_storageType)->Reserve();
+ else
{
- case ResourceCache::EPrimary:
- m_storage = resourceManager->primaryStorages()->Reserve();
- break;
- case ResourceCache::EFonts:
- m_storage = resourceManager->smallStorages()->Reserve();
- break;
- case ResourceCache::EStatic:
- m_storage = resourceManager->smallStorages()->Reserve();
- break;
- default:
LOG(LERROR, ("invalid storage type in checkStorage"));
+ return;
}
}
@@ -122,22 +115,14 @@ namespace graphics
{
TStoragePool * storagePool = 0;
if (pipeline.m_useGuiResources)
- storagePool = resourceManager()->guiThreadStorages();
+ storagePool = resourceManager()->storagePool(ESmallStorage);
else
- switch (pipeline.m_type)
+ if (pipeline.m_storageType != EInvalidStorage)
+ storagePool = resourceManager()->storagePool(pipeline.m_storageType);
+ else
{
- case ResourceCache::EPrimary:
- storagePool = resourceManager()->primaryStorages();
- break;
- case ResourceCache::EFonts:
- storagePool = resourceManager()->smallStorages();
- break;
- case ResourceCache::EStatic:
- storagePool = resourceManager()->smallStorages();
- break;
- default:
LOG(LERROR, ("invalid pipeline type in freePipeline"));
- break;
+ return;
}
base_t::freeStorage(pipeline.m_storage, storagePool);
@@ -155,8 +140,8 @@ namespace graphics
/// settings proper skin page type according to useGuiResources flag
if (m_useGuiResources)
for (size_t i = 0; i < m_skin->pagesCount(); ++i)
- if (m_skin->page(i)->type() != ResourceCache::EStatic)
- m_skin->page(i)->setType(ResourceCache::ELightWeight);
+ if (m_skin->page(i)->type() != EStaticTexture)
+ m_skin->page(i)->setType(ESmallTexture);
m_pipelines.resize(m_skin->pagesCount());
@@ -170,7 +155,25 @@ namespace graphics
m_pipelines[i].m_currentIndex = 0;
m_pipelines[i].m_hasStorage = false;
- m_pipelines[i].m_type = skin->page(i)->type();
+ m_pipelines[i].m_textureType = skin->page(i)->type();
+
+ switch(m_pipelines[i].m_textureType)
+ {
+ case ELargeTexture:
+ m_pipelines[i].m_storageType = ELargeStorage;
+ break;
+ case EMediumTexture:
+ m_pipelines[i].m_storageType = EMediumStorage;
+ break;
+ case ESmallTexture:
+ m_pipelines[i].m_storageType = ESmallStorage;
+ break;
+ case EStaticTexture:
+ m_pipelines[i].m_storageType = EMediumStorage;
+ break;
+ default:
+ LOG(LINFO, ("Unknown StorageType for TextureType detected!"));
+ };
m_pipelines[i].m_maxVertices = 0;
m_pipelines[i].m_maxIndices = 0;
@@ -220,9 +223,7 @@ namespace graphics
{
for (size_t i = 0; i < m_pipelines.size(); ++i)
if ((m_pipelines[i].m_verticesDrawn != 0) || (m_pipelines[i].m_indicesDrawn != 0))
- {
LOG(LINFO, ("pipeline #", i, " vertices=", m_pipelines[i].m_verticesDrawn, ", triangles=", m_pipelines[i].m_indicesDrawn / 3));
- }
}
/// is the rendering was cancelled, there possibly could
@@ -310,22 +311,17 @@ namespace graphics
shared_ptr<gl::BaseTexture> texture = m_skin->page(pipelineID)->texture();
TTexturePool * texturePool = 0;
- switch (m_skin->page(pipelineID)->type())
+ ETextureType type = m_skin->page(pipelineID)->type();
+
+ if (type != EStaticTexture)
+ texturePool = resourceManager()->texturePool(type);
+ else
{
- case ResourceCache::EPrimary:
- texturePool = resourceManager()->primaryTextures();
- break;
- case ResourceCache::EFonts:
- texturePool = resourceManager()->fontTextures();
- break;
- case ResourceCache::ELightWeight:
- texturePool = resourceManager()->guiThreadTextures();
- break;
- case ResourceCache::EStatic:
LOG(LWARNING, ("texture with EStatic can't be freed."));
return;
}
+
base_t::freeTexture(texture, texturePool);
m_skin->page(pipelineID)->resetTexture();
diff --git a/graphics/geometry_batcher.hpp b/graphics/geometry_batcher.hpp
index 9b98c9319c..77cee2a8f1 100644
--- a/graphics/geometry_batcher.hpp
+++ b/graphics/geometry_batcher.hpp
@@ -61,7 +61,8 @@ namespace graphics
/// @}
bool m_useGuiResources;
- ResourceCache::EType m_type;
+ ETextureType m_textureType;
+ EStorageType m_storageType;
int verticesLeft();
int indicesLeft();
diff --git a/graphics/opengl/geometry_renderer.cpp b/graphics/opengl/geometry_renderer.cpp
index 5aafb552cb..1ba2a61ee9 100644
--- a/graphics/opengl/geometry_renderer.cpp
+++ b/graphics/opengl/geometry_renderer.cpp
@@ -135,9 +135,11 @@ namespace graphics
if (isDebugging())
LOG(LINFO, ("performing IMMDrawTexturedPrimitives command"));
- graphics::gl::Storage blitStorage = m_resourceManager->blitStorages()->Reserve();
+ TStoragePool * storagePool = m_resourceManager->storagePool(ESmallStorage);
- if (m_resourceManager->blitStorages()->IsCancelled())
+ graphics::gl::Storage blitStorage = storagePool->Reserve();
+
+ if (storagePool->IsCancelled())
{
LOG(LDEBUG, ("skipping IMMDrawTexturedPrimitives on cancelled multiBlitStorages pool"));
return;
@@ -194,7 +196,7 @@ namespace graphics
blitStorage.m_vertices->discard();
blitStorage.m_indices->discard();
- m_resourceManager->blitStorages()->Free(blitStorage);
+ storagePool->Free(blitStorage);
}
void GeometryRenderer::DrawGeometry::perform()
diff --git a/graphics/opengl/storage.cpp b/graphics/opengl/storage.cpp
index 8412fd2a7b..41f0a231fc 100644
--- a/graphics/opengl/storage.cpp
+++ b/graphics/opengl/storage.cpp
@@ -14,5 +14,10 @@ namespace graphics
m_vertices(new BufferObject(vbSize, GL_ARRAY_BUFFER)),
m_indices(new BufferObject(ibSize, GL_ELEMENT_ARRAY_BUFFER))
{}
+
+ bool Storage::isValid() const
+ {
+ return m_vertices.get();
+ }
}
}
diff --git a/graphics/opengl/storage.hpp b/graphics/opengl/storage.hpp
index 82e49e1366..f1bc12d60b 100644
--- a/graphics/opengl/storage.hpp
+++ b/graphics/opengl/storage.hpp
@@ -16,6 +16,8 @@ namespace graphics
Storage();
Storage(size_t vbSize, size_t ibSize);
+
+ bool isValid() const;
};
}
}
diff --git a/graphics/resource_cache.cpp b/graphics/resource_cache.cpp
index 64e811bc13..88159c96f9 100644
--- a/graphics/resource_cache.cpp
+++ b/graphics/resource_cache.cpp
@@ -16,7 +16,7 @@ namespace graphics
typedef gl::Texture<DATA_TRAITS, true> TDynamicTexture;
ResourceCache::ResourceCache()
- : m_type(EStatic),
+ : m_textureType(EStaticTexture),
m_pipelineID(0)
{}
@@ -25,16 +25,16 @@ namespace graphics
uint8_t pipelineID)
: m_texture(resourceManager->getTexture(name)),
m_packer(m_texture->width(), m_texture->height(), 0x00FFFFFF - 1),
- m_type(EStatic),
+ m_textureType(EStaticTexture),
m_pipelineID(pipelineID)
{
}
ResourceCache::ResourceCache(shared_ptr<ResourceManager> const & resourceManager,
- EType type,
+ ETextureType type,
uint8_t pipelineID)
: m_resourceManager(resourceManager),
- m_type(type),
+ m_textureType(type),
m_pipelineID(pipelineID)
{
createPacker();
@@ -307,17 +307,17 @@ namespace graphics
return m_packer.hasRoom(p.x, p.y);
}
- void ResourceCache::setType(ResourceCache::EType type)
+ void ResourceCache::setType(ETextureType textureType)
{
- m_type = type;
+ m_textureType = textureType;
createPacker();
- if (m_type != EStatic)
+ if (m_textureType != EStaticTexture)
m_packer.addOverflowFn(bind(&ResourceCache::clearHandles, this), 0);
}
- ResourceCache::EType ResourceCache::type() const
+ ETextureType ResourceCache::type() const
{
- return m_type;
+ return m_textureType;
}
bool ResourceCache::hasData()
@@ -332,7 +332,7 @@ namespace graphics
void ResourceCache::checkTexture() const
{
- if ((m_type != EStatic) && (m_texture == 0))
+ if ((m_textureType != EStaticTexture) && (m_texture == 0))
reserveTexture();
}
@@ -384,44 +384,20 @@ namespace graphics
void ResourceCache::reserveTexture() const
{
- switch (m_type)
- {
- case EPrimary:
- m_texture = m_resourceManager->primaryTextures()->Reserve();
- break;
- case EFonts:
- m_texture = m_resourceManager->fontTextures()->Reserve();
- break;
- case ELightWeight:
- m_texture = m_resourceManager->guiThreadTextures()->Reserve();
- break;
- default:
+ if (m_textureType != EStaticTexture)
+ m_texture = m_resourceManager->texturePool(m_textureType)->Reserve();
+ else
LOG(LINFO, ("reserveTexture call for with invalid type param"));
- }
}
void ResourceCache::createPacker()
{
- switch (m_type)
- {
- case EPrimary:
- m_packer = m2::Packer(m_resourceManager->params().m_primaryTexturesParams.m_texWidth,
- m_resourceManager->params().m_primaryTexturesParams.m_texHeight,
- 0x00FFFFFF - 1);
- break;
- case EFonts:
- m_packer = m2::Packer(m_resourceManager->params().m_fontTexturesParams.m_texWidth,
- m_resourceManager->params().m_fontTexturesParams.m_texHeight,
+ if (m_textureType != EStaticTexture)
+ m_packer = m2::Packer(m_resourceManager->params().m_textureParams[m_textureType].m_texWidth,
+ m_resourceManager->params().m_textureParams[m_textureType].m_texHeight,
0x00FFFFFF - 1);
- break;
- case ELightWeight:
- m_packer = m2::Packer(m_resourceManager->params().m_guiThreadTexturesParams.m_texWidth,
- m_resourceManager->params().m_guiThreadTexturesParams.m_texHeight,
- 0x00FFFFFF - 1);
- break;
- default:
+ else
LOG(LINFO, ("createPacker call for invalid type param"));
- }
}
shared_ptr<ResourceManager> const & ResourceCache::resourceManager() const
diff --git a/graphics/resource_cache.hpp b/graphics/resource_cache.hpp
index 56e74cd0e8..d9f6ea0b92 100644
--- a/graphics/resource_cache.hpp
+++ b/graphics/resource_cache.hpp
@@ -11,6 +11,7 @@
#include "glyph_cache.hpp"
#include "image_info.hpp"
#include "packets_queue.hpp"
+#include "defines.hpp"
namespace graphics
{
@@ -28,14 +29,6 @@ namespace graphics
{
public:
- enum EType
- {
- EStatic,
- EPrimary,
- EFonts,
- ELightWeight
- };
-
typedef m2::Packer::overflowFn overflowFn;
typedef vector<shared_ptr<ResourceStyle> > TUploadQueue;
@@ -73,7 +66,8 @@ namespace graphics
TUploadQueue m_uploadQueue;
- EType m_type;
+ ETextureType m_textureType;
+ EStorageType m_storageType;
uint32_t m_pipelineID;
/// number of pending rendering commands,
@@ -106,12 +100,12 @@ namespace graphics
/// creation of a static page
ResourceCache(shared_ptr<ResourceManager> const & resourceManager,
- char const * name,
- uint8_t pipelineID);
+ char const * name,
+ uint8_t pipelineID);
/// creation of a dynamic page
ResourceCache(shared_ptr<ResourceManager> const & resourceManager,
- EType type,
+ ETextureType type,
uint8_t pipelineID);
void reserveTexture() const;
@@ -143,8 +137,8 @@ namespace graphics
ResourceStyle * fromID(uint32_t idx) const;
- void setType(EType type);
- EType type() const;
+ void setType(ETextureType textureType);
+ ETextureType type() const;
shared_ptr<ResourceManager> const & resourceManager() const;
void addOverflowFn(overflowFn fn, int priority);
diff --git a/graphics/resource_manager.cpp b/graphics/resource_manager.cpp
index 5f181583c6..469a31a90e 100644
--- a/graphics/resource_manager.cpp
+++ b/graphics/resource_manager.cpp
@@ -93,243 +93,82 @@ namespace graphics
}
}
- ResourceManager::StoragePoolParams::StoragePoolParams(string const & poolName)
- : m_vbSize(0),
- m_vertexSize(0),
- m_ibSize(0),
- m_indexSize(0),
- m_storagesCount(0),
- m_isFixedBufferSize(true),
- m_isFixedBufferCount(true),
- m_scalePriority(0),
- m_poolName(poolName),
- m_isDebugging(false),
- m_allocateOnDemand(false)
- {}
-
ResourceManager::StoragePoolParams::StoragePoolParams(size_t vbSize,
size_t vertexSize,
size_t ibSize,
size_t indexSize,
size_t storagesCount,
- bool isFixedBufferSize,
- bool isFixedBufferCount,
- int scalePriority,
- string const & poolName,
- bool isDebugging,
- bool allocateOnDemand)
+ EStorageType storageType,
+ bool isDebugging)
: m_vbSize(vbSize),
m_vertexSize(vertexSize),
m_ibSize(ibSize),
m_indexSize(indexSize),
m_storagesCount(storagesCount),
- m_isFixedBufferSize(isFixedBufferSize),
- m_isFixedBufferCount(isFixedBufferCount),
- m_scalePriority(scalePriority),
- m_poolName(poolName),
- m_isDebugging(isDebugging),
- m_allocateOnDemand(allocateOnDemand)
+ m_storageType(storageType),
+ m_isDebugging(isDebugging)
{}
- bool ResourceManager::StoragePoolParams::isFixed() const
- {
- return m_isFixedBufferSize && m_isFixedBufferCount;
- }
+ ResourceManager::StoragePoolParams::StoragePoolParams(EStorageType storageType)
+ : m_vbSize(0),
+ m_vertexSize(0),
+ m_ibSize(0),
+ m_indexSize(0),
+ m_storagesCount(0),
+ m_storageType(storageType),
+ m_isDebugging(false)
+ {}
+
+ ResourceManager::StoragePoolParams::StoragePoolParams()
+ : m_vbSize(0),
+ m_vertexSize(0),
+ m_ibSize(0),
+ m_indexSize(0),
+ m_storagesCount(0),
+ m_storageType(EInvalidStorage),
+ m_isDebugging(false)
+ {}
bool ResourceManager::StoragePoolParams::isValid() const
{
return m_vbSize && m_ibSize && m_storagesCount;
}
- size_t ResourceManager::StoragePoolParams::memoryUsage() const
- {
- return (m_vbSize + m_ibSize) * m_storagesCount;
- }
-
- void ResourceManager::StoragePoolParams::scaleMemoryUsage(double k)
- {
-#ifndef OMIM_PRODUCTION
- int oldMemoryUsage = memoryUsage();
- int oldVBSize = m_vbSize;
- int oldIBSize = m_ibSize;
- int oldStoragesCount = m_storagesCount;
-#endif
-
- if (!m_isFixedBufferSize)
- {
- m_vbSize *= k;
- m_ibSize *= k;
- k = 1;
- }
-
- if (!m_isFixedBufferCount)
- m_storagesCount *= k;
-
-#ifndef OMIM_PRODUCTION
- LOG(LINFO, ("resizing", m_poolName));
- LOG(LINFO, ("from:", oldVBSize / m_vertexSize, "vertices,", oldIBSize / m_indexSize, "indices,", oldStoragesCount, "storages,", oldMemoryUsage, "bytes total"));
- LOG(LINFO, ("to :", m_vbSize / m_vertexSize, "vertices,", m_ibSize / m_indexSize, "indices,", m_storagesCount, "storages,", memoryUsage(), "bytes total"));
-#endif
- }
-
- void ResourceManager::StoragePoolParams::distributeFreeMemory(int freeVideoMemory)
- {
- if (!isFixed())
- {
- double k = (freeVideoMemory * m_scaleFactor + memoryUsage()) / memoryUsage();
- scaleMemoryUsage(k);
- }
- else
- {
-#ifndef OMIM_PRODUCTION
- 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"));
-#endif
- }
- }
-
- ResourceManager::TexturePoolParams::TexturePoolParams(string const & poolName)
- : m_texWidth(0),
- m_texHeight(0),
- m_texCount(0),
- m_format(graphics::Data8Bpp),
- m_isWidthFixed(true),
- m_isHeightFixed(true),
- m_isCountFixed(true),
- m_scalePriority(0),
- m_poolName(poolName),
- m_isDebugging(false),
- m_allocateOnDemand(false)
- {}
-
ResourceManager::TexturePoolParams::TexturePoolParams(size_t texWidth,
size_t texHeight,
size_t texCount,
graphics::DataFormat format,
- bool isWidthFixed,
- bool isHeightFixed,
- bool isCountFixed,
- int scalePriority,
- string const & poolName,
- bool isDebugging,
- bool allocateOnDemand)
+ ETextureType textureType,
+ bool isDebugging)
: m_texWidth(texWidth),
m_texHeight(texHeight),
m_texCount(texCount),
m_format(format),
- m_isWidthFixed(isWidthFixed),
- m_isHeightFixed(isHeightFixed),
- m_isCountFixed(isCountFixed),
- m_scalePriority(scalePriority),
- m_poolName(poolName),
- m_isDebugging(isDebugging),
- m_allocateOnDemand(allocateOnDemand)
+ m_textureType(textureType),
+ m_isDebugging(isDebugging)
{}
- bool ResourceManager::TexturePoolParams::isFixed() const
- {
- return m_isWidthFixed && m_isHeightFixed && m_isCountFixed;
- }
+ ResourceManager::TexturePoolParams::TexturePoolParams(ETextureType textureType)
+ : m_texWidth(0),
+ m_texHeight(0),
+ m_texCount(0),
+ m_textureType(textureType),
+ m_isDebugging(false)
+ {}
+
+ ResourceManager::TexturePoolParams::TexturePoolParams()
+ : m_texWidth(0),
+ m_texHeight(0),
+ m_texCount(0),
+ m_textureType(EInvalidTexture),
+ m_isDebugging(false)
+ {}
bool ResourceManager::TexturePoolParams::isValid() const
{
return m_texWidth && m_texHeight && m_texCount;
}
- size_t ResourceManager::TexturePoolParams::memoryUsage() const
- {
- size_t pixelSize = 0;
- switch (m_format)
- {
- case graphics::Data4Bpp:
- pixelSize = 2;
- break;
- case graphics::Data8Bpp:
- pixelSize = 4;
- break;
- case graphics::Data565Bpp:
- pixelSize = 2;
- break;
- }
-
- return m_texWidth * m_texHeight * pixelSize * m_texCount;
- }
-
- void ResourceManager::TexturePoolParams::distributeFreeMemory(int freeVideoMemory)
- {
- if (!isFixed())
- {
- double k = (freeVideoMemory * m_scaleFactor + memoryUsage()) / memoryUsage();
- scaleMemoryUsage(k);
- }
- else
- {
-#ifndef OMIM_PRODUCTION
- if (m_texWidth && m_texHeight && m_texCount)
- LOG(LINFO, (m_poolName, " : ", m_texWidth, "x", m_texHeight, ", ", m_texCount, " textures, ", memoryUsage(), " bytes total"));
-#endif
- }
- }
-
- void ResourceManager::TexturePoolParams::scaleMemoryUsage(double k)
- {
-#ifndef OMIM_PRODUCTION
- int oldTexCount = m_texCount;
- int oldTexWidth = m_texWidth;
- int oldTexHeight = m_texHeight;
- int oldMemoryUsage = memoryUsage();
-#endif
-
- if (!m_isWidthFixed || !m_isHeightFixed)
- {
- if (k > 1)
- {
- while (k > 2)
- {
- if ((k > 2) && (!m_isWidthFixed))
- {
- m_texWidth *= 2;
- k /= 2;
- }
-
- if ((k > 2) && (!m_isHeightFixed))
- {
- m_texHeight *= 2;
- k /= 2;
- }
- }
- }
- else
- {
- if (k < 1)
- {
- while (k < 1)
- {
- if ((k < 0.5) && (!m_isWidthFixed))
- {
- m_texHeight /= 2;
- k *= 2;
- }
-
- if ((k < 0.5) && (!m_isHeightFixed))
- {
- m_texWidth /= 2;
- k *= 2;
- }
- }
- }
- }
- }
-
- if (!m_isCountFixed)
- m_texCount *= k;
-#ifndef OMIM_PRODUCTION
- 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"));
-#endif
- }
-
ResourceManager::GlyphCacheParams::GlyphCacheParams()
: m_glyphCacheMemoryLimit(0)
{}
@@ -365,19 +204,15 @@ namespace
m_texRtFormat(graphics::Data4Bpp),
m_useSingleThreadedOGL(false),
m_videoMemoryLimit(0),
- m_primaryStoragesParams("primaryStorage"),
- m_smallStoragesParams("smallStorage"),
- m_blitStoragesParams("blitStorage"),
- m_multiBlitStoragesParams("multiBlitStorage"),
- m_guiThreadStoragesParams("tinyStorage"),
- m_primaryTexturesParams("primaryTexture"),
- m_fontTexturesParams("fontTexture"),
- m_renderTargetTexturesParams("renderTargetTexture"),
- m_styleCacheTexturesParams("styleCacheTexture"),
- m_guiThreadTexturesParams("guiThreadTexture"),
m_renderThreadsCount(0),
m_threadSlotsCount(0)
{
+ for (unsigned i = 0; i < EInvalidStorage + 1; ++i)
+ m_storageParams.push_back(ResourceManager::StoragePoolParams(EStorageType(i)));
+
+ for (unsigned i = 0; i < EInvalidTexture + 1; ++i)
+ m_textureParams.push_back(ResourceManager::TexturePoolParams(ETextureType(i)));
+
GetGLStringSafe(GL_VENDOR, m_vendorName);
GetGLStringSafe(GL_RENDERER, m_rendererName);
}
@@ -437,130 +272,23 @@ namespace
LOG(LINFO, ("using ReadPixels instead of glFinish to synchronize"));
}
- void ResourceManager::Params::fitIntoLimits()
- {
- initScaleWeights();
-
- int oldMemoryUsage = memoryUsage();
-
- int videoMemoryLimit = m_videoMemoryLimit;
-
- if (videoMemoryLimit == 0)
- {
- videoMemoryLimit = memoryUsage();
- LOG(LINFO, ("videoMemoryLimit is not set. will not scale resource usage."));
- }
-
- if (videoMemoryLimit < fixedMemoryUsage())
- {
- LOG(LINFO, ("videoMemoryLimit", videoMemoryLimit, "is less than an amount of fixed resources", fixedMemoryUsage()));
- videoMemoryLimit = memoryUsage();
- }
-
- if (videoMemoryLimit < memoryUsage())
- {
- LOG(LINFO, ("videoMemoryLimit", videoMemoryLimit, "is less than amount of currently allocated resources", memoryUsage()));
- videoMemoryLimit = memoryUsage();
- }
-
- int freeVideoMemory = videoMemoryLimit - oldMemoryUsage;
-
- /// distributing free memory according to the weights
- distributeFreeMemory(freeVideoMemory);
-
- LOG(LINFO, ("resizing from", oldMemoryUsage, "bytes to", memoryUsage(), "bytes of video memory"));
- }
-
- int ResourceManager::Params::memoryUsage() const
- {
- return m_primaryStoragesParams.memoryUsage()
- + m_smallStoragesParams.memoryUsage()
- + m_blitStoragesParams.memoryUsage()
- + m_multiBlitStoragesParams.memoryUsage()
- + m_guiThreadStoragesParams.memoryUsage()
- + m_primaryTexturesParams.memoryUsage()
- + m_fontTexturesParams.memoryUsage()
- + m_renderTargetTexturesParams.memoryUsage()
- + m_styleCacheTexturesParams.memoryUsage()
- + m_guiThreadTexturesParams.memoryUsage();
- }
-
- 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_guiThreadStoragesParams.isFixed() ? m_guiThreadStoragesParams.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)
- + (m_guiThreadTexturesParams.isFixed() ? m_guiThreadTexturesParams.memoryUsage() : 0);
- }
-
- void ResourceManager::Params::distributeFreeMemory(int freeVideoMemory)
- {
- m_primaryStoragesParams.distributeFreeMemory(freeVideoMemory);
- m_smallStoragesParams.distributeFreeMemory(freeVideoMemory);
- m_blitStoragesParams.distributeFreeMemory(freeVideoMemory);
- m_multiBlitStoragesParams.distributeFreeMemory(freeVideoMemory);
- m_guiThreadStoragesParams.distributeFreeMemory(freeVideoMemory);
-
- m_primaryTexturesParams.distributeFreeMemory(freeVideoMemory);
- m_fontTexturesParams.distributeFreeMemory(freeVideoMemory);
- m_renderTargetTexturesParams.distributeFreeMemory(freeVideoMemory);
- m_styleCacheTexturesParams.distributeFreeMemory(freeVideoMemory);
- m_guiThreadTexturesParams.distributeFreeMemory(freeVideoMemory);
- }
-
ResourceManager::ResourceManager(Params const & p)
: m_params(p)
{
initThreadSlots(p);
- 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_guiThreadStoragesParams, m_guiThreadStorages);
+ m_storagePools.resize(EInvalidStorage + 1);
- initTexturePool(p.m_primaryTexturesParams, m_primaryTextures);
- initTexturePool(p.m_fontTexturesParams, m_fontTextures);
- initTexturePool(p.m_renderTargetTexturesParams, m_renderTargets);
- initTexturePool(p.m_styleCacheTexturesParams, m_styleCacheTextures);
- initTexturePool(p.m_guiThreadTexturesParams, m_guiThreadTextures);
+ for (unsigned i = 0; i < EInvalidStorage + 1; ++i)
+ initStoragePool(p.m_storageParams[i], m_storagePools[i]);
- if (!graphics::gl::g_isBufferObjectsSupported)
- 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_guiThreadStoragesParams.isFixed() ? 0 : m_guiThreadStoragesParams.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)
- + (m_guiThreadTexturesParams.isFixed() ? 0 : m_guiThreadTexturesParams.m_scalePriority);
+ m_texturePools.resize(EInvalidTexture + 1);
- if (prioritySum == 0)
- return;
+ for (unsigned i = 0; i < EInvalidTexture + 1; ++i)
+ initTexturePool(p.m_textureParams[i], m_texturePools[i]);
- 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_guiThreadStoragesParams.m_scaleFactor = m_guiThreadStoragesParams.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;
- m_guiThreadTexturesParams.m_scaleFactor = m_guiThreadTexturesParams.m_scalePriority / prioritySum;
+ if (!graphics::gl::g_isBufferObjectsSupported)
+ LOG(LINFO, ("buffer objects are unsupported. using client vertex array instead."));
}
void ResourceManager::initThreadSlots(Params const & p)
@@ -594,59 +322,58 @@ namespace
}
}
- void ResourceManager::initStoragePool(StoragePoolParams const & p, scoped_ptr<TStoragePool> & pool)
+ void ResourceManager::initStoragePool(StoragePoolParams const & p, shared_ptr<TStoragePool> & pool)
{
if (p.isValid())
{
- LOG(LINFO, ("initializing", p.m_poolName, "resource pool. vbSize=", p.m_vbSize, ", ibSize=", p.m_ibSize));
- TStorageFactory storageFactory(p.m_vbSize, p.m_ibSize, m_params.m_useSingleThreadedOGL, p.m_poolName.c_str(), p.m_allocateOnDemand ? p.m_storagesCount : 0);
+ LOG(LINFO, ("initializing", convert(p.m_storageType), "resource pool. vbSize=", p.m_vbSize, ", ibSize=", p.m_ibSize));
+ TStorageFactory storageFactory(p.m_vbSize,
+ p.m_ibSize,
+ m_params.m_useSingleThreadedOGL,
+ convert(p.m_storageType),
+ p.m_storagesCount);
if (m_params.m_useSingleThreadedOGL)
- {
- if (p.m_allocateOnDemand)
- pool.reset(new TOnDemandSingleThreadedStoragePoolImpl(new TOnDemandSingleThreadedStoragePoolTraits(storageFactory, p.m_storagesCount)));
- else
- pool.reset(new TFixedSizeMergeableStoragePoolImpl(new TFixedSizeMergeableStoragePoolTraits(storageFactory, p.m_storagesCount)));
- }
+ pool.reset(new TOnDemandSingleThreadedStoragePoolImpl(new TOnDemandSingleThreadedStoragePoolTraits(storageFactory, p.m_storagesCount)));
else
- {
- if (p.m_allocateOnDemand)
- pool.reset(new TOnDemandMultiThreadedStoragePoolImpl(new TOnDemandMultiThreadedStoragePoolTraits(storageFactory, p.m_storagesCount)));
- else
- pool.reset(new TFixedSizeNonMergeableStoragePoolImpl(new TFixedSizeNonMergeableStoragePoolTraits(storageFactory, p.m_storagesCount)));
- }
+ pool.reset(new TOnDemandMultiThreadedStoragePoolImpl(new TOnDemandMultiThreadedStoragePoolTraits(storageFactory, p.m_storagesCount)));
pool->SetIsDebugging(p.m_isDebugging);
}
else
- LOG(LINFO, ("no ", p.m_poolName, " resource"));
+ LOG(LINFO, ("no ", convert(p.m_storageType), " resource"));
}
- void ResourceManager::initTexturePool(TexturePoolParams const & p, scoped_ptr<TTexturePool> & pool)
+ TStoragePool * ResourceManager::storagePool(EStorageType type)
+ {
+ return m_storagePools[type].get();
+ }
+
+ void ResourceManager::initTexturePool(TexturePoolParams const & p,
+ shared_ptr<TTexturePool> & pool)
{
if (p.isValid())
{
- TTextureFactory textureFactory(p.m_texWidth, p.m_texHeight, p.m_format, p.m_poolName.c_str(), p.m_allocateOnDemand ? p.m_texCount : 0);
+ TTextureFactory textureFactory(p.m_texWidth,
+ p.m_texHeight,
+ p.m_format,
+ convert(p.m_textureType),
+ p.m_texCount);
if (m_params.m_useSingleThreadedOGL)
- {
- if (p.m_allocateOnDemand)
- pool.reset(new TOnDemandSingleThreadedTexturePoolImpl(new TOnDemandSingleThreadedTexturePoolTraits(textureFactory, p.m_texCount)));
- else
- pool.reset(new TFixedSizeTexturePoolImpl(new TFixedSizeTexturePoolTraits(textureFactory, p.m_texCount)));
- }
+ pool.reset(new TOnDemandSingleThreadedTexturePoolImpl(new TOnDemandSingleThreadedTexturePoolTraits(textureFactory, p.m_texCount)));
else
- {
- if (p.m_allocateOnDemand)
- pool.reset(new TOnDemandMultiThreadedTexturePoolImpl(new TOnDemandMultiThreadedTexturePoolTraits(textureFactory, p.m_texCount)));
- else
- pool.reset(new TFixedSizeTexturePoolImpl(new TFixedSizeTexturePoolTraits(textureFactory, p.m_texCount)));
- }
+ pool.reset(new TOnDemandMultiThreadedTexturePoolImpl(new TOnDemandMultiThreadedTexturePoolTraits(textureFactory, p.m_texCount)));
pool->SetIsDebugging(p.m_isDebugging);
}
else
- LOG(LINFO, ("no ", p.m_poolName, " resource"));
+ LOG(LINFO, ("no ", convert(p.m_textureType), " resource"));
+ }
+
+ TTexturePool * ResourceManager::texturePool(ETextureType type)
+ {
+ return m_texturePools[type].get();
}
shared_ptr<gl::BaseTexture> const & ResourceManager::getTexture(string const & fileName)
@@ -710,70 +437,26 @@ namespace
{
threads::MutexGuard guard(m_mutex);
- if (m_primaryStorages.get())
- m_primaryStorages->EnterBackground();
+ for (unsigned i = 0; i < m_texturePools.size(); ++i)
+ if (m_texturePools[i].get())
+ m_texturePools[i]->EnterBackground();
- if (m_smallStorages.get())
- m_smallStorages->EnterBackground();
-
- if (m_blitStorages.get())
- m_blitStorages->EnterBackground();
-
- if (m_multiBlitStorages.get())
- m_multiBlitStorages->EnterBackground();
-
- if (m_guiThreadStorages.get())
- m_guiThreadStorages->EnterBackground();
-
- if (m_primaryTextures.get())
- m_primaryTextures->EnterBackground();
-
- if (m_fontTextures.get())
- m_fontTextures->EnterBackground();
-
- if (m_renderTargets.get())
- m_renderTargets->EnterBackground();
-
- if (m_styleCacheTextures.get())
- m_styleCacheTextures->EnterBackground();
-
- if (m_guiThreadTextures.get())
- m_guiThreadTextures->EnterBackground();
+ for (unsigned i = 0; i < m_storagePools.size(); ++i)
+ if (m_storagePools[i].get())
+ m_storagePools[i]->EnterBackground();
}
void ResourceManager::enterForeground()
{
threads::MutexGuard guard(m_mutex);
- if (m_primaryStorages.get())
- m_primaryStorages->EnterForeground();
-
- if (m_smallStorages.get())
- m_smallStorages->EnterForeground();
-
- if (m_blitStorages.get())
- m_blitStorages->EnterForeground();
-
- if (m_multiBlitStorages.get())
- m_multiBlitStorages->EnterForeground();
-
- if (m_guiThreadStorages.get())
- m_guiThreadStorages->EnterForeground();
+ for (unsigned i = 0; i < m_texturePools.size(); ++i)
+ if (m_texturePools[i].get())
+ m_texturePools[i]->EnterForeground();
- if (m_primaryTextures.get())
- m_primaryTextures->EnterForeground();
-
- if (m_fontTextures.get())
- m_fontTextures->EnterForeground();
-
- if (m_renderTargets.get())
- m_renderTargets->EnterForeground();
-
- if (m_styleCacheTextures.get())
- m_styleCacheTextures->EnterForeground();
-
- if (m_guiThreadTextures.get())
- m_guiThreadTextures->EnterForeground();
+ for (unsigned i = 0; i < m_storagePools.size(); ++i)
+ if (m_storagePools[i].get())
+ m_storagePools[i]->EnterForeground();
}
shared_ptr<graphics::gl::BaseTexture> ResourceManager::createRenderTarget(unsigned w, unsigned h)
@@ -807,104 +490,26 @@ namespace
return 1 + m_params.m_renderThreadsCount;
}
- TStoragePool * ResourceManager::primaryStorages()
- {
- return m_primaryStorages.get();
- }
-
- TStoragePool * ResourceManager::smallStorages()
- {
- return m_smallStorages.get();
- }
-
- TStoragePool * ResourceManager::guiThreadStorages()
- {
- return m_guiThreadStorages.get();
- }
-
- TStoragePool * ResourceManager::blitStorages()
- {
- return m_blitStorages.get();
- }
-
- TStoragePool * ResourceManager::multiBlitStorages()
- {
- return m_multiBlitStorages.get();
- }
-
- TTexturePool * ResourceManager::primaryTextures()
- {
- return m_primaryTextures.get();
- }
-
- TTexturePool * ResourceManager::fontTextures()
- {
- return m_fontTextures.get();
- }
-
- TTexturePool * ResourceManager::renderTargetTextures()
- {
- return m_renderTargets.get();
- }
-
- TTexturePool * ResourceManager::styleCacheTextures()
- {
- return m_styleCacheTextures.get();
- }
-
- TTexturePool * ResourceManager::guiThreadTextures()
- {
- return m_guiThreadTextures.get();
- }
-
void ResourceManager::updatePoolState()
{
- if (m_primaryTextures.get())
- m_primaryTextures->UpdateState();
- if (m_fontTextures.get())
- m_fontTextures->UpdateState();
- if (m_styleCacheTextures.get())
- m_styleCacheTextures->UpdateState();
- if (m_renderTargets.get())
- m_renderTargets->UpdateState();
- if (m_guiThreadTextures.get())
- m_guiThreadTextures->UpdateState();
-
- if (m_guiThreadStorages.get())
- m_guiThreadStorages->UpdateState();
- if (m_primaryStorages.get())
- m_primaryStorages->UpdateState();
- if (m_smallStorages.get())
- m_smallStorages->UpdateState();
- if (m_blitStorages.get())
- m_blitStorages->UpdateState();
- if (m_multiBlitStorages.get())
- m_multiBlitStorages->UpdateState();
+ for (unsigned i = 0; i < m_texturePools.size(); ++i)
+ if (m_texturePools[i].get())
+ m_texturePools[i]->UpdateState();
+
+ for (unsigned i = 0; i < m_storagePools.size(); ++i)
+ if (m_storagePools[i].get())
+ m_storagePools[i]->UpdateState();
}
void ResourceManager::cancel()
{
- if (m_primaryTextures.get())
- m_primaryTextures->Cancel();
- if (m_fontTextures.get())
- m_fontTextures->Cancel();
- if (m_styleCacheTextures.get())
- m_styleCacheTextures->Cancel();
- if (m_renderTargets.get())
- m_renderTargets->Cancel();
- if (m_guiThreadTextures.get())
- m_guiThreadTextures->Cancel();
-
- if (m_primaryStorages.get())
- m_primaryStorages->Cancel();
- if (m_smallStorages.get())
- m_smallStorages->Cancel();
- if (m_blitStorages.get())
- m_blitStorages->Cancel();
- if (m_multiBlitStorages.get())
- m_multiBlitStorages->Cancel();
- if (m_guiThreadStorages.get())
- m_guiThreadStorages->Cancel();
+ for (unsigned i = 0; i < m_texturePools.size(); ++i)
+ if (m_texturePools[i].get())
+ m_texturePools[i]->Cancel();
+
+ for (unsigned i = 0; i < m_storagePools.size(); ++i)
+ if (m_storagePools[i].get())
+ m_storagePools[i]->Cancel();
}
bool ResourceManager::useReadPixelsToSynchronize() const
diff --git a/graphics/resource_manager.hpp b/graphics/resource_manager.hpp
index bb73864129..9f6cf3da2f 100644
--- a/graphics/resource_manager.hpp
+++ b/graphics/resource_manager.hpp
@@ -1,7 +1,6 @@
#pragma once
#include "../std/shared_ptr.hpp"
-#include "../std/scoped_ptr.hpp"
#include "../std/map.hpp"
#include "../std/string.hpp"
#include "../std/list.hpp"
@@ -13,6 +12,7 @@
#include "opengl/program_manager.hpp"
#include "glyph_cache.hpp"
#include "data_formats.hpp"
+#include "defines.hpp"
namespace graphics
{
@@ -32,7 +32,11 @@ namespace graphics
size_t m_w;
size_t m_h;
graphics::DataFormat m_format;
- TTextureFactory(size_t w, size_t h, graphics::DataFormat format, char const * resName, size_t batchSize);
+ TTextureFactory(size_t w,
+ size_t h,
+ graphics::DataFormat format,
+ char const * resName,
+ size_t batchSize);
shared_ptr<gl::BaseTexture> const Create();
};
@@ -41,7 +45,11 @@ namespace graphics
size_t m_vbSize;
size_t m_ibSize;
bool m_useSingleThreadedOGL;
- TStorageFactory(size_t vbSize, size_t ibSize, bool useSingleThreadedOGL, char const * resName, size_t batchSize);
+ TStorageFactory(size_t vbSize,
+ size_t ibSize,
+ bool useSingleThreadedOGL,
+ char const * resName,
+ size_t batchSize);
gl::Storage const Create();
void BeforeMerge(gl::Storage const & e);
};
@@ -105,37 +113,20 @@ namespace graphics
size_t m_ibSize;
size_t m_indexSize;
size_t m_storagesCount;
-
- bool m_isFixedBufferSize;
- bool m_isFixedBufferCount;
-
- int m_scalePriority;
- double m_scaleFactor;
-
- string m_poolName;
-
+ EStorageType m_storageType;
bool m_isDebugging;
- bool m_allocateOnDemand;
+ StoragePoolParams();
+ StoragePoolParams(EStorageType storageType);
StoragePoolParams(size_t vbSize,
size_t vertexSize,
size_t ibSize,
size_t indexSize,
size_t storagesCount,
- bool isFixedBufferSize,
- bool isFixedBufferCount,
- int scalePriority,
- string const & poolName,
- bool isDebugging,
- bool allocateOnDemand);
-
- StoragePoolParams(string const & poolName);
+ EStorageType storageType,
+ bool isDebugging);
- bool isFixed() const;
bool isValid() const;
- void scaleMemoryUsage(double k);
- void distributeFreeMemory(int freeVideoMemory);
- size_t memoryUsage() const;
};
struct TexturePoolParams
@@ -144,38 +135,19 @@ namespace graphics
size_t m_texHeight;
size_t m_texCount;
graphics::DataFormat m_format;
-
- bool m_isWidthFixed;
- bool m_isHeightFixed;
- bool m_isCountFixed;
-
- int m_scalePriority;
- double m_scaleFactor;
-
- string m_poolName;
-
+ ETextureType m_textureType;
bool m_isDebugging;
- bool m_allocateOnDemand;
+ TexturePoolParams();
+ TexturePoolParams(ETextureType textureType);
TexturePoolParams(size_t texWidth,
size_t texHeight,
size_t texCount,
graphics::DataFormat format,
- bool isWidthFixed,
- bool isHeightFixed,
- bool isCountFixed,
- int scalePriority,
- string const & poolName,
- bool isDebugging,
- bool allocateOnDemand);
-
- TexturePoolParams(string const & poolName);
+ ETextureType textureType,
+ bool isDebugging);
- bool isFixed() const;
bool isValid() const;
- void scaleMemoryUsage(double k);
- void distributeFreeMemory(int freeVideoMemory);
- size_t memoryUsage() const;
};
struct GlyphCacheParams
@@ -186,7 +158,6 @@ namespace graphics
size_t m_glyphCacheMemoryLimit;
-
GlyphCacheParams();
GlyphCacheParams(string const & unicodeBlockFile,
string const & whiteListFile,
@@ -215,23 +186,12 @@ namespace graphics
size_t m_videoMemoryLimit;
/// storages params
-
- StoragePoolParams m_primaryStoragesParams;
- StoragePoolParams m_smallStoragesParams;
- StoragePoolParams m_blitStoragesParams;
- StoragePoolParams m_multiBlitStoragesParams;
- StoragePoolParams m_guiThreadStoragesParams;
+ vector<StoragePoolParams> m_storageParams;
/// textures params
-
- TexturePoolParams m_primaryTexturesParams;
- TexturePoolParams m_fontTexturesParams;
- TexturePoolParams m_renderTargetTexturesParams;
- TexturePoolParams m_styleCacheTexturesParams;
- TexturePoolParams m_guiThreadTexturesParams;
+ vector<TexturePoolParams> m_textureParams;
/// glyph caches params
-
GlyphCacheParams m_glyphCacheParams;
unsigned m_renderThreadsCount;
@@ -241,7 +201,6 @@ namespace graphics
void distributeFreeMemory(int freeVideoMemory);
void checkDeviceCaps();
- void fitIntoLimits();
int memoryUsage() const;
int fixedMemoryUsage() const;
void initScaleWeights();
@@ -255,17 +214,8 @@ namespace graphics
threads::Mutex m_mutex;
- scoped_ptr<TTexturePool> m_primaryTextures;
- scoped_ptr<TTexturePool> m_fontTextures;
- scoped_ptr<TTexturePool> m_styleCacheTextures;
- scoped_ptr<TTexturePool> m_renderTargets;
- scoped_ptr<TTexturePool> m_guiThreadTextures;
-
- scoped_ptr<TStoragePool> m_primaryStorages;
- scoped_ptr<TStoragePool> m_smallStorages;
- scoped_ptr<TStoragePool> m_blitStorages;
- scoped_ptr<TStoragePool> m_multiBlitStorages;
- scoped_ptr<TStoragePool> m_guiThreadStorages;
+ vector<shared_ptr<TTexturePool> > m_texturePools;
+ vector<shared_ptr<TStoragePool> > m_storagePools;
struct ThreadSlot
{
@@ -283,21 +233,13 @@ namespace graphics
void initThreadSlots(Params const & p);
- void initStoragePool(StoragePoolParams const & p, scoped_ptr<TStoragePool> & pool);
+ void initStoragePool(StoragePoolParams const & p, shared_ptr<TStoragePool> & pool);
- TStoragePool * primaryStorages();
- TStoragePool * smallStorages();
- TStoragePool * blitStorages();
- TStoragePool * multiBlitStorages();
- TStoragePool * guiThreadStorages();
+ TStoragePool * storagePool(EStorageType type);
- void initTexturePool(TexturePoolParams const & p, scoped_ptr<TTexturePool> & pool);
+ void initTexturePool(TexturePoolParams const & p, shared_ptr<TTexturePool> & pool);
- TTexturePool * primaryTextures();
- TTexturePool * fontTextures();
- TTexturePool * renderTargetTextures();
- TTexturePool * styleCacheTextures();
- TTexturePool * guiThreadTextures();
+ TTexturePool * texturePool(ETextureType type);
shared_ptr<gl::BaseTexture> const & getTexture(string const & fileName);
diff --git a/graphics/skin.cpp b/graphics/skin.cpp
index 8d103ed4d1..a64e643e54 100644
--- a/graphics/skin.cpp
+++ b/graphics/skin.cpp
@@ -36,7 +36,7 @@ namespace graphics
for (int i = 0; i < count; ++i)
{
uint8_t pipelineID = (uint8_t)m_caches.size();
- m_caches.push_back(make_shared_ptr(new ResourceCache(m_resourceManager, ResourceCache::EFonts, pipelineID)));
+ m_caches.push_back(make_shared_ptr(new ResourceCache(m_resourceManager, EMediumTexture, pipelineID)));
m_caches.back()->addOverflowFn(bind(&Skin::onTextOverflow, this, pipelineID), 0);
}
}
@@ -50,7 +50,7 @@ namespace graphics
for (int i = 0; i < count; ++i)
{
uint8_t pipelineID = (uint8_t)m_caches.size();
- m_caches.push_back(make_shared_ptr(new ResourceCache(m_resourceManager, ResourceCache::EPrimary, pipelineID)));
+ m_caches.push_back(make_shared_ptr(new ResourceCache(m_resourceManager, ELargeTexture, pipelineID)));
m_caches.back()->addOverflowFn(bind(&Skin::onDynamicOverflow, this, pipelineID), 0);
}
}
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);
diff --git a/qt_tstfrm/tstwidgets.cpp b/qt_tstfrm/tstwidgets.cpp
index c6bd4cf3b3..283b4a4b87 100644
--- a/qt_tstfrm/tstwidgets.cpp
+++ b/qt_tstfrm/tstwidgets.cpp
@@ -48,77 +48,57 @@ void GLDrawWidget::initializeGL()
rmp.m_texFormat = graphics::Data8Bpp;
rmp.m_videoMemoryLimit = 20 * 1024 * 1024;
- rmp.m_primaryStoragesParams = graphics::ResourceManager::StoragePoolParams(30000 * sizeof(graphics::gl::Vertex),
- sizeof(graphics::gl::Vertex),
- 50000 * sizeof(unsigned short),
- sizeof(unsigned short),
- 20,
- false,
- true,
- 1,
- "primaryStorage",
- false,
- false);
-
- rmp.m_smallStoragesParams = graphics::ResourceManager::StoragePoolParams(3000 * sizeof(graphics::gl::Vertex),
- sizeof(graphics::gl::Vertex),
- 5000 * 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),
- 30,
- true,
- true,
- 1,
- "blitStorage",
- false,
- false);
-
- rmp.m_multiBlitStoragesParams = graphics::ResourceManager::StoragePoolParams(500 * sizeof(graphics::gl::Vertex),
- sizeof(graphics::gl::Vertex),
- 500 * sizeof(unsigned short),
- sizeof(unsigned short),
- 10,
- true,
- true,
- 1,
- "multiBlitStorage",
- false,
- false);
-
- rmp.m_primaryTexturesParams = graphics::ResourceManager::TexturePoolParams(512,
- 512,
- 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::StoragePoolParams spp;
+ graphics::ResourceManager::TexturePoolParams tpp;
+
+ spp = graphics::ResourceManager::StoragePoolParams(30000 * sizeof(graphics::gl::Vertex),
+ sizeof(graphics::gl::Vertex),
+ 50000 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 20,
+ graphics::ELargeStorage,
+ false);
+
+ rmp.m_storageParams[graphics::ELargeStorage] = spp;
+
+ spp = graphics::ResourceManager::StoragePoolParams(3000 * sizeof(graphics::gl::Vertex),
+ sizeof(graphics::gl::Vertex),
+ 5000 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 100,
+ graphics::EMediumStorage,
+ false);
+
+ rmp.m_storageParams[graphics::EMediumStorage] = spp;
+
+ spp = graphics::ResourceManager::StoragePoolParams(500 * sizeof(graphics::gl::Vertex),
+ sizeof(graphics::gl::Vertex),
+ 500 * sizeof(unsigned short),
+ sizeof(unsigned short),
+ 10,
+ graphics::ESmallStorage,
+ false);
+
+ rmp.m_storageParams[graphics::ESmallStorage] = spp;
+
+ tpp = graphics::ResourceManager::TexturePoolParams(512,
+ 512,
+ 10,
+ rmp.m_texFormat,
+ graphics::ELargeTexture,
+ false);
+
+ rmp.m_textureParams[graphics::ELargeTexture] = tpp;
+
+ tpp = graphics::ResourceManager::TexturePoolParams(512,
+ 256,
+ 5,
+ rmp.m_texFormat,
+ graphics::ESmallTexture,
+ false);
+
+ rmp.m_textureParams[graphics::ESmallTexture];
rmp.m_glyphCacheParams = graphics::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
"fonts_whitelist.txt",