CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::VKObjectCache< ObjectType, OwnerType, DescriptorType > Class Template Reference

A object that caches existing Vulkan objects. More...

#include <CeresEngine/RenderAPI/Vulkan/VKCommon.hpp>

Public Types

using Descriptor = DescriptorType
 The type of descriptor used to detect duplicates and create new objects.
 
using Object = ObjectType
 The type of object managed by the cache object.
 
using ObjectPtr = RC< Object >
 A pointer to the cached object.
 

Public Member Functions

 VKObjectCache (OwnerType &owner)
 Creates a new Vulkan device object cache for the given device.
 
 ~VKObjectCache ()
 Destroys the Vulkan device object cache.
 
ObjectPtr get (const Descriptor &descriptor)
 Searches for an existing object that is compatible with the given descriptor.
 
ObjectPtr operator[] (const Descriptor &descriptor)
 Searches for an existing object that is compatible with the given descriptor.
 
void release (Object *object)
 Releases a previously cached object.
 

Private Attributes

OwnerTypemOwner
 The object owning the cached objects.
 
HashMap< UInt64, Object * > mCache
 A map that contains all cached objects.
 

Detailed Description

template<typename ObjectType, typename OwnerType = VKDevice, typename DescriptorType = typename ObjectType::Descriptor>
class CeresEngine::VKObjectCache< ObjectType, OwnerType, DescriptorType >

A object that caches existing Vulkan objects.

Stateless objects can be shared across the engine.

Template Parameters
ObjectTypeThe type of object managed by the cache object.
OwnerTypeThe type of the object owner.

Member Typedef Documentation

◆ Descriptor

template<typename ObjectType , typename OwnerType = VKDevice, typename DescriptorType = typename ObjectType::Descriptor>
using CeresEngine::VKObjectCache< ObjectType, OwnerType, DescriptorType >::Descriptor = DescriptorType

The type of descriptor used to detect duplicates and create new objects.

◆ Object

template<typename ObjectType , typename OwnerType = VKDevice, typename DescriptorType = typename ObjectType::Descriptor>
using CeresEngine::VKObjectCache< ObjectType, OwnerType, DescriptorType >::Object = ObjectType

The type of object managed by the cache object.

◆ ObjectPtr

template<typename ObjectType , typename OwnerType = VKDevice, typename DescriptorType = typename ObjectType::Descriptor>
using CeresEngine::VKObjectCache< ObjectType, OwnerType, DescriptorType >::ObjectPtr = RC<Object>

A pointer to the cached object.

Constructor & Destructor Documentation

◆ VKObjectCache()

template<typename ObjectType , typename OwnerType = VKDevice, typename DescriptorType = typename ObjectType::Descriptor>
CeresEngine::VKObjectCache< ObjectType, OwnerType, DescriptorType >::VKObjectCache ( OwnerType owner)
explicit

Creates a new Vulkan device object cache for the given device.

Parameters
ownerThe device to create new objects for.

◆ ~VKObjectCache()

template<typename ObjectType , typename OwnerType = VKDevice, typename DescriptorType = typename ObjectType::Descriptor>
CeresEngine::VKObjectCache< ObjectType, OwnerType, DescriptorType >::~VKObjectCache ( )

Destroys the Vulkan device object cache.

Member Function Documentation

◆ get()

template<typename ObjectType , typename OwnerType = VKDevice, typename DescriptorType = typename ObjectType::Descriptor>
ObjectPtr CeresEngine::VKObjectCache< ObjectType, OwnerType, DescriptorType >::get ( const Descriptor descriptor)

Searches for an existing object that is compatible with the given descriptor.

If none is found, a new one is created and returned.

Parameters
descriptorThe descriptor to lookup/create a new object from.
Returns
A reused object or a newly created one.

◆ operator[]()

template<typename ObjectType , typename OwnerType = VKDevice, typename DescriptorType = typename ObjectType::Descriptor>
ObjectPtr CeresEngine::VKObjectCache< ObjectType, OwnerType, DescriptorType >::operator[] ( const Descriptor descriptor)
inline

Searches for an existing object that is compatible with the given descriptor.

If none is found, a new one is created and returned.

Parameters
descriptorThe descriptor to lookup/create a new object from.
Returns
A reused object or a newly created one.

◆ release()

template<typename ObjectType , typename OwnerType = VKDevice, typename DescriptorType = typename ObjectType::Descriptor>
void CeresEngine::VKObjectCache< ObjectType, OwnerType, DescriptorType >::release ( Object object)

Releases a previously cached object.

Member Data Documentation

◆ mCache

template<typename ObjectType , typename OwnerType = VKDevice, typename DescriptorType = typename ObjectType::Descriptor>
HashMap<UInt64, Object*> CeresEngine::VKObjectCache< ObjectType, OwnerType, DescriptorType >::mCache
private

A map that contains all cached objects.

◆ mOwner

template<typename ObjectType , typename OwnerType = VKDevice, typename DescriptorType = typename ObjectType::Descriptor>
OwnerType& CeresEngine::VKObjectCache< ObjectType, OwnerType, DescriptorType >::mOwner
private

The object owning the cached objects.


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