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

Provide default implementation for IBinaryShaderCache interface, to be used in RamsesRenderer by setting in RendererConfig. Also provides functions to serialize binary shaders to file and deserialize binary shaders from file. More...

#include <BinaryShaderCache.h>

Inheritance diagram for ramses::BinaryShaderCache:
[legend]
Collaboration diagram for ramses::BinaryShaderCache:
[legend]

Public Member Functions

 BinaryShaderCache ()
 Default Constructor. More...
 
virtual ~BinaryShaderCache () override
 Destructor of IBinaryShaderCache. More...
 
virtual void deviceSupportsBinaryShaderFormats (const binaryShaderFormatId_t *supportedFormats, uint32_t numSupportedFormats) override
 Provides a list of binary shader formats supported by the device in use. The cache implementation should provide only shaders that were compiled and stored with using of those formats. The format ID is platform/driver specific, on OpenGL it is equivalent to those retrieved from GL_PROGRAM_BINARY_FORMATS parameter. This callback will be called only once, after at least one display is created and at latest before the first IBinaryShaderCache::hasBinaryShader query. More...
 
virtual bool hasBinaryShader (effectId_t effectId) const override
 Check if the cache contains the binary shader for the Effect with the given Effect Id. More...
 
virtual uint32_t getBinaryShaderSize (effectId_t effectId) const override
 Get the binary shader size in bytes for the Effect with the given Effect Id. More...
 
virtual binaryShaderFormatId_t getBinaryShaderFormat (effectId_t effectId) const override
 Get the binary shader format for the Effect with the given Effect Id. More...
 
virtual bool shouldBinaryShaderBeCached (effectId_t effectId, sceneId_t sceneId) const override
 Returns for a specific effect whether it should be cached. More...
 
virtual void getBinaryShaderData (effectId_t effectId, uint8_t *buffer, uint32_t bufferSize) const override
 Get the binary shader data for the Effect with the given Effect Id. More...
 
virtual void storeBinaryShader (effectId_t effectId, sceneId_t sceneId, const uint8_t *binaryShaderData, uint32_t binaryShaderDataSize, binaryShaderFormatId_t binaryShaderFormat) override
 Store the binary shader into the cache. More...
 
void saveToFile (const char *filePath) const
 Save all binary shaders in the cache to the file with the given path. More...
 
bool loadFromFile (const char *filePath)
 Load all binary shaders from the file with the given path. More...
 
virtual void binaryShaderUploaded (effectId_t effectId, bool success) const override
 Used by RamsesRenderer to provide a callback with information on the result of a binary shader upload operation. More...
 
 BinaryShaderCache (const BinaryShaderCache &other)=delete
 Deleted copy constructor. More...
 
BinaryShaderCacheoperator= (const BinaryShaderCache &other)=delete
 Deleted copy assignment. More...
 
- Public Member Functions inherited from ramses::IBinaryShaderCache
virtual ~IBinaryShaderCache ()=default
 Destructor of IBinaryShaderCache. More...
 

Public Attributes

class BinaryShaderCacheImpl & impl
 

Detailed Description

Provide default implementation for IBinaryShaderCache interface, to be used in RamsesRenderer by setting in RendererConfig. Also provides functions to serialize binary shaders to file and deserialize binary shaders from file.

Constructor & Destructor Documentation

◆ BinaryShaderCache() [1/2]

ramses::BinaryShaderCache::BinaryShaderCache ( )

Default Constructor.

◆ ~BinaryShaderCache()

virtual ramses::BinaryShaderCache::~BinaryShaderCache ( )
overridevirtual

Destructor of IBinaryShaderCache.

◆ BinaryShaderCache() [2/2]

ramses::BinaryShaderCache::BinaryShaderCache ( const BinaryShaderCache other)
delete

Deleted copy constructor.

Parameters
otherunused

Member Function Documentation

◆ binaryShaderUploaded()

virtual void ramses::BinaryShaderCache::binaryShaderUploaded ( effectId_t  effectId,
bool  success 
) const
overridevirtual

Used by RamsesRenderer to provide a callback with information on the result of a binary shader upload operation.

This method is called by the renderer after each attempted upload operation from a binary shader cache. It is intended for informational/debugging purposes in detecting an invalid binary shader cache.

Parameters
effectIdEffect Id of the Effect
successThe result

Implements ramses::IBinaryShaderCache.

◆ deviceSupportsBinaryShaderFormats()

virtual void ramses::BinaryShaderCache::deviceSupportsBinaryShaderFormats ( const binaryShaderFormatId_t supportedFormats,
uint32_t  numSupportedFormats 
)
overridevirtual

