RAMSES Documentation  27.0.130
Information for RAMSES users and developers
Public Member Functions | Public Attributes | Friends | List of all members
ramses::ResourceDataPool Class Reference

The ResourceDataPool holds resource data which can be instantiated for a given scene. Resource data can either be added by calling the add functions or by attaching a resource data file to the pool. The same resource data can be instantiated by multiple scenes at the same time. More...

#include <ResourceDataPool.h>

Public Member Functions

resourceId_t addArrayResourceData (EDataType type, uint32_t numElements, const void *arrayData, resourceCacheFlag_t cacheFlag=ResourceCacheFlag_DoNotCache, const char *name=nullptr)
 Add ArrayResource data to the pool. The pool is taking ownership of the given range of data of a certain type and keeps it to instantiate resource from it later via createResourceForScene. See ramses::ArrayResource for more details. Readding the same resource data again will return the previous resource id, but not recreate the resource data. Readding a same resource requires removing it again with removeResourceData. More...
 
resourceId_t addTexture2DData (ETextureFormat format, uint32_t width, uint32_t height, uint32_t mipMapCount, const MipLevelData mipLevelData[], bool generateMipChain=false, const TextureSwizzle &swizzle={}, resourceCacheFlag_t cacheFlag=ResourceCacheFlag_DoNotCache, const char *name=nullptr)
 Add Texture2D data to the pool. It is taking ownership of the given range of texture data in the specified pixel format and keeps it to instantiate resource from it later via createResourceForScene. See ramses::Texture2D for more details. More...
 
resourceId_t addTexture3DData (ETextureFormat format, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipMapCount, const MipLevelData mipLevelData[], bool generateMipChain=false, resourceCacheFlag_t cacheFlag=ResourceCacheFlag_DoNotCache, const char *name=nullptr)
 Add Texture3D data to the pool. It is taking ownership of the given range of texture data in the specified pixel format and keeps it to instantiate resource from it later via createResourceForScene. See ramses::Texture3D for more details. Readding the same resource data again will return the previous resource id, but not recreate the resource data. Readding a same resource requires removing it again with removeResourceData. More...
 
resourceId_t addTextureCubeData (ETextureFormat format, uint32_t size, uint32_t mipMapCount, const CubeMipLevelData mipLevelData[], bool generateMipChain=false, const TextureSwizzle &swizzle={}, resourceCacheFlag_t cacheFlag=ResourceCacheFlag_DoNotCache, const char *name=nullptr)
 Add Cube Texture data to the pool. It is taking ownership of the given range of texture data in the specified pixel format and keeps it to instantiate resource from it later via createResourceForScene. All texel values are initially initialized to 0. See ramses::TextureCube for more details. Readding the same resource data again will return the previous resource id, but not recreate the resource data. Readding a same resource requires removing it again with removeResourceData. More...
 
resourceId_t addEffectData (const EffectDescription &effectDesc, resourceCacheFlag_t cacheFlag=ResourceCacheFlag_DoNotCache, const char *name=nullptr)
 Add Effect data to the pool by parsing a GLSL shader described by an EffectDescription instance. The data can be used to instantiate a resource via createResourceForScene. Refer to RamsesClient::getLastEffectErrorMessages in case of parsing error. See ramses::Effect for more details. Readding the same resource data again will return the previous resource id, but not recreate the resource data. Readding a same resource requires removing it again with removeResourceData. More...
 
std::string getLastEffectErrorMessages () const
 Get the GLSL error messages that were produced at the creation of the last Effect data. More...
 
bool removeResourceData (resourceId_t const &id)
 Removes data which was added to the pool. The provided resource id might not be used anymore to instantiate a resource via createResourceForScene, depending on how many times corresponding addResourceData was called before. Already instantiated resources will not be affected by removeResourceData. More...
 
bool addResourceDataFile (std::string const &filename)
 Adds a file to the resource data pool, so the contained data can be instantiated via createResourceForScene. More...
 
bool forceLoadResourcesFromResourceDataFile (std::string const &filename)
 Loads all resources in a file currently in use by any scene from that file to memory. More...
 
bool removeResourceDataFile (std::string const &filename)
 Removes a resource file from the pool. The contained data can then not be used anymore to instantiate a resource via createResourceForScene. More...
 
ResourcecreateResourceForScene (Scene &scene, resourceId_t const &id)
 Creates a resource for a scene out of pool data. The resource can then be used in scene as if created with the scenes create resource functions. More...
 

Public Attributes

ResourceDataPoolImpl & impl
 

Friends

class RamsesClientImpl
 RamsesClientImpl is the factory for creating the ResourceDataPool instance. More...
 

Detailed Description

The ResourceDataPool holds resource data which can be instantiated for a given scene. Resource data can either be added by calling the add functions or by attaching a resource data file to the pool. The same resource data can be instantiated by multiple scenes at the same time.

Deprecated:
This class was being introduced to cover legacy ramses use cases. Using this class is discouraged and it might be removed without warning in the future.

