ezEngine  Milestone 7
ezResourceManager Class Reference

Classes

struct  LoadingInfo
 
struct  ManagerEvent
 
struct  ResourceCategory
 
struct  ResourceEvent
 

Public Types

enum  ResourceEventType {
  ResourceExists, ResourceCreated, ResourceDeleted, ResourceContentUpdated,
  ResourceContentUnloaded, ResourceInPreloadQueue, ResourceOutOfPreloadQueue, ResourcePriorityChanged,
  ResourceDueDateChanged
}
 
enum  ManagerEventType { ManagerShuttingDown, ResourceCategoryChanged }
 

Public Member Functions

template<typename ResourceType >
ResourceType * GetResource (const char *szResourceID, bool bIsReloadable)
 
template<typename ResourceType >
ezResourceHandle< ResourceType > LoadResource (const char *szResourceID)
 
template<typename ResourceType >
ezResourceHandle< ResourceType > LoadResource (const char *szResourceID, ezResourcePriority Priority, ezResourceHandle< ResourceType > hFallbackResource)
 
template<typename ResourceType >
ezResourceHandle< ResourceType > GetExistingResource (const char *szResourceID)
 
template<typename ResourceType >
ezResourceHandle< ResourceType > CreateResource (const char *szResourceID, const typename ResourceType::DescriptorType &descriptor, const char *szResourceDescription)
 
template<typename ResourceType >
ResourceType * BeginAcquireResource (const ezResourceHandle< ResourceType > &hResource, ezResourceAcquireMode mode, const ezResourceHandle< ResourceType > &hFallbackResource, ezResourcePriority Priority)
 
template<typename ResourceType >
void EndAcquireResource (ResourceType *pResource)
 
template<typename ResourceType >
void PreloadResource (const ezResourceHandle< ResourceType > &hResource, ezTime tShouldBeAvailableIn)
 
template<typename ResourceType >
void ReloadResource (const ezResourceHandle< ResourceType > &hResource)
 
template<typename ResourceType >
void ReloadResourcesOfType ()
 
template<typename ResourceType >
void SetResourceTypeLoader (ezResourceTypeLoader *creator)
 

Static Public Member Functions

static void BroadcastResourceEvent (const ResourceEvent &e)
 
template<typename ResourceType >
static ezResourceHandle
< ResourceType > 
LoadResource (const char *szResourceID)
 
template<typename ResourceType >
static ezResourceHandle
< ResourceType > 
LoadResource (const char *szResourceID, ezResourcePriority Priority, ezResourceHandle< ResourceType > hFallbackResource)
 
template<typename ResourceType >
static ezResourceHandle
< ResourceType > 
CreateResource (const char *szResourceID, const typename ResourceType::DescriptorType &descriptor, const char *szResourceDescription=nullptr)
 
template<typename ResourceType >
static ezResourceHandle
< ResourceType > 
GetExistingResource (const char *szResourceID)
 
template<typename ResourceType >
static ResourceType * BeginAcquireResource (const ezResourceHandle< ResourceType > &hResource, ezResourceAcquireMode mode=ezResourceAcquireMode::AllowFallback, const ezResourceHandle< ResourceType > &hFallbackResource=ezResourceHandle< ResourceType >(), ezResourcePriority Priority=ezResourcePriority::Unchanged)
 
template<typename ResourceType >
static void EndAcquireResource (ResourceType *pResource)
 
template<typename ResourceType >
static void SetResourceTypeLoader (ezResourceTypeLoader *pCreator)
 
static void SetDefaultResourceLoader (ezResourceTypeLoader *pDefaultLoader)
 
static ezResourceTypeLoaderGetDefaultResourceLoader ()
 
static void OnEngineShutdown ()
 
static void OnCoreShutdown ()
 
static void OnCoreStartup ()
 
template<typename ResourceType >
static void PreloadResource (const ezResourceHandle< ResourceType > &hResource, ezTime tShouldBeAvailableIn)
 
static ezUInt32 FreeUnusedResources (bool bFreeAllUnused)
 
template<typename ResourceType >
static void ReloadResource (const ezResourceHandle< ResourceType > &hResource)
 
template<typename ResourceType >
static void ReloadResourcesOfType ()
 
