go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
Public Types | Public Member Functions | Private Attributes
itk::OpenCLSampler Class Reference

#include <itkOpenCLSampler.h>

Detailed Description

The OpenCLSampler class represents an OpenCL sampler object.

A sampler object describes how to sample an image when the image is read in the kernel. The built-in functions to read from an image in a kernel take a sampler as an argument. The sampler arguments to the image read function can be sampler objects created using OpenCL functions and passed as argument values to the kernel or can be samplers declared inside a kernel. In this section we discuss how sampler objects are created using OpenCL functions.

The GetFilterMode() specifies the type of filter that must be applied when reading an image. This can be {CL_FILTER_NEAREST}, or {CL_FILTER_LINEAR}.

The GetAddressingMode() specifies how out-of-range image coordinates are handled when reading from an image. This can be set to {CL_ADDRESS_MIRRORED_REPEAT}, {CL_ADDRESS_REPEAT}, {CL_ADDRESS_CLAMP_TO_EDGE}, {CL_ADDRESS_CLAMP} and {CL_ADDRESS_NONE}.

Samplers are created using OpenCLContext::CreateSampler(), as follows:

OpenCLSampler sampler = context.CreateSampler

Samplers can also be defined as literals in the OpenCL kernel source code, which avoids the need to create an explicit OpenCLSampler value:

__constant sampler_t imageSampler =

The main advantage of OpenCLSampler over literal sampler values is that OpenCLSampler allows the pixel derivation strategy to be modified at runtime.

See also

Definition at line 71 of file itkOpenCLSampler.h.

Public Types

enum  AddressingMode {
  None = 0x1130, ClampToEdge = 0x1131, Clamp = 0x1132, Repeat = 0x1133,
  MirroredRepeat = 0x1134
enum  FilterMode { Nearest = 0x1140, Linear = 0x1141 }
typedef OpenCLSampler Self

Public Member Functions

OpenCLSampler::AddressingMode GetAddressingMode () const
OpenCLContextGetContext () const
OpenCLSampler::FilterMode GetFilterMode () const
bool GetNormalizedCoordinates () const
cl_sampler GetSamplerId () const
bool IsNull () const
 OpenCLSampler ()
 OpenCLSampler (OpenCLContext *context, cl_sampler id)
 OpenCLSampler (const OpenCLSampler &other)
OpenCLSampleroperator= (const OpenCLSampler &other)
 ~OpenCLSampler ()

Private Attributes

cl_sampler m_Id

Member Typedef Documentation

Standard class typedefs.

Definition at line 76 of file itkOpenCLSampler.h.

Member Enumeration Documentation


Definition at line 107 of file itkOpenCLSampler.h.


Definition at line 121 of file itkOpenCLSampler.h.

Constructor & Destructor Documentation

itk::OpenCLSampler::OpenCLSampler ( )

Constructs a null OpenCL sampler object.

Definition at line 79 of file itkOpenCLSampler.h.

itk::OpenCLSampler::OpenCLSampler ( OpenCLContext context,
cl_sampler  id 

Constructs an OpenCL sampler object from the native identifier id. This class takes over ownership of id and will release it in the destructor. The sampler id will be associated with context.

Definition at line 84 of file itkOpenCLSampler.h.

itk::OpenCLSampler::OpenCLSampler ( const OpenCLSampler other)

Constructs a copy of other. The {clRetainSampler()} function will be called to update the reference count on GetSamplerId().

itk::OpenCLSampler::~OpenCLSampler ( )

Releases this OpenCL sampler object by calling {clReleaseSampler()}.

Member Function Documentation

OpenCLSampler::AddressingMode itk::OpenCLSampler::GetAddressingMode ( ) const

Returns the addressing mode for out-of-range co-ordinates when reading from an image in OpenCL.

See also
GetNormalizedCoordinates(), GetFilterMode()
OpenCLContext* itk::OpenCLSampler::GetContext ( ) const

Returns the OpenCL context that this sampler was created for; null if not yet created within a context.

Definition at line 148 of file itkOpenCLSampler.h.

OpenCLSampler::FilterMode itk::OpenCLSampler::GetFilterMode ( ) const

Returns the type of filter to apply when reading from an image in OpenCL.

See also
GetNormalizedCoordinates(), GetAddressingMode()
bool itk::OpenCLSampler::GetNormalizedCoordinates ( ) const

Returns true if this sampler is using normalized co-ordinates, false otherwise.

See also
GetAddressingMode(), GetFilterMode()
cl_sampler itk::OpenCLSampler::GetSamplerId ( ) const

Returns the native OpenCL identifier for this sampler; or 0 if the sampler is null.

Definition at line 144 of file itkOpenCLSampler.h.

bool itk::OpenCLSampler::IsNull ( ) const

Returns true if this OpenCL sampler object is null, false otherwise.

Definition at line 127 of file itkOpenCLSampler.h.

OpenCLSampler& itk::OpenCLSampler::operator= ( const OpenCLSampler other)

Assigns other to this OpenCL sampler object. The current samplerId() will be released with {clReleaseSampler()}, and the new samplerId() will be retained with {clRetainSampler()}.

Field Documentation

OpenCLContext* itk::OpenCLSampler::m_Context

Definition at line 152 of file itkOpenCLSampler.h.

cl_sampler itk::OpenCLSampler::m_Id

Definition at line 153 of file itkOpenCLSampler.h.

Generated on 04-09-2015 for elastix by doxygen elastix logo