#include <itkOpenCLSampler.h>
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:
Samplers can also be defined as literals in the OpenCL kernel source code, which avoids the need to create an explicit OpenCLSampler value:
The main advantage of OpenCLSampler over literal sampler values is that OpenCLSampler allows the pixel derivation strategy to be modified at runtime.
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 } |
using | Self = OpenCLSampler |
Public Member Functions | |
OpenCLSampler::AddressingMode | GetAddressingMode () const |
OpenCLContext * | GetContext () 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) | |
OpenCLSampler & | operator= (const OpenCLSampler &other) |
~OpenCLSampler () | |
Private Attributes | |
OpenCLContext * | m_Context |
cl_sampler | m_Id |
Standard class typedefs.
Definition at line 75 of file itkOpenCLSampler.h.
Enumerator | |
---|---|
None | |
ClampToEdge | |
Clamp | |
Repeat | |
MirroredRepeat |
Definition at line 112 of file itkOpenCLSampler.h.
Enumerator | |
---|---|
Nearest | |
Linear |
Definition at line 127 of file itkOpenCLSampler.h.
|
inline |
Constructs a null OpenCL sampler object.
Definition at line 78 of file itkOpenCLSampler.h.
|
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 86 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()}.
OpenCLSampler::AddressingMode itk::OpenCLSampler::GetAddressingMode | ( | ) | const |
Returns the addressing mode for out-of-range co-ordinates when reading from an image in OpenCL.
|
inline |
Returns the OpenCL context that this sampler was created for; null if not yet created within a context.
Definition at line 167 of file itkOpenCLSampler.h.
OpenCLSampler::FilterMode itk::OpenCLSampler::GetFilterMode | ( | ) | const |
Returns the type of filter to apply when reading from an image in OpenCL.
bool itk::OpenCLSampler::GetNormalizedCoordinates | ( | ) | const |
Returns true if this sampler is using normalized co-ordinates, false otherwise.
|
inline |
Returns the native OpenCL identifier for this sampler; or 0 if the sampler is null.
Definition at line 159 of file itkOpenCLSampler.h.
|
inline |
Returns true if this OpenCL sampler object is null, false otherwise.
Definition at line 135 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()}.
|
private |
Definition at line 173 of file itkOpenCLSampler.h.
|
private |
Definition at line 174 of file itkOpenCLSampler.h.
Generated on 2024-07-17 for elastix by 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) |