Member Function Documentation

◆ addArrayResourceData()

resourceId_t ramses::ResourceDataPool::addArrayResourceData ( EDataType  type,
uint32_t  numElements,
const void *  arrayData,
resourceCacheFlag_t  cacheFlag = ResourceCacheFlag_DoNotCache,
const char *  name = nullptr 
)

Add ArrayResource data to the pool. The pool is taking ownership of the given range of data of a certain type and keeps it to instantiate resource from it later via createResourceForScene. See ramses::ArrayResource for more details. Readding the same resource data again will return the previous resource id, but not recreate the resource data. Readding a same resource requires removing it again with removeResourceData.

Parameters
[in]typeThe data type of the array elements.
[in]numElementsThe number of elements of the given data type to use for the resource.
[in]arrayDataPointer to the data to be used to create the array from.
[in]cacheFlagThe optional flag sent to the renderer. The value describes how the cache implementation should handle the resource.
[in]nameThe optional name of the ArrayResource.
Returns
The resource id of the created pool ArrayResource

◆ addEffectData()

resourceId_t ramses::ResourceDataPool::addEffectData ( const EffectDescription effectDesc,
resourceCacheFlag_t  cacheFlag = ResourceCacheFlag_DoNotCache,
const char *  name = nullptr 
)

Add Effect data to the pool by parsing a GLSL shader described by an EffectDescription instance. The data can be used to instantiate a resource via createResourceForScene. Refer to RamsesClient::getLastEffectErrorMessages in case of parsing error. See ramses::Effect for more details. Readding the same resource data again will return the previous resource id, but not recreate the resource data. Readding a same resource requires removing it again with removeResourceData.

Parameters
[in]effectDescEffect description.
[in]cacheFlagThe optional flag sent to the renderer. The value describes how the cache implementation should handle the resource.
[in]nameThe name of the created Effect.
Returns
The resource id of the pool effect

◆ addResourceDataFile()

bool ramses::ResourceDataPool::addResourceDataFile ( std::string const &  filename)

Adds a file to the resource data pool, so the contained data can be instantiated via createResourceForScene.

Parameters
[in]filenameThe file name of the resource file to be added to pool.
Returns
true for success.

◆ addTexture2DData()

resourceId_t ramses::ResourceDataPool::addTexture2DData ( ETextureFormat  format,
uint32_t  width,
uint32_t  height,
uint32_t  mipMapCount,
const MipLevelData  mipLevelData[],
bool  generateMipChain = false,
const TextureSwizzle swizzle = {},
resourceCacheFlag_t  cacheFlag = ResourceCacheFlag_DoNotCache,
const char *  name = nullptr 
)

Add Texture2D data to the pool. It is taking ownership of the given range of texture data in the specified pixel format and keeps it to instantiate resource from it later via createResourceForScene. See ramses::Texture2D for more details.

Readding the same resource data again will return the previous resource id, but not recreate the resource data. Readding a same resource requires removing it again with removeResourceData.

Parameters
[in]formatPixel format of the Texture2D data.
[in]widthWidth of the texture (mipmap level 0).
[in]heightHeight of the texture (mipmap level 0).
[in]mipMapCountNumber of mipmap levels contained in mipLevelData array.
[in]mipLevelDataArray of MipLevelData structs defining mipmap levels to use. Amount and sizes of supplied mipmap levels have to conform to GL specification. Order is lowest level (biggest resolution) to highest level (smallest resolution).
[in]swizzleDescribes how RGBA channels of the texture are swizzled, where each member of the struct represents one destination channel that the source channel should get sampled from.
[in]generateMipChainAuto generate mipmap levels. Cannot be used if custom data for lower mipmap levels provided.
[in]cacheFlagThe optional flag sent to the renderer. The value describes how the cache implementation should handle the resource.
[in]nameThe name of the Texture2D.
Returns
The resource id of the pool Texture2D resource

◆ addTexture3DData()

resourceId_t ramses::ResourceDataPool::addTexture3DData ( ETextureFormat  format,
uint32_t  width,
uint32_t  height,
uint32_t  depth,
uint32_t  mipMapCount,
const MipLevelData  mipLevelData[],
bool  generateMipChain = false,
resourceCacheFlag_t  cacheFlag = ResourceCacheFlag_DoNotCache,
const char *  name = nullptr 
)

Add Texture3D data to the pool. It is taking ownership of the given range of texture data in the specified pixel format and keeps it to instantiate resource from it later via createResourceForScene. See ramses::Texture3D for more details. Readding the same resource data again will return the previous resource id, but not recreate the resource data. Readding a same resource requires removing it again with removeResourceData.

