Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
BIAS::clfBuffer Class Reference

OpenCL Buffer wrapper. More...

#include <OpenCLFramework/clfBuffer.hh>

+ Inheritance diagram for BIAS::clfBuffer:
+ Collaboration diagram for BIAS::clfBuffer:

Public Member Functions

void Allocate (unsigned int bufsize, bool readonly=false, bool writeonly=false, void *hostptr=NULL, bool copy=false)
 Allocation of a memory buffer A memory buffer can be created on device or host, it can be initialized from a host ptr. More...
 
void Allocate (unsigned int rows, unsigned int cols, unsigned int channels, unsigned int itemsize, bool readonly=false, bool writeonly=false, void *hostptr=NULL, bool copy=false)
 
void AllocateFromVertexBuffer (BIAS::glfVertexBuffer &vbo, bool readonly=false, bool writeonly=false)
 Allocation of a memory buffer from a GL vertexBuffer (works only on shared context!) More...
 
void CopyBuffer (clfBuffer &outputbuffer, unsigned int srcoffset=0, unsigned int dstoffset=0, unsigned int size=0)
 copy from one buffer to another More...
 
unsigned int GetChannels () const
 
unsigned int GetCols () const
 
unsigned int GetItemSize () const
 
unsigned int GetRows () const
 
unsigned int GetStride () const
 
unsigned int GLId ()
 
bool Initialized ()
 
bool IsReadOnly ()
 
bool IsSharedGL ()
 
bool IsWriteOnly ()
 
void * MapBuffer (bool write=false, unsigned int offset=0, unsigned int size=0)
 
void ReadFromBuffer (void *data, unsigned int offset=0, unsigned int size=0)
 read from buffer object to host memory More...
 
void SetCached (bool cache)
 
unsigned int Size ()
 
void UnMap (void *data)
 
void WriteToBuffer (const void *data, unsigned int offset=0, unsigned int size=0)
 write from host memory to buffer object More...
 
virtual ~clfBuffer ()
 

Protected Member Functions

cl::Buffer & buffer ()
 
 clfBuffer (cl::Context *context, cl::CommandQueue *queue_)
 
int DetermineMemFlags_ (bool readonly, bool writeonly, const void *hostptr=NULL, bool copy=false)
 
cl::Memory & memory ()
 

Protected Attributes

cl::Memory buffer_
 
cl::Context * context_
 
unsigned int glid_
 
bool initialized_
 
cl::CommandQueue * queue_
 
bool sharedGL_
 
unsigned int size_
 

Friends

class clfContext
 
class clfProgram
 

Detailed Description

OpenCL Buffer wrapper.

An clfBuffer is used for Buffers both host and GL objects. All buffers are created from a valid clfContext, hence the constructor is protected.

Author
fkellner 06/11

Definition at line 43 of file clfBuffer.hh.

Constructor & Destructor Documentation

clfBuffer::~clfBuffer ( )
virtual

Definition at line 41 of file clfBuffer.cpp.

clfBuffer::clfBuffer ( cl::Context *  context,
cl::CommandQueue *  queue_ 
)
protected

Definition at line 32 of file clfBuffer.cpp.

Member Function Documentation

void clfBuffer::Allocate ( unsigned int  bufsize,
bool  readonly = false,
bool  writeonly = false,
void *  hostptr = NULL,
bool  copy = false 
)

Allocation of a memory buffer A memory buffer can be created on device or host, it can be initialized from a host ptr.

if the buffer is not readonly and not writeonly it is declared read/write.

Parameters
bufsizesize of buffer in byte
readonlyif this buffer is read only
writeonlyif this buffer is write only
hostptrptr to host memory which is used for initialization (if NULL, do not initialize)
copycopy host ptr data to device or use host memory

Definition at line 45 of file clfBuffer.cpp.

References BIAS::clfMemory::buffer_, BIAS::clfMemory::context_, BIAS::clfMemory::DetermineMemFlags_(), BIAS::clfMemory::initialized_, BIAS::clfMemory::sharedGL_, and BIAS::clfMemory::size_.

Referenced by BIAS::clfRadixSort::clfRadixSort(), and BIAS::clfTrimmedICP::clfTrimmedICP().

