Dali 3D User Interface Engine
List of all members | Public Member Functions | Private Member Functions | Private Attributes
Dali::Internal::ShaderFactory Class Reference

ShaderFactory is an object which manages shader binary resource load requests, It triggers the load requests during core initialization and sends a message to the render manager with information about all the requested shader binaries. More...

#include <shader-factory.h>

Inheritance diagram for Dali::Internal::ShaderFactory:
Inheritance graph
[legend]
Collaboration diagram for Dali::Internal::ShaderFactory:
Collaboration graph
[legend]

Public Member Functions

 ShaderFactory ()
 Default constructor. More...
 
virtual ~ShaderFactory ()
 Destructor. More...
 
Internal::ShaderDataPtr Load (const std::string &vertexSource, const std::string &fragmentSource, const Dali::Shader::ShaderHints hints, size_t &shaderHash)
 Looks for precompiled binary version of shader program in memory and file caches. More...
 
virtual void SaveBinary (Internal::ShaderDataPtr shader)
 Saves shader to memory cache and filesystem. More...
 
void LoadDefaultShaders ()
 Called during Core initialization to load the default shader. More...
 

Private Member Functions

void MemoryCacheInsert (Internal::ShaderData &shaderData)
 
 ShaderFactory (const ShaderFactory &)
 
ShaderFactoryoperator= (const ShaderFactory &rhs)
 

Private Attributes

ShaderEffectPtr mDefaultShader
 
Dali::Vector
< Internal::ShaderData * > 
mShaderBinaryCache
 Cache of pre-compiled shaders. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Dali::Internal::ShaderSaver
virtual ~ShaderSaver ()
 Destructor. More...
 

Detailed Description

ShaderFactory is an object which manages shader binary resource load requests, It triggers the load requests during core initialization and sends a message to the render manager with information about all the requested shader binaries.

Definition at line 42 of file shader-factory.h.

Constructor & Destructor Documentation

Dali::Internal::ShaderFactory::ShaderFactory ( )

Default constructor.

Definition at line 68 of file shader-factory.cpp.

Dali::Internal::ShaderFactory::~ShaderFactory ( )
virtual

Destructor.

Definition at line 72 of file shader-factory.cpp.

References mShaderBinaryCache.

Dali::Internal::ShaderFactory::ShaderFactory ( const ShaderFactory )
private

Member Function Documentation

ShaderDataPtr Dali::Internal::ShaderFactory::Load ( const std::string &  vertexSource,
const std::string &  fragmentSource,
const Dali::Shader::ShaderHints  hints,
size_t &  shaderHash 
)

Looks for precompiled binary version of shader program in memory and file caches.

Tries to load a binary version of a shader program identified by a hash over the two source files, checking an in-memory cache first. If the cache hits or the load succeeds, the buffer member of the returned ShaderData will contain a precompiled shader binary program which can be uploaded directly to GLES.

Parameters
[in]vertexSourceThe vertex shader source code
[in]fragmentSourceThe fragment shader source code
[out]shaderHashHash key created from vertex and fragment shader code
Returns
ShaderData containing the source and hash value, and additionally, a compiled shader program binary if one could be found, else an empty binary buffer cleared to size zero.

Check a cache of previously loaded shaders:

Definition at line 84 of file shader-factory.cpp.

References Dali::CalculateHash(), DALI_LOG_INFO, Dali::Internal::ThreadLocalStorage::Get(), Dali::IntrusivePtr< T >::Get(), Dali::Internal::ThreadLocalStorage::GetPlatformAbstraction(), Dali::Integration::PlatformAbstraction::LoadShaderBinaryFile(), MemoryCacheInsert(), mShaderBinaryCache, and Dali::Internal::anonymous_namespace{shader-factory.cpp}::shaderBinaryFilename().

Referenced by Dali::Internal::Shader::Initialize().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::ShaderFactory::LoadDefaultShaders ( )

Called during Core initialization to load the default shader.

Definition at line 149 of file shader-factory.cpp.

References mDefaultShader, and Dali::Internal::ShaderEffect::New().

Here is the call graph for this function:

void Dali::Internal::ShaderFactory::MemoryCacheInsert ( Internal::ShaderData shaderData)
private

Definition at line 154 of file shader-factory.cpp.

References DALI_ASSERT_DEBUG, DALI_LOG_INFO, Dali::Internal::ShaderData::GetBufferSize(), Dali::Internal::ShaderData::GetHashValue(), mShaderBinaryCache, and Dali::RefObject::Reference().

Referenced by Load(), and SaveBinary().

Here is the call graph for this function:

Here is the caller graph for this function:

ShaderFactory& Dali::Internal::ShaderFactory::operator= ( const ShaderFactory rhs)
private
void Dali::Internal::ShaderFactory::SaveBinary ( Internal::ShaderDataPtr  shader)
virtual

Saves shader to memory cache and filesystem.

This is called when a shader binary is ready to be saved to the memory cache file system. Shaders that pass through here become available to subsequent invocations of Load.

Parameters
[in]shaderThe data to be saved.
See Also
Load

Implements Dali::Internal::ShaderSaver.

Definition at line 132 of file shader-factory.cpp.

References DALI_LOG_INFO, Dali::Internal::ThreadLocalStorage::Get(), MemoryCacheInsert(), Dali::Integration::PlatformAbstraction::SaveShaderBinaryFile(), and Dali::Internal::anonymous_namespace{shader-factory.cpp}::shaderBinaryFilename().

Here is the call graph for this function:

Member Data Documentation

ShaderEffectPtr Dali::Internal::ShaderFactory::mDefaultShader
private

Definition at line 98 of file shader-factory.h.

Referenced by LoadDefaultShaders().

Dali::Vector< Internal::ShaderData* > Dali::Internal::ShaderFactory::mShaderBinaryCache
private

Cache of pre-compiled shaders.

Definition at line 99 of file shader-factory.h.

Referenced by Load(), MemoryCacheInsert(), and ~ShaderFactory().


The documentation for this class was generated from the following files:
Dali Docs Home
Read more about Dali