HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CE_Image Class Reference

#include <CE_Image.h>

Public Types

enum  StorageType {
  INT8 = 0, INT16, INT32, FLOAT16,
  FLOAT32
}
 

Public Member Functions

 CE_Image ()
 Creates a new uninitialized object. Call setSize() to allocate memory. More...
 
 ~CE_Image ()
 
bool copy (const CE_Image &other, bool force=false)
 
void swap (CE_Image &other)
 Swaps the backing buffers between the two objects. More...
 
SYS_FORCE_INLINE bool isValid () const
 Returns true if this buffer is allocated and usable. More...
 
void setSize (int width, int height, int channels, StorageType storage)
 Resizes this buffer; allocated memory is uninitialized. More...
 
void match (const CE_Image &other)
 
template<typename T >
void initFromVoxels (const UT_VoxelArray< T > &src)
 
void destroy ()
 
void readIn (const void *src, bool blocking=true)
 
void writeOut (void *dst, bool blocking=true) const
 
template<typename T >
void matchAndCopyToVoxels (UT_VoxelArray< T > &dest) const
 
const cl::Bufferbuffer () const
 Returns this buffer descriptor. More...
 
int64 totalMemory () const
 Total memory in bytes needed to hold this image's data. More...
 
int getWidth () const
 Returns the image's width. More...
 
int getHeight () const
 Returns the image's height. More...
 
int getChannels () const
 Returns the number of channels per pixel. More...
 
StorageType getStorage () const
 Identifies the type of data stored for each channel of every pixel. More...
 
cl::KernelFunctor bind (cl::Kernel k) const
 Bind a 2D kernel with one work item per pixel. More...
 
void setValue (const UT_Vector4F &val)
 Sets this buffer to the given constant value. More...
 
void setValue (int val)
 
bool indexToPos (int x, int y, int z, UT_Vector3F &pos) const
 

Static Public Member Functions

static const char * getName (StorageType)
 
static const char * getStorageString (StorageType)
 String used in snippets to identify the storage type. More...
 
static bool storesIntegers (StorageType t)
 
static int getBytes (StorageType t)
 
static int64 totalMemory (exint width, exint height, exint channels, StorageType storage)
 Total memory in bytes needed to hold an image with the given properties. More...
 
static bool indexToPos (int x, int y, int z, UT_Vector3F &pos, int w, int h)
 

Protected Attributes

cl::Buffer myBuffer
 OpenCL descriptor for the actual GPU buffer. More...
 
int myWidth
 Sizes of the buffer. More...
 
int myHeight
 
int myChannels
 
StorageType myStorage
 

Detailed Description

This class represents OpenCL storage of an image (a 2-dimensional rectangular grid of pixels with 1-4 floating point channels).

Definition at line 22 of file CE_Image.h.

Member Enumeration Documentation

Type of data stored in this buffer. This enum must be in sync with storage types defined in the imx.h OpenCL header.

Enumerator
INT8 
INT16 
INT32 
FLOAT16 
FLOAT32 

Definition at line 27 of file CE_Image.h.

Constructor & Destructor Documentation

CE_Image::CE_Image ( )

Creates a new uninitialized object. Call setSize() to allocate memory.

CE_Image::~CE_Image ( )

Member Function Documentation

cl::KernelFunctor CE_Image::bind ( cl::Kernel  k) const

Bind a 2D kernel with one work item per pixel.

const cl::Buffer& CE_Image::buffer ( ) const
inline

Returns this buffer descriptor.

Definition at line 101 of file CE_Image.h.

bool CE_Image::copy ( const CE_Image other,
bool  force = false 
)

Copies data into this image from other. If sizes are different between the two,

  • nothing is done if force is false,
  • this buffer is resized, then the copy performed if force is true. Returns true if copying was done, false otherwise.
void CE_Image::destroy ( )

Releases memory held by this buffer. setSize() must be called to make this object usable again.

static int CE_Image::getBytes ( StorageType  t)
inlinestatic