static void ReloadResourcesOfType (const ezRTTI *pType)
 
static void ReloadAllResources ()
 
static void PerFrameUpdate ()
 
static void BroadcastExistsEvent ()
 Goes through all existing resources and broadcasts the 'Exists' event. Used to announce all currently existing resources to interested event listeners.
 
static void ConfigureResourceCategory (const char *szCategoryName, ezUInt64 uiMemoryLimitCPU, ezUInt64 uiMemoryLimitGPU)
 Sets up a new or existing category of resources. More...
 
static const ResourceCategoryGetResourceCategory (const char *szCategoryName)
 

Static Public Attributes

static ezEvent< const
ResourceEvent & > 
s_ResourceEvents
 
static ezEvent< const
ManagerEvent & > 
s_ManagerEvents
 

Static Private Member Functions

static void ReloadResource (ezResourceBase *pResource)
 
static void PreloadResource (ezResourceBase *pResource, ezTime tShouldBeAvailableIn)
 
template<typename ResourceType >
static ResourceType * GetResource (const char *szResourceID, bool bIsReloadable)
 
static void InternalPreloadResource (ezResourceBase *pResource, bool bHighestPriority)
 
static void RunWorkerTask ()
 
static void UpdateLoadingDeadlines ()
 
static ezResourceTypeLoaderGetResourceTypeLoader (const ezRTTI *pRTTI)
 

Static Private Attributes

static ezHashTable
< ezTempHashedString,
ezResourceBase * > 
m_LoadedResources
 
static ezMap< ezString,
ezResourceTypeLoader * > 
m_ResourceTypeLoader
 
static ezResourceLoaderFromFile m_FileResourceLoader
 
static ezResourceTypeLoaderm_pDefaultResourceLoader = &m_FileResourceLoader
 
static ezDeque< LoadingInfom_RequireLoading
 
static bool m_bTaskRunning = false
 
static bool m_bStop = false
 
static ezResourceManagerWorker m_WorkerTask [2]
 
static ezResourceManagerWorkerGPU m_WorkerGPU [16]
 
static ezUInt8 m_iCurrentWorkerGPU = 0
 
static ezUInt8 m_iCurrentWorker = 0
 
static ezTime m_LastDeadLineUpdate
 
static ezTime m_LastFrameUpdate
 
static bool m_bBroadcastExistsEvent = false
 
static ezHashTable< ezUInt32,
ResourceCategory
m_ResourceCategories
 
static ezMutex s_ResourceMutex
 

Friends

class ezResourceManagerWorker
 
class ezResourceManagerWorkerGPU
 

Class Documentation

struct ezResourceManager::ManagerEvent
Class Members
ManagerEventType m_EventType
const ResourceCategory * m_pCategory
struct ezResourceManager::ResourceCategory
Class Members
ezString m_sName
ezUInt64 m_uiMemoryLimitCPU
ezUInt64 m_uiMemoryLimitGPU
ezAtomicInteger64 m_uiMemoryUsageCPU
ezAtomicInteger64 m_uiMemoryUsageGPU
struct ezResourceManager::ResourceEvent
Class Members
ResourceEventType m_EventType
const ezResourceBase * m_pResource

Member Function Documentation

void ezResourceManager::ConfigureResourceCategory ( const char *  szCategoryName,
ezUInt64  uiMemoryLimitCPU,
ezUInt64  uiMemoryLimitGPU 
)
static

Sets up a new or existing category of resources.

Each resource can be assigned to one category. All resources with the same category share the same total memory limits.

void ezResourceManager::UpdateLoadingDeadlines ( )
staticprivate
Todo:
don't do this too often
Todo:
Allow to tweak kick out time
Todo:
Make sure resources that are queued here don't get deleted

Member Data Documentation

ezHashTable< ezTempHashedString, ezResourceBase * > ezResourceManager::m_LoadedResources
staticprivate
Todo:

Do not unload resources while they are acquired

Resource Type Memory Thresholds

Preload does not load all quality levels

Priority change on acquire not visible in inspector

Events: Resource being loaded (Task) -> loading time Infos to Display: Ref Count (max) Fallback: Type / Instance Loading Time Inspector -> Engine Resource to Preview


The documentation for this class was generated from the following files: