mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
Set different caches size depending on cache type
This commit is contained in:
parent
59c9e0bb50
commit
8415098fc2
7 changed files with 25 additions and 5 deletions
|
@ -17,7 +17,10 @@
|
|||
static int animationPointerMetaTypeId = qRegisterMetaType<AnimationPointer>();
|
||||
|
||||
AnimationCache::AnimationCache(QObject* parent) :
|
||||
ResourceCache(parent) {
|
||||
ResourceCache(parent)
|
||||
{
|
||||
const qint64 ANIMATION_DEFAULT_UNUSED_MAX_SIZE = 50 * BYTES_PER_MEGABYTES;
|
||||
setUnusedResourceCacheSize(ANIMATION_DEFAULT_UNUSED_MAX_SIZE);
|
||||
}
|
||||
|
||||
AnimationPointer AnimationCache::getAnimation(const QUrl& url) {
|
||||
|
|
|
@ -23,7 +23,8 @@ SoundCache& SoundCache::getInstance() {
|
|||
SoundCache::SoundCache(QObject* parent) :
|
||||
ResourceCache(parent)
|
||||
{
|
||||
|
||||
const qint64 SOUND_DEFAULT_UNUSED_MAX_SIZE = 50 * BYTES_PER_MEGABYTES;
|
||||
setUnusedResourceCacheSize(SOUND_DEFAULT_UNUSED_MAX_SIZE);
|
||||
}
|
||||
|
||||
SharedSoundPointer SoundCache::getSound(const QUrl& url) {
|
||||
|
|
|
@ -109,9 +109,12 @@ ScriptCache* ScriptCache::getInstance() {
|
|||
}
|
||||
|
||||
ScriptCache::ScriptCache() :
|
||||
_engine(NULL) {
|
||||
|
||||
_engine(NULL)
|
||||
{
|
||||
setEngine(new QScriptEngine(this));
|
||||
|
||||
const qint64 SCRIPT_DEFAULT_UNUSED_MAX_SIZE = 50 * BYTES_PER_MEGABYTES;
|
||||
setUnusedResourceCacheSize(SCRIPT_DEFAULT_UNUSED_MAX_SIZE);
|
||||
}
|
||||
|
||||
void ScriptCache::setEngine(QScriptEngine* engine) {
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include <QTimer>
|
||||
#include <QtDebug>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "NetworkAccessManager.h"
|
||||
|
||||
#include "ResourceCache.h"
|
||||
|
@ -70,7 +72,7 @@ QSharedPointer<Resource> ResourceCache::getResource(const QUrl& url, const QUrl&
|
|||
}
|
||||
|
||||
void ResourceCache::setUnusedResourceCacheSize(qint64 unusedResourcesMaxSize) {
|
||||
_unusedResourcesMaxSize = unusedResourcesMaxSize;
|
||||
_unusedResourcesMaxSize = glm::clamp(unusedResourcesMaxSize, MIN_UNUSED_MAX_SIZE, MAX_UNUSED_MAX_SIZE);
|
||||
reserveUnusedResource(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,14 @@ class Resource;
|
|||
|
||||
static constexpr qint64 BYTES_PER_MEGABYTES = 1024 * 1024;
|
||||
static constexpr qint64 BYTES_PER_GIGABYTES = 1024 * BYTES_PER_MEGABYTES;
|
||||
|
||||
// Windows can have troubles allocating that much memory in ram sometimes
|
||||
// so default cache size at 100 MB on windows (1GB otherwise)
|
||||
#ifdef Q_OS_WIN32
|
||||
static constexpr qint64 DEFAULT_UNUSED_MAX_SIZE = 100 * BYTES_PER_MEGABYTES;
|
||||
#else
|
||||
static constexpr qint64 DEFAULT_UNUSED_MAX_SIZE = 1024 * BYTES_PER_MEGABYTES;
|
||||
#endif
|
||||
static constexpr qint64 MIN_UNUSED_MAX_SIZE = 0;
|
||||
static constexpr qint64 MAX_UNUSED_MAX_SIZE = 10 * BYTES_PER_GIGABYTES;
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ const int GeometryCache::UNKNOWN_ID = -1;
|
|||
GeometryCache::GeometryCache() :
|
||||
_nextID(0)
|
||||
{
|
||||
const qint64 GEOMETRY_DEFAULT_UNUSED_MAX_SIZE = DEFAULT_UNUSED_MAX_SIZE;
|
||||
setUnusedResourceCacheSize(GEOMETRY_DEFAULT_UNUSED_MAX_SIZE);
|
||||
}
|
||||
|
||||
GeometryCache::~GeometryCache() {
|
||||
|
|
|
@ -39,6 +39,8 @@ TextureCache::TextureCache() :
|
|||
_frameBufferSize(100, 100),
|
||||
_associatedWidget(NULL)
|
||||
{
|
||||
const qint64 TEXTURE_DEFAULT_UNUSED_MAX_SIZE = DEFAULT_UNUSED_MAX_SIZE;
|
||||
setUnusedResourceCacheSize(TEXTURE_DEFAULT_UNUSED_MAX_SIZE);
|
||||
}
|
||||
|
||||
TextureCache::~TextureCache() {
|
||||
|
|
Loading…
Reference in a new issue