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

#include <IMX_PoolEntry.h>

+ Inheritance diagram for IMX_PoolEntry:

Public Types

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

Public Member Functions

 IMX_PoolEntry ()
 Creates a new buffer. You must call setSize to make this buffer usable. More...
 
virtual ~IMX_PoolEntry ()
 
 IMX_PoolEntry (const IMX_PoolEntry &)=delete
 
IMX_PoolEntryoperator= (const IMX_PoolEntry &)=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 (IMX_PoolEntry *other)=0
 Swap two GPU buffers. Returns true if it did something. More...
 
virtual void poolShallowCopyGPUBuffer (const IMX_PoolEntry *src)=0
 Copies GPU buffer from source, shallow copy so it shares. More...
 

Protected Attributes

int myGPUInUseCount = 0
 

Friends

class IMX_CEMemoryPool
 

Detailed Description

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

Definition at line 23 of file IMX_PoolEntry.h.

Member Enumeration Documentation

To avoid the need for dynamic casts:

Enumerator
BUFFER 
VDB 

Definition at line 27 of file IMX_PoolEntry.h.

Constructor & Destructor Documentation

IMX_PoolEntry::IMX_PoolEntry ( )
inline

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

Definition at line 34 of file IMX_PoolEntry.h.

virtual IMX_PoolEntry::~IMX_PoolEntry ( )
inlinevirtual

Definition at line 35 of file IMX_PoolEntry.h.

IMX_PoolEntry::IMX_PoolEntry ( const IMX_PoolEntry )
delete

Member Function Documentation

void IMX_PoolEntry::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 IMX_PoolEntry::isInUseGPU ( ) const
inline

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

Definition at line 43 of file IMX_PoolEntry.h.

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

True if the gpu buffer is null.

Implemented in IMX_Buffer, and IMX_VDB.

virtual bool IMX_PoolEntry::poolIsGPUBufferValid ( ) const
protectedpure virtual

True if the gpu buffer is not null and valid.

Implemented in IMX_Buffer, and IMX_VDB.

virtual void IMX_PoolEntry::poolResetGPUBuffer ( )
protectedpure virtual

Resets the GPU Buffer pointer.

Implemented in IMX_Buffer, and IMX_VDB.

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

CHnages the OnGPU status.

Implemented in IMX_Buffer, and IMX_VDB.

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

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

Implemented in IMX_Buffer, and IMX_VDB.

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

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

Implemented in IMX_Buffer, and IMX_VDB.

virtual EntryType IMX_PoolEntry::poolTypeID ( ) const
pure virtual

Implemented in IMX_Buffer, and IMX_VDB.

void IMX_PoolEntry::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. IMX_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 IMX_PoolEntry::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.

Friends And Related Function Documentation

friend class IMX_CEMemoryPool
friend

Definition at line 100 of file IMX_PoolEntry.h.

Member Data Documentation

int IMX_PoolEntry::myGPUInUseCount = 0
mutableprotected

Number of current users of the GPU memory from this buffer. All changes to this member must be done by the memory pool!!!

Definition at line 98 of file IMX_PoolEntry.h.


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