HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CE_HotSwapPoolEntry Class Referenceabstract

#include <CE_HotSwapPoolEntry.h>

+ Inheritance diagram for CE_HotSwapPoolEntry:

Public Types

enum  EntryType { EntryType::BUFFER = 0, EntryType::VDB, EntryType::ATTRIBUTE }
 To avoid the need for dynamic casts: More...
 

Public Member Functions

 CE_HotSwapPoolEntry ()
 Creates a new buffer. You must call setSize to make this buffer usable. More...
 
virtual ~CE_HotSwapPoolEntry ()
 
 CE_HotSwapPoolEntry (const CE_HotSwapPoolEntry &)=delete
 
CE_HotSwapPoolEntryoperator= (const CE_HotSwapPoolEntry &)=delete
 
virtual EntryType poolTypeID () const =0
 
bool isInUseGPU () const
 
void setInUseGPUFlag () const
 
void clearInUseGPUFlag () const
 

Protected Member Functions

virtual void unloadFromGPU ()=0
 
virtual void poolResetGPUBuffer ()=0
 Resets the GPU Buffer pointer. More...
 
virtual void poolSetOnGPU (bool ongpu)=0
 CHnages the OnGPU status. More...
 
virtual bool poolIsGPUBufferEmpty () const =0
 True if the gpu buffer is null. More...
 
virtual bool poolIsGPUBufferValid () const =0
 True if the gpu buffer is not null and valid. More...
 
virtual bool poolSwapGPUBuffer (CE_HotSwapPoolEntry *other)=0
 Swap two GPU buffers. Returns true if it did something. More...
 
virtual void poolShallowCopyGPUBuffer (const CE_HotSwapPoolEntry *src)=0
 Copies GPU buffer from source, shallow copy so it shares. More...
 

Friends

class CE_HotSwapPool
 

Detailed Description

Base class for objects that can be managed by the CE_HotSwapPool This handles the registration / unloading /etc of the GPU buffers.

Definition at line 20 of file CE_HotSwapPoolEntry.h.

Member Enumeration Documentation

To avoid the need for dynamic casts:

Enumerator
BUFFER 
VDB 
ATTRIBUTE 

Definition at line 24 of file CE_HotSwapPoolEntry.h.

Constructor & Destructor Documentation

CE_HotSwapPoolEntry::CE_HotSwapPoolEntry ( )
inline

Creates a new buffer. You must call setSize to make this buffer usable.

Definition at line 32 of file CE_HotSwapPoolEntry.h.

virtual CE_HotSwapPoolEntry::~CE_HotSwapPoolEntry ( )
inlinevirtual

Definition at line 33 of file CE_HotSwapPoolEntry.h.

CE_HotSwapPoolEntry::CE_HotSwapPoolEntry ( const CE_HotSwapPoolEntry )
delete

Member Function Documentation

void CE_HotSwapPoolEntry::clearInUseGPUFlag ( ) const

Decrements the user count of our GPU data. If there are no active users of the GPU data, the memory pool will be able to unload this buffer. See setInUseGPUFlag() documentation for how these methods must be used. This method also refreshes the buffer in the eyes of the memory pool, making it less likely to get evicted.

bool CE_HotSwapPoolEntry::isInUseGPU ( ) const
inline

Returns whether the GPU data for this image is currently being used by someone.

Definition at line 41 of file CE_HotSwapPoolEntry.h.

CE_HotSwapPoolEntry& CE_HotSwapPoolEntry::operator= ( const CE_HotSwapPoolEntry )
delete
virtual bool CE_HotSwapPoolEntry::poolIsGPUBufferEmpty ( ) const
protectedpure virtual

True if the gpu buffer is null.

Implemented in IMX_Buffer, IMX_VDB, and GA_CEAttribute.

virtual bool CE_HotSwapPoolEntry::poolIsGPUBufferValid ( ) const
protectedpure virtual

True if the gpu buffer is not null and valid.

Implemented in IMX_Buffer, IMX_VDB, and GA_CEAttribute.

virtual void CE_HotSwapPoolEntry::poolResetGPUBuffer ( )
protectedpure virtual

Resets the GPU Buffer pointer.

Implemented in IMX_Buffer, IMX_VDB, and GA_CEAttribute.

virtual void CE_HotSwapPoolEntry::poolSetOnGPU ( bool  ongpu)
protectedpure virtual

CHnages the OnGPU status.

Implemented in IMX_Buffer, IMX_VDB, and GA_CEAttribute.

virtual void CE_HotSwapPoolEntry::poolShallowCopyGPUBuffer ( const CE_HotSwapPoolEntry src)
protectedpure virtual

Copies GPU buffer from source, shallow copy so it shares.

Implemented in IMX_Buffer, IMX_VDB, and GA_CEAttribute.

virtual bool CE_HotSwapPoolEntry::poolSwapGPUBuffer ( CE_HotSwapPoolEntry other)
protectedpure virtual

Swap two GPU buffers. Returns true if it did something.

Implemented in IMX_Buffer, IMX_VDB, and GA_CEAttribute.

virtual EntryType CE_HotSwapPoolEntry::poolTypeID ( ) const
pure virtual

Implemented in IMX_Buffer, GA_CEAttribute, and IMX_VDB.

void CE_HotSwapPoolEntry::setInUseGPUFlag ( ) const

Increments the user count of our GPU data. If there are no active users of the GPU data, the memory pool will be able to unload the buffer. When using one of the getGPUBuffer() methods, the in-use GPU flag must be set to prevent the GPU data from getting unloaded: // Set the in-use flag before grabbing the GPU buffer. buffer.setInUseGPUFlag(); CE_Image& img = buffer.getGPUBufferW(); // Do stuff with the CE_Image (i.e. queue up an OpenCL command with // it, can be asynchronous). ... // Flip the flag that we set earlier. buffer.clearInUseGPUFlag(); Alternatively, you can use the RAII wrapper for this: { // Set the in-use flag before grabbing the GPU buffer. CE_ScopedBufferInUseGPU scoped_gpu_use(buffer); CE_Image& img = buffer.getGPUBufferW(); // Do stuff with the CE_Image (i.e. queue up an OpenCL command // with it, can be asynchronous). ... // Destructor automatically clears the flag that we set earlier. }

virtual void CE_HotSwapPoolEntry::unloadFromGPU ( )
protectedpure virtual

Queues up commands that transfer this buffer's GPU storage to main memory. TODO: this is non-blocking, make sure that's okay...

Implemented in IMX_VDB, and GA_CEAttribute.

Friends And Related Function Documentation

friend class CE_HotSwapPool
friend

Definition at line 98 of file CE_HotSwapPoolEntry.h.


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