void clfBuffer::Allocate ( unsigned int  rows,
unsigned int  cols,
unsigned int  channels,
unsigned int  itemsize,
bool  readonly = false,
bool  writeonly = false,
void *  hostptr = NULL,
bool  copy = false 
)
void clfBuffer::AllocateFromVertexBuffer ( BIAS::glfVertexBuffer vbo,
bool  readonly = false,
bool  writeonly = false 
)
cl::Buffer & clfBuffer::buffer ( )
protected
void clfBuffer::CopyBuffer ( clfBuffer outputbuffer,
unsigned int  srcoffset = 0,
unsigned int  dstoffset = 0,
unsigned int  size = 0 
)

copy from one buffer to another

Parameters
outputbufferbuffer object (to)
sizenumber of bytes to copy

Definition at line 139 of file clfBuffer.cpp.

References buffer(), BIAS::clfMemory::queue_, and BIAS::clfMemory::size_.

Referenced by BIAS::clfRadixSort::SetData().

int BIAS::clfMemory::DetermineMemFlags_ ( bool  readonly,
bool  writeonly,
const void *  hostptr = NULL,
bool  copy = false 
)
protectedinherited
unsigned int clfBuffer::GetChannels ( ) const

Definition at line 183 of file clfBuffer.cpp.

unsigned int clfBuffer::GetCols ( ) const

Definition at line 173 of file clfBuffer.cpp.

unsigned int clfBuffer::GetItemSize ( ) const

Definition at line 176 of file clfBuffer.cpp.

unsigned int clfBuffer::GetRows ( ) const

Definition at line 170 of file clfBuffer.cpp.

unsigned int clfBuffer::GetStride ( ) const

Definition at line 179 of file clfBuffer.cpp.

unsigned int BIAS::clfMemory::GLId ( )
inherited

Definition at line 47 of file clfMemory.cpp.

References BIAS::clfMemory::glid_, and BIAS::clfMemory::sharedGL_.

bool BIAS::clfMemory::Initialized ( )
inlineinherited

Definition at line 37 of file clfMemory.hh.

bool BIAS::clfMemory::IsReadOnly ( )
inherited
bool BIAS::clfMemory::IsSharedGL ( )
inlineinherited
bool BIAS::clfMemory::IsWriteOnly ( )
inherited

Definition at line 67 of file clfMemory.cpp.

References BIAS::clfMemory::buffer_.

void * clfBuffer::MapBuffer ( bool  write = false,
unsigned int  offset = 0,
unsigned int  size = 0 
)
cl::Memory & BIAS::clfMemory::memory ( )
protectedinherited
void clfBuffer::ReadFromBuffer ( void *  data,
unsigned int  offset = 0,
unsigned int  size = 0 
)

read from buffer object to host memory

Parameters
datahost memory pointer
offsetoffset in bytes
sizenumber of bytes to read

Definition at line 128 of file clfBuffer.cpp.

References buffer(), BIAS::clfMemory::queue_, and BIAS::clfMemory::size_.

Referenced by BIAS::clfRadixSort::GetPermutation(), and BIAS::clfRadixSort::RecupGPU().

void clfBuffer::SetCached ( bool  cache)

Definition at line 109 of file clfBuffer.cpp.

unsigned int BIAS::clfMemory::Size ( )
inlineinherited

Definition at line 40 of file clfMemory.hh.

void BIAS::clfMemory::UnMap ( void *  data)
inherited
void clfBuffer::WriteToBuffer ( const void *  data,
unsigned int  offset = 0,
unsigned int  size = 0 
)

write from host memory to buffer object

Parameters
datahost memory pointer
offsetoffset in bytes
sizenumber of bytes to write

Definition at line 117 of file clfBuffer.cpp.

References buffer(), BIAS::clfMemory::queue_, and BIAS::clfMemory::size_.

Referenced by BIAS::clfRadixSort::Host2GPU(), BIAS::clfRadixSort::Resize(), and BIAS::clfRadixSort::SetData().

Friends And Related Function Documentation

friend class clfContext
friend

Definition at line 102 of file clfBuffer.hh.

friend class clfProgram
friend

Definition at line 103 of file clfBuffer.hh.

Member Data Documentation

cl::Memory BIAS::clfMemory::buffer_
protectedinherited
cl::Context* BIAS::clfMemory::context_
protectedinherited
unsigned int BIAS::clfMemory::glid_
protectedinherited
bool BIAS::clfMemory::initialized_
protectedinherited
cl::CommandQueue* BIAS::clfMemory::queue_
protectedinherited
bool BIAS::clfMemory::sharedGL_
protectedinherited
unsigned int BIAS::clfMemory::size_
protectedinherited

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