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
The OpenCLSampler class represents an OpenCL sampler object.

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 =
CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;

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

See also
OpenCLContext

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 (const OpenCLSampler &other)
 
 OpenCLSampler (OpenCLContext *context, cl_sampler id)
 
OpenCLSampleroperator= (const OpenCLSampler &other)
 
 ~OpenCLSampler ()
 

Private Attributes

OpenCLContextm_Context
 
cl_sampler m_Id
 

Member Typedef Documentation

◆ Self

Standard class typedefs.

Definition at line 76 of file itkOpenCLSampler.h.

Member Enumeration Documentation

◆ AddressingMode

Enumerator
None 
ClampToEdge 
Clamp 
Repeat 
MirroredRepeat 

Definition at line 107 of file itkOpenCLSampler.h.

◆ FilterMode

Enumerator
Nearest 
Linear 

Definition at line 121 of file itkOpenCLSampler.h.

Constructor & Destructor Documentation

◆ OpenCLSampler() [1/3]

itk::OpenCLSampler::OpenCLSampler ( )
inline

Constructs a null OpenCL sampler object.

Definition at line 79 of file itkOpenCLSampler.h.

◆ OpenCLSampler() [2/3]

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

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.

◆ OpenCLSampler() [3/3]

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

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

◆ ~OpenCLSampler()

itk::OpenCLSampler::~OpenCLSampler ( )

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

Member Function Documentation

◆ GetAddressingMode()

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()

◆ GetContext()

OpenCLContext * itk::OpenCLSampler::GetContext ( ) const
inline

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.

◆ GetFilterMode()

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

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

See also
GetNormalizedCoordinates(), GetAddressingMode()

◆ GetNormalizedCoordinates()

bool itk::OpenCLSampler::GetNormalizedCoordinates ( ) const

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

See also
GetAddressingMode(), GetFilterMode()

◆ GetSamplerId()

cl_sampler itk::OpenCLSampler::GetSamplerId ( ) const
inline

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

Definition at line 144 of file itkOpenCLSampler.h.

◆ IsNull()

bool itk::OpenCLSampler::IsNull ( ) const
inline

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

Definition at line 127 of file itkOpenCLSampler.h.

◆ operator=()

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

◆ m_Context

OpenCLContext* itk::OpenCLSampler::m_Context
private

Definition at line 152 of file itkOpenCLSampler.h.

◆ m_Id

cl_sampler itk::OpenCLSampler::m_Id
private

Definition at line 153 of file itkOpenCLSampler.h.



Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo