Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/TextureManager.cpp
Show All 22 Lines | |||||
#include "graphics/TextureConverter.h" | #include "graphics/TextureConverter.h" | ||||
#include "lib/allocators/shared_ptr.h" | #include "lib/allocators/shared_ptr.h" | ||||
#include "lib/bits.h" | #include "lib/bits.h" | ||||
#include "lib/file/vfs/vfs_tree.h" | #include "lib/file/vfs/vfs_tree.h" | ||||
#include "lib/hash.h" | #include "lib/hash.h" | ||||
#include "lib/timer.h" | #include "lib/timer.h" | ||||
#include "maths/MathUtil.h" | #include "maths/MathUtil.h" | ||||
#include "maths/MD5.h" | #include "maths/MD5.h" | ||||
#include "ps/Algorithm.h" | |||||
#include "ps/CacheLoader.h" | #include "ps/CacheLoader.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/ConfigDB.h" | #include "ps/ConfigDB.h" | ||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "ps/Profile.h" | #include "ps/Profile.h" | ||||
#include "ps/Util.h" | #include "ps/Util.h" | ||||
#include "renderer/backend/IDevice.h" | #include "renderer/backend/IDevice.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
▲ Show 20 Lines • Show All 666 Lines • ▼ Show 20 Lines | bool MakeProgress() | ||||
bool converterBusy = m_TextureConverter.IsBusy(); | bool converterBusy = m_TextureConverter.IsBusy(); | ||||
if (!converterBusy) | if (!converterBusy) | ||||
{ | { | ||||
// Look for all high-priority textures needing conversion. | // Look for all high-priority textures needing conversion. | ||||
// (Iterating over all textures isn't optimally efficient, but it | // (Iterating over all textures isn't optimally efficient, but it | ||||
// doesn't seem to be a problem yet and it's simpler than maintaining | // doesn't seem to be a problem yet and it's simpler than maintaining | ||||
// multiple queues.) | // multiple queues.) | ||||
for (TextureCache::iterator it = m_TextureCache.begin(); it != m_TextureCache.end(); ++it) | const TextureCache::const_iterator it = PS::Find(m_TextureCache, | ||||
{ | CTexture::HIGH_NEEDS_CONVERTING, &CTexture::m_State); | ||||
if ((*it)->m_State == CTexture::HIGH_NEEDS_CONVERTING) | |||||
if (it != m_TextureCache.end()) | |||||
{ | { | ||||
// Start converting this texture | // Start converting this texture | ||||
(*it)->m_State = CTexture::HIGH_IS_CONVERTING; | (*it)->m_State = CTexture::HIGH_IS_CONVERTING; | ||||
ConvertTexture(*it); | ConvertTexture(*it); | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
} | |||||
// Try loading prefetched textures from their cache | |||||
for (TextureCache::iterator it = m_TextureCache.begin(); it != m_TextureCache.end(); ++it) | |||||
{ | { | ||||
if ((*it)->m_State == CTexture::PREFETCH_NEEDS_LOADING) | // Try loading prefetched textures from their cache | ||||
const TextureCache::const_iterator it = PS::Find(m_TextureCache, | |||||
CTexture::PREFETCH_NEEDS_LOADING, &CTexture::m_State); | |||||
if (it != m_TextureCache.end()) | |||||
{ | { | ||||
if (TryLoadingCached(*it)) | if (TryLoadingCached(*it)) | ||||
{ | { | ||||
(*it)->m_State = CTexture::LOADED; | (*it)->m_State = CTexture::LOADED; | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
(*it)->m_State = CTexture::PREFETCH_NEEDS_CONVERTING; | (*it)->m_State = CTexture::PREFETCH_NEEDS_CONVERTING; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
// If we've got nothing better to do, then start converting prefetched textures. | // If we've got nothing better to do, then start converting prefetched textures. | ||||
if (!converterBusy) | if (!converterBusy) | ||||
{ | { | ||||
for (TextureCache::iterator it = m_TextureCache.begin(); it != m_TextureCache.end(); ++it) | const TextureCache::const_iterator it = PS::Find(m_TextureCache, | ||||
{ | CTexture::PREFETCH_NEEDS_CONVERTING, &CTexture::m_State); | ||||
if ((*it)->m_State == CTexture::PREFETCH_NEEDS_CONVERTING) | |||||
if (it != m_TextureCache.end()) | |||||
{ | { | ||||
(*it)->m_State = CTexture::PREFETCH_IS_CONVERTING; | (*it)->m_State = CTexture::PREFETCH_IS_CONVERTING; | ||||
ConvertTexture(*it); | ConvertTexture(*it); | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
} | |||||
return false; | return false; | ||||
} | } | ||||
bool MakeUploadProgress( | bool MakeUploadProgress( | ||||
Renderer::Backend::IDeviceCommandContext* deviceCommandContext) | Renderer::Backend::IDeviceCommandContext* deviceCommandContext) | ||||
{ | { | ||||
if (!m_PredefinedTexturesUploaded) | if (!m_PredefinedTexturesUploaded) | ||||
▲ Show 20 Lines • Show All 346 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator