The DefaultRendererResourceCache provides a simple example on how the IRendererResourceCache interface can be implemented. It is only intended as an example, as the optimal implementation would be very specific to how RAMSES is being utilized.
More...
#include <DefaultRendererResourceCache.h>
|
| DefaultRendererResourceCache (uint32_t maxCacheSizeInBytes) |
| Construct a DefaultRendererResourceCache with a given maximum size. Whenever the size limit is exceeded, items will automatically be unloaded in a FIFO-manner. More...
|
|
virtual | ~DefaultRendererResourceCache () override |
| Destructor of DefaultRendererResourceCache. More...
|
|
bool | hasResource (rendererResourceId_t resourceId, uint32_t &size) const override |
| Called by RamsesRenderer to ask for a resource with the given id. More...
|
|
bool | getResourceData (rendererResourceId_t resourceId, uint8_t *buffer, uint32_t bufferSize) const override |
| Called by RamsesRenderer to get the resource data associated with a given resource id. This method will be called immediately after hasResource(...), if the resource exists in the cache. More...
|
|
bool | shouldResourceBeCached (rendererResourceId_t resourceId, uint32_t resourceDataSize, resourceCacheFlag_t cacheFlag, sceneId_t sceneId) const override |
| Called by RamsesRenderer when a resource was not in the cache and is now available from other source. The cache is asked if it wants to store a given resource or not. This avoids the overhead of preparing the resource data in case it is not to be cached. More...
|
|
void | storeResource (rendererResourceId_t resourceId, const uint8_t *resourceData, uint32_t resourceDataSize, resourceCacheFlag_t cacheFlag, sceneId_t sceneId) override |
| Called by RamsesRenderer with the final resource for storing. This is called immediately after shouldResourceBeCached(...), if it was requested to be cached. More...
|
|
void | saveToFile (const char *filePath) const |
| Save current content of the cache to a file. More...
|
|
bool | loadFromFile (const char *filePath) |
| Load all content from a file. It is assumed that the file has been created using saveToFile(...). More...
|
|
| DefaultRendererResourceCache (const DefaultRendererResourceCache &other)=delete |
| Deleted copy constructor. More...
|
|
DefaultRendererResourceCache & | operator= (const DefaultRendererResourceCache &other)=delete |
| Deleted copy assignment. More...
|
|
virtual | ~IRendererResourceCache ()=default |
| Destructor of IRendererResourceCache. More...
|
|
|
class DefaultRendererResourceCacheImpl & | impl |
|
The DefaultRendererResourceCache provides a simple example on how the IRendererResourceCache interface can be implemented. It is only intended as an example, as the optimal implementation would be very specific to how RAMSES is being utilized.
◆ DefaultRendererResourceCache() [1/2]
ramses::DefaultRendererResourceCache::DefaultRendererResourceCache |
( |
uint32_t |
maxCacheSizeInBytes | ) |
|
|
explicit |
Construct a DefaultRendererResourceCache with a given maximum size. Whenever the size limit is exceeded, items will automatically be unloaded in a FIFO-manner.
- Parameters
-
maxCacheSizeInBytes | Maximum size of cache content in bytes |
◆ ~DefaultRendererResourceCache()
virtual ramses::DefaultRendererResourceCache::~DefaultRendererResourceCache |
( |
| ) |
|
|
overridevirtual |
◆ DefaultRendererResourceCache() [2/2]
Deleted copy constructor.
- Parameters
-
◆ getResourceData()
bool ramses::DefaultRendererResourceCache::getResourceData |
( |
rendererResourceId_t |
resourceId, |
|
|
uint8_t * |
buffer, |
|
|
uint32_t |
bufferSize |
|
) |
| const |
|
overridevirtual |
Called by RamsesRenderer to get the resource data associated with a given resource id. This method will be called immediately after hasResource(...), if the resource exists in the cache.
- Parameters
-
resourceId | Id for the resource. |
buffer | A pre-allocated buffer which the resource data will be copied into. |
bufferSize | The size of the pre-allocated buffer in bytes. It should be at least the size of the requested resource (returned by hasResource(...)). |
- Returns
- true if the resource was copied successfully into the buffer.
Implements ramses::IRendererResourceCache.
◆ hasResource()
bool ramses::DefaultRendererResourceCache::hasResource |
( |
rendererResourceId_t |
resourceId, |
|
|
uint32_t & |
size |
|
) |
| const |
|
overridevirtual |
Called by RamsesRenderer to ask for a resource with the given id.
- Parameters
-
| resourceId | Id for the resource. |
[out] | size | The size of the found resource in bytes. This value is only relevant if the resource exists in the cache. |
- Returns
- true if a resource with the given resource id exists in the cache.
Implements ramses::IRendererResourceCache.
◆ loadFromFile()
bool ramses::DefaultRendererResourceCache::loadFromFile |
( |
const char * |
filePath | ) |
|
Load all content from a file. It is assumed that the file has been created using saveToFile(...).
- Parameters
-
filePath | The file path to load from. |
- Returns
- true if the load was successful.
◆ operator=()
Deleted copy assignment.
- Parameters
-
- Returns
- unused
◆ saveToFile()
void ramses::DefaultRendererResourceCache::saveToFile |
( |
const char * |
filePath | ) |
const |
Save current content of the cache to a file.
- Parameters
-
filePath | The file path to save to. |
◆ shouldResourceBeCached()
Called by RamsesRenderer when a resource was not in the cache and is now available from other source. The cache is asked if it wants to store a given resource or not. This avoids the overhead of preparing the resource data in case it is not to be cached.
- Parameters
-
resourceId | Id for the resource. |
resourceDataSize | The size of the resource in bytes. |
cacheFlag | The cache flag associated with the resource (set on client side). |
sceneId | The id of the first scene which requested the resource. In case of multiple scenes using the same resource, only the first scene id is guaranteed to be reported. |
- Returns
- true if the cache wants to store the resource.
Implements ramses::IRendererResourceCache.
◆ storeResource()
Called by RamsesRenderer with the final resource for storing. This is called immediately after shouldResourceBeCached(...), if it was requested to be cached.
- Parameters
-
resourceId | Id for the resource. |
resourceData | The resource data which will be copied into the cache. |
resourceDataSize | The size of the resource in bytes. |
cacheFlag | The cache flag associated with the resource (set on client side). |
sceneId | The id of the first scene which requested the resource. In case of multiple scenes using the same resource, only the first scene id is guaranteed to be reported. |
Implements ramses::IRendererResourceCache.
◆ impl
class DefaultRendererResourceCacheImpl& ramses::DefaultRendererResourceCache::impl |
Stores internal data for implementation specifics of this class.
The documentation for this class was generated from the following file: