Load skybox first and sounds later

This commit is contained in:
Atlante45 2017-04-26 13:56:26 -07:00
parent 1555fc3088
commit 70ece9f0fd
3 changed files with 10 additions and 2 deletions

View file

@ -14,6 +14,8 @@
#include "AudioLogging.h"
#include "SoundCache.h"
static const int SOUNDS_LOADING_PRIORITY { -7 }; // Make sure sounds load after the low rez texture mips
int soundPointerMetaTypeId = qRegisterMetaType<SharedSoundPointer>();
SoundCache::SoundCache(QObject* parent) :
@ -37,5 +39,7 @@ SharedSoundPointer SoundCache::getSound(const QUrl& url) {
QSharedPointer<Resource> SoundCache::createResource(const QUrl& url, const QSharedPointer<Resource>& fallback,
const void* extra) {
qCDebug(audio) << "Requesting sound at" << url.toString();
return QSharedPointer<Resource>(new Sound(url), &Resource::deleter);
auto resource = QSharedPointer<Resource>(new Sound(url), &Resource::deleter);
resource->setLoadPriority(this, SOUNDS_LOADING_PRIORITY);
return resource;
}

View file

@ -50,6 +50,8 @@ Q_LOGGING_CATEGORY(trace_resource_parse_image_ktx, "trace.resource.parse.image.k
const std::string TextureCache::KTX_DIRNAME { "ktx_cache" };
const std::string TextureCache::KTX_EXT { "ktx" };
static const int SKYBOX_LOAD_PRIORITY { 10 }; // Make sure skybox loads first
TextureCache::TextureCache() :
_ktxCache(KTX_DIRNAME, KTX_EXT) {
setUnusedResourceCacheSize(0);
@ -259,6 +261,9 @@ QSharedPointer<Resource> TextureCache::createResource(const QUrl& url, const QSh
auto content = textureExtra ? textureExtra->content : QByteArray();
auto maxNumPixels = textureExtra ? textureExtra->maxNumPixels : ABSOLUTE_MAX_TEXTURE_NUM_PIXELS;
NetworkTexture* texture = new NetworkTexture(url, type, content, maxNumPixels);
if (type == image::TextureUsage::CUBE_TEXTURE) {
texture->setLoadPriority(this, SKYBOX_LOAD_PRIORITY);
}
return QSharedPointer<Resource>(texture, &Resource::deleter);
}

View file

@ -558,7 +558,6 @@ void ModelMeshPartPayload::render(RenderArgs* args) {
}
if (_materialNeedsUpdate && _model->getGeometry()->areTexturesLoaded()) {
qDebug() << "Updating for textures";
_model->setRenderItemsNeedUpdate();
_materialNeedsUpdate = false;
}