Provides a list of binary shader formats supported by the device in use. The cache implementation should provide only shaders that were compiled and stored with using of those formats. The format ID is platform/driver specific, on OpenGL it is equivalent to those retrieved from GL_PROGRAM_BINARY_FORMATS parameter. This callback will be called only once, after at least one display is created and at latest before the first IBinaryShaderCache::hasBinaryShader query.

Parameters
[in]supportedFormatsPointer to first element of a list of supported formats, this array is valid only for in the scope of this callback
[in]numSupportedFormatsNumber of elements in supportedFormats array, if zero there is no support for uploading binary shaders

Implements ramses::IBinaryShaderCache.

◆ getBinaryShaderData()

virtual void ramses::BinaryShaderCache::getBinaryShaderData ( effectId_t  effectId,
uint8_t *  buffer,
uint32_t  bufferSize 
) const
overridevirtual

Get the binary shader data for the Effect with the given Effect Id.

Parameters
effectIdEffect Id of the Effect
bufferpointer to the buffer to get the binary shader data
bufferSizethe size of the buffer to get the binary shader data

Implements ramses::IBinaryShaderCache.

◆ getBinaryShaderFormat()

virtual binaryShaderFormatId_t ramses::BinaryShaderCache::getBinaryShaderFormat ( effectId_t  effectId) const
overridevirtual

Get the binary shader format for the Effect with the given Effect Id.

Parameters
effectIdEffect Id of the Effect
Returns
binary shader format for the Effect with the given Effect Id. 0 if there is no binary shader in the cache for the Effect with the Effect Id.

Implements ramses::IBinaryShaderCache.

◆ getBinaryShaderSize()

virtual uint32_t ramses::BinaryShaderCache::getBinaryShaderSize ( effectId_t  effectId) const
overridevirtual

Get the binary shader size in bytes for the Effect with the given Effect Id.

Parameters
effectIdEffect Id of the Effect
Returns
size in bytes for the Effect with the given Effect Id 0 if there is no binary shader in the cache for the Effect with the Effect Id.

Implements ramses::IBinaryShaderCache.

◆ hasBinaryShader()

virtual bool ramses::BinaryShaderCache::hasBinaryShader ( effectId_t  effectId) const
overridevirtual

Check if the cache contains the binary shader for the Effect with the given Effect Id.

Parameters
effectIdEffect Id of the Effect
Returns
true if there is binary shader for the Effect Id false otherwise

Implements ramses::IBinaryShaderCache.

◆ loadFromFile()

bool ramses::BinaryShaderCache::loadFromFile ( const char *  filePath)

Load all binary shaders from the file with the given path.

Parameters
filePaththe path of the file to load binary shaders
Returns
true when succeed in loading binary shaders from the file false when fail to load binary shaders from the file

◆ operator=()

BinaryShaderCache& ramses::BinaryShaderCache::operator= ( const BinaryShaderCache other)
delete

Deleted copy assignment.

Parameters
otherunused
Returns
unused

◆ saveToFile()

void ramses::BinaryShaderCache::saveToFile ( const char *  filePath) const

Save all binary shaders in the cache to the file with the given path.

Parameters
filePaththe path of the file to save binary shaders

◆ shouldBinaryShaderBeCached()

virtual bool ramses::BinaryShaderCache::shouldBinaryShaderBeCached ( effectId_t  effectId,
sceneId_t  sceneId 
) const
overridevirtual

Returns for a specific effect whether it should be cached.

        This method is called if the shader is not cached yet but could be provided by the renderer.
        The cache can decide whether it the shader should be cached.
Parameters
[in]effectIdEffect Id of the Effect
[in]sceneIdID of scene that uses the effect
Returns
true if the effect should be cached, false otherwise.

Implements ramses::IBinaryShaderCache.

◆ storeBinaryShader()

virtual void ramses::BinaryShaderCache::storeBinaryShader ( effectId_t  effectId,
sceneId_t  sceneId,
const uint8_t *  binaryShaderData,
uint32_t  binaryShaderDataSize,
binaryShaderFormatId_t  binaryShaderFormat 
)
overridevirtual

Store the binary shader into the cache.

Parameters
effectIdEffect Id of the Effect
sceneIdID of scene that uses the effect
binaryShaderDatapointer to the binary shader data
binaryShaderDataSizesize of the binary shader data
binaryShaderFormatformat of the binary shader

Implements ramses::IBinaryShaderCache.

Member Data Documentation

◆ impl

class BinaryShaderCacheImpl& ramses::BinaryShaderCache::impl

Stores internal data for implementation specifics of this class.


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