|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TPASSIVECACHEMANAGER_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define TPASSIVECACHEMANAGER_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxcachemanager.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Forward declarations
|
|
Toshihiro Shimizu |
890ddd |
class TXsheet;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Typedefs
|
|
Toshihiro Shimizu |
890ddd |
typedef void (*TreeDescriptor)(std::string &desc, const TFxP &root);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===================================
|
|
Toshihiro Shimizu |
890ddd |
// TPassiveCacheManager class
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Shinya Kitaoka |
120a6e |
The TPassiveCacheManager is the cache delegate manager that allows render
|
|
Shinya Kitaoka |
120a6e |
processes to cache
|
|
Toshihiro Shimizu |
890ddd |
fx results from externally specified schematic nodes for future reuse.
|
|
Shinya Kitaoka |
120a6e |
Observe that this manager takes no effort in verifying the usefulness of caching
|
|
Shinya Kitaoka |
120a6e |
an fx, as the
|
|
Shinya Kitaoka |
120a6e |
expected behaviour for such cached results is that of being recycled on future,
|
|
Shinya Kitaoka |
120a6e |
\a unpredictable render
|
|
Shinya Kitaoka |
120a6e |
instances under the same passive cache management. Active, predictive caching
|
|
Shinya Kitaoka |
120a6e |
takes place
|
|
Shinya Kitaoka |
120a6e |
under control of another manager class - namely, the TFxCacheManager - for
|
|
Shinya Kitaoka |
120a6e |
single render instances.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TPassiveCacheManager : public TFxCacheManagerDelegate {
|
|
Shinya Kitaoka |
120a6e |
T_RENDER_RESOURCE_MANAGER
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
struct FxData {
|
|
Shinya Kitaoka |
120a6e |
TFxP m_fx;
|
|
Shinya Kitaoka |
120a6e |
UCHAR m_storageFlag;
|
|
Shinya Kitaoka |
120a6e |
int m_passiveCacheId;
|
|
Shinya Kitaoka |
120a6e |
// std::set<tcacheresourcep> m_resources;</tcacheresourcep>
|
|
Shinya Kitaoka |
120a6e |
std::string m_treeDescription;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
FxData();
|
|
Shinya Kitaoka |
120a6e |
~FxData();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*void insert(const TCacheResourceP& resource);
|
|
Shinya Kitaoka |
120a6e |
std::set<tcacheresourcep>::iterator erase(const</tcacheresourcep>
|
|
Shinya Kitaoka |
120a6e |
std::set<tcacheresourcep>::iterator& it);</tcacheresourcep>
|
|
Shinya Kitaoka |
120a6e |
void clear();*/
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class ResourcesContainer;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
QMutex m_mutex;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::vector<fxdata> m_fxDataVector;</fxdata>
|
|
Shinya Kitaoka |
120a6e |
std::set<std::string> m_invalidatedLevels;</std::string>
|
|
Shinya Kitaoka |
120a6e |
ResourcesContainer *m_resources;
|
|
Shinya Kitaoka |
120a6e |
std::map<std::string, uchar=""> m_contextNames;</std::string,>
|
|
Shinya Kitaoka |
120a6e |
std::map<unsigned long,="" std::string=""> m_contextNamesByRenderId;</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool m_updatingPassiveCacheIds;
|
|
Shinya Kitaoka |
120a6e |
int m_currentPassiveCacheId;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool m_enabled;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TPassiveCacheManager();
|
|
Shinya Kitaoka |
120a6e |
~TPassiveCacheManager();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static TPassiveCacheManager *instance();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setContextName(unsigned long renderId, const std::string &name);
|
|
Shinya Kitaoka |
120a6e |
void releaseContextNamesWithPrefix(const std::string &prefix);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFx *getNotAllowingAncestor(TFx *fx);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setEnabled(bool enabled);
|
|
Shinya Kitaoka |
120a6e |
bool isEnabled() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void reset();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
enum StorageFlag { NONE = 0x0, IN_MEMORY = 0x1, ON_DISK = 0x2 };
|
|
Shinya Kitaoka |
120a6e |
void setStorageMode(StorageFlag mode);
|
|
Shinya Kitaoka |
120a6e |
StorageFlag getStorageMode() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int declareCached(TFx *fx, int passiveCacheId);
|
|
Shinya Kitaoka |
120a6e |
void onSceneLoaded();
|
|
Shinya Kitaoka |
120a6e |
int getPassiveCacheId(TFx *fx);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void enableCache(TFx *fx);
|
|
Shinya Kitaoka |
120a6e |
void disableCache(TFx *fx);
|
|
Shinya Kitaoka |
120a6e |
bool cacheEnabled(TFx *fx);
|
|
Shinya Kitaoka |
120a6e |
void toggleCache(TFx *fx);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
StorageFlag getStorageMode(TFx *fx);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void invalidateLevel(const std::string &levelName);
|
|
Shinya Kitaoka |
120a6e |
void forceInvalidate();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void getResource(TCacheResourceP &resource, const std::string &alias,
|
|
Shinya Kitaoka |
120a6e |
const TFxP &fx, double frame, const TRenderSettings &rs,
|
|
Shinya Kitaoka |
473e70 |
ResourceDeclaration *resData) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void onRenderInstanceStart(unsigned long renderId) override;
|
|
Shinya Kitaoka |
473e70 |
void onRenderInstanceEnd(unsigned long renderId) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void onRenderStatusEnd(int renderStatus) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
bool renderHasOwnership() override { return false; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
void setTreeDescriptor(TreeDescriptor callback);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void onFxChanged(const TFxP &fx);
|
|
Shinya Kitaoka |
120a6e |
void onXsheetChanged();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
TreeDescriptor m_descriptorCallback;
|
|
Shinya Kitaoka |
120a6e |
StorageFlag m_currStorageFlag;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
void touchFxData(int &idx);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int getNewPassiveCacheId();
|
|
Shinya Kitaoka |
120a6e |
int updatePassiveCacheId(int id);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::string getContextName();
|
|
Shinya Kitaoka |
120a6e |
void releaseOldResources();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // TPASSIVECACHEMANAGER_INCLUDED
|