Parameters
[in]formatPixel format of the Texture3D data.
[in]widthWidth of the texture (mipmap level 0).
[in]heightHeight of the texture (mipmap level 0).
[in]depthDepth of the texture.
[in]mipMapCountNumber of mipmap levels contained in mipLevelData array.
[in]mipLevelDataArray of MipLevelData structs defining mipmap levels to use. Amount and sizes of supplied mipmap levels have to conform to GL specification. Order is lowest level (biggest resolution) to highest level (smallest resolution).
[in]generateMipChainAuto generate mipmap levels. Cannot be used if custom data for lower mipmap levels provided.
[in]cacheFlagThe optional flag sent to the renderer. The value describes how the cache implementation should handle the resource.
[in]nameThe name of the Texture3D.
Returns
The resource id of the pool Texture3D resource

◆ addTextureCubeData()

resourceId_t ramses::ResourceDataPool::addTextureCubeData ( ETextureFormat  format,
uint32_t  size,
uint32_t  mipMapCount,
const CubeMipLevelData  mipLevelData[],
bool  generateMipChain = false,
const TextureSwizzle swizzle = {},
resourceCacheFlag_t  cacheFlag = ResourceCacheFlag_DoNotCache,
const char *  name = nullptr 
)

Add Cube Texture data to the pool. It is taking ownership of the given range of texture data in the specified pixel format and keeps it to instantiate resource from it later via createResourceForScene. All texel values are initially initialized to 0. See ramses::TextureCube for more details. Readding the same resource data again will return the previous resource id, but not recreate the resource data. Readding a same resource requires removing it again with removeResourceData.

Parameters
[in]formatPixel format of the Cube Texture data.
[in]sizeedge length of one quadratic cube face, belonging to the texture.
[in]mipMapCountNumber of mipmaps contained in mipLevelData array.
[in]mipLevelDataArray of MipLevelData structs defining mipmap levels to use. Amount and sizes of supplied mipmap levels have to conform to GL specification. Order ist lowest level (biggest resolution) to highest level (smallest resolution).
[in]generateMipChainAuto generate mipmap levels. Cannot be used if custom data for lower mipmap levels provided.
[in]swizzleDescribes how RGBA channels of the texture are swizzled,
[in]cacheFlagThe optional flag sent to the renderer. The value describes how the cache implementation should handle the resource.
[in]nameThe name of the Cube Texture.
Returns
The resource id of the pool Cube Texture resource

◆ createResourceForScene()

Resource* ramses::ResourceDataPool::createResourceForScene ( Scene scene,
resourceId_t const &  id 
)

Creates a resource for a scene out of pool data. The resource can then be used in scene as if created with the scenes create resource functions.

Parameters
[in]sceneThe scene to instantiate the resource in.
[in]idThe resource id of the previously added resource.
Returns
Pointer to the created resource.

◆ forceLoadResourcesFromResourceDataFile()

bool ramses::ResourceDataPool::forceLoadResourcesFromResourceDataFile ( std::string const &  filename)

Loads all resources in a file currently in use by any scene from that file to memory.

When resources are created via createResourceForScene, not the full resource data is loaded immediately, but lazily at a later time when the data is actually needed. This function will fully load all resources which are currently instantiated in any scene and make sure resources are complete and independent of the resource file.

This operation can be used to trigger the potentially heavy resource loading at a user chosen, most convenient point in time to ensure fast resource handling once the resource is actually used for rendering.

This operation is recommended to be called before removeResourceDataFile to avoid removing a resource file whose resource data hasn't been fully loaded yet for all its resources in any scene.

Parameters
[in]filenameThe file name of the resource file resource are supposed to force loaded from.
Returns
true for success.

◆ getLastEffectErrorMessages()

std::string ramses::ResourceDataPool::getLastEffectErrorMessages ( ) const

Get the GLSL error messages that were produced at the creation of the last Effect data.

Returns
A string containing the GLSL error messages of the last effect

◆ removeResourceData()

bool ramses::ResourceDataPool::removeResourceData ( resourceId_t const &  id)

Removes data which was added to the pool. The provided resource id might not be used anymore to instantiate a resource via createResourceForScene, depending on how many times corresponding addResourceData was called before. Already instantiated resources will not be affected by removeResourceData.

Parameters
[in]idThe resource id of the previously added resource data.
Returns
true for success.

◆ removeResourceDataFile()

bool ramses::ResourceDataPool::removeResourceDataFile ( std::string const &  filename)

Removes a resource file from the pool. The contained data can then not be used anymore to instantiate a resource via createResourceForScene.

Calling this function might make resource data contained in the file unavailable for loading which leads to a scene not being rendered or rendered in a wrong way. It is recommended to call forceLoadResourcesFromResourceDataFile before to make sure all resource data is in memory and don't do any other resource operation before calling removeResourceDataFile.

Parameters
[in]filenameThe file name of the resource file to be removed from pool.
Returns
true for success.

Friends And Related Function Documentation

◆ RamsesClientImpl

friend class RamsesClientImpl
friend

RamsesClientImpl is the factory for creating the ResourceDataPool instance.

Member Data Documentation

◆ impl

ResourceDataPoolImpl& ramses::ResourceDataPool::impl

Stores internal data for implementation specifics of ResourceDataPool.


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