Definition at line 39 of file CE_Image.h.

int CE_Image::getChannels ( ) const
inline

Returns the number of channels per pixel.

Definition at line 125 of file CE_Image.h.

int CE_Image::getHeight ( ) const
inline

Returns the image's height.

Definition at line 119 of file CE_Image.h.

static const char* CE_Image::getName ( StorageType  )
static
StorageType CE_Image::getStorage ( ) const
inline

Identifies the type of data stored for each channel of every pixel.

Definition at line 131 of file CE_Image.h.

static const char* CE_Image::getStorageString ( StorageType  )
static

String used in snippets to identify the storage type.

int CE_Image::getWidth ( ) const
inline

Returns the image's width.

Definition at line 113 of file CE_Image.h.

bool CE_Image::indexToPos ( int  x,
int  y,
int  z,
UT_Vector3F pos 
) const
inline

Converts the given voxel coordinates to the normalized [0..1]^3 space in the same way as done in UT_VoxelArray.

Definition at line 145 of file CE_Image.h.

static bool CE_Image::indexToPos ( int  x,
int  y,
int  z,
UT_Vector3F pos,
int  w,
int  h 
)
static

Converts the given voxel coordinates to the normalized [0..1]^3 space in the same way as done in UT_VoxelArray. This static version of the method must be provided with width and height.

template<typename T >
void CE_Image::initFromVoxels ( const UT_VoxelArray< T > &  src)

Resizes this buffer to match the voxel array and copies its data into the image. Z-resolution of src should be 1. Number of channels is set based on T (which can be float, UT_Vector2F, UT_Vector3F, UT_Vector4F, or int64).

SYS_FORCE_INLINE bool CE_Image::isValid ( ) const
inline

Returns true if this buffer is allocated and usable.

Definition at line 60 of file CE_Image.h.

void CE_Image::match ( const CE_Image other)

Resizes this buffer to match the other image. Allocated memory is not initialized.

template<typename T >
void CE_Image::matchAndCopyToVoxels ( UT_VoxelArray< T > &  dest) const

Resizes dest to match dimensions of this image (its Z-resolution is set to 1). Number of channels in this image should equal tuple size of T. This function also downloads the image's data into dest.

void CE_Image::readIn ( const void src,
bool  blocking = true 
)

Upload data into this image from src. If blocking is true, the copying will be complete by the time the function returns; otherwise, the operation is simply queued up.

void CE_Image::setSize ( int  width,
int  height,
int  channels,
StorageType  storage 
)

Resizes this buffer; allocated memory is uninitialized.

void CE_Image::setValue ( const UT_Vector4F val)

Sets this buffer to the given constant value.

void CE_Image::setValue ( int  val)
static bool CE_Image::storesIntegers ( StorageType  t)
inlinestatic

Definition at line 38 of file CE_Image.h.

void CE_Image::swap ( CE_Image other)

Swaps the backing buffers between the two objects.

int64 CE_Image::totalMemory ( ) const

Total memory in bytes needed to hold this image's data.

static int64 CE_Image::totalMemory ( exint  width,
exint  height,
exint  channels,
StorageType  storage 
)
static

Total memory in bytes needed to hold an image with the given properties.

void CE_Image::writeOut ( void dst,
bool  blocking = true 
) const

Download data from this image into dst. If blocking is true, the copying will be complete by the time the function returns; otherwise, the operation is only queued up.

Member Data Documentation

cl::Buffer CE_Image::myBuffer
protected

OpenCL descriptor for the actual GPU buffer.

Definition at line 156 of file CE_Image.h.

int CE_Image::myChannels
protected

Definition at line 160 of file CE_Image.h.

int CE_Image::myHeight
protected

Definition at line 159 of file CE_Image.h.

StorageType CE_Image::myStorage
protected

Definition at line 161 of file CE_Image.h.

int CE_Image::myWidth
protected

Sizes of the buffer.

Definition at line 158 of file CE_Image.h.


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