go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkOpenCLImage.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef __itkOpenCLImage_h
19#define __itkOpenCLImage_h
20
23#include "itkOpenCLEvent.h"
24#include "itkOpenCLSize.h"
25
26namespace itk
27{
35// Forward declaration
36class OpenCLBuffer;
37
39{
40public:
41
45
48
53 OpenCLImage( OpenCLContext * context, const cl_mem id ) :
54 OpenCLMemoryObject( context, id ) {}
55
57 OpenCLImage( const OpenCLImage & other );
58
60 OpenCLImage & operator=( const OpenCLImage & other );
61
64
68 std::size_t GetElementSizeInBytes() const;
69
71 std::size_t GetRowSizeInBytes() const;
72
76 std::size_t GetSliceSizeInBytes() const;
77
79 std::size_t GetDimension() const;
80
83 std::size_t GetWidth() const;
84
88 std::size_t GetHeight() const;
89
94 std::size_t GetDepth() const;
95
102 bool Read( void * data, const OpenCLSize & origin, const OpenCLSize & region,
103 const std::size_t rowPitch = 0, const std::size_t slicePitch = 0 );
104
111 OpenCLEvent ReadAsync( void * data,
112 const OpenCLSize & origin, const OpenCLSize & region,
113 const OpenCLEventList & event_list = OpenCLEventList(),
114 const std::size_t rowPitch = 0, const std::size_t slicePitch = 0 );
115
122 bool Write( const void * data,
123 const OpenCLSize & origin, const OpenCLSize & region,
124 const std::size_t rowPitch = 0, const std::size_t slicePitch = 0 );
125
132 OpenCLEvent WriteAsync( const void * data,
133 const OpenCLSize & origin, const OpenCLSize & region,
134 const OpenCLEventList & event_list = OpenCLEventList(),
135 const std::size_t rowPitch = 0, const std::size_t slicePitch = 0 );
136
144 void * Map( const OpenCLMemoryObject::Access access,
145 const OpenCLSize & origin, const OpenCLSize & region,
146 std::size_t * rowPitch = 0, std::size_t * slicePitch = 0 );
147
154 OpenCLEvent MapAsync( void ** data,
155 const OpenCLMemoryObject::Access access,
156 const OpenCLSize & origin, const OpenCLSize & region,
157 const OpenCLEventList & event_list = OpenCLEventList(),
158 std::size_t * rowPitch = 0, std::size_t * slicePitch = 0 );
159
165 bool Copy( const OpenCLImage & dest,
166 const OpenCLSize & origin, const OpenCLSize & region,
167 const OpenCLSize & destOrigin );
168
176 const OpenCLSize & origin, const OpenCLSize & region,
177 const OpenCLSize & destOrigin,
178 const OpenCLEventList & event_list = OpenCLEventList() );
179
185 bool Copy( const OpenCLBuffer & dest,
186 const OpenCLSize & origin, const OpenCLSize & region,
187 const std::size_t dst_offset = 0 );
188
196 const OpenCLSize & origin, const OpenCLSize & region,
197 const OpenCLEventList & event_list = OpenCLEventList(),
198 const std::size_t dst_offset = 0 );
199
200#ifdef CL_VERSION_1_2
202 static void SetImageDescription( cl_image_desc & imageDescription,
203 const OpenCLImageFormat & format,
204 const OpenCLSize & size );
205
206#endif
207
208protected:
209
211 std::size_t GetImageInfo( const cl_image_info name ) const;
212
214 void SetOrigin( std::size_t * origin_t, const OpenCLSize & origin ) const;
215
217 void SetRegion( std::size_t * region_t, const OpenCLSize & region ) const;
218
220 void SetSize( std::size_t * region_t, const OpenCLSize & region, const std::size_t value ) const;
221
223 friend class OpenCLBuffer;
224};
225
227template< typename charT, typename traits >
228inline
229std::basic_ostream< charT, traits > &
230operator<<( std::basic_ostream< charT, traits > & strm,
231 const OpenCLImage & image )
232{
233 if( image.IsNull() )
234 {
235 strm << "OpenCLImage(null)";
236 return strm;
237 }
238
239 const char indent = ' ';
240
241 strm << "OpenCLImage" << std::endl
242 << indent << "Element size(bytes): " << image.GetElementSizeInBytes() << std::endl
243 << indent << "Row size(bytes): " << image.GetRowSizeInBytes() << std::endl
244 << indent << "Slice size(bytes): " << image.GetSliceSizeInBytes() << std::endl
245 << indent << "Dimension: " << image.GetDimension() << std::endl
246 << indent << "Width: " << image.GetWidth() << std::endl
247 << indent << "Height: " << image.GetHeight() << std::endl
248 << indent << "Depth: " << image.GetDepth() << std::endl;
249
250 // Stream OpenCLMemoryObject
251 const OpenCLMemoryObject & memObj = image;
252 strm << memObj;
253
254 return strm;
255}
256
257
258} // end namespace itk
259
260#endif /* __itkOpenCLImage_h */
The OpenCLBuffer class represents an OpenCL buffer object.
The OpenCLContext class represents an OpenCL context.
OpenCLEventList class represents a list of OpenCLEvent objects.
OpenCLEvent class represents an OpenCL event object.
The OpenCLImageFormat class represents the format of a OpenCLImage.
The OpenCLImage class represents an image object is used to store a one, two or three dimensional tex...
OpenCLMemoryObject Superclass
std::vcl_size_t GetRowSizeInBytes() const
std::vcl_size_t GetElementSizeInBytes() const
OpenCLEvent ReadAsync(void *data, const OpenCLSize &origin, const OpenCLSize &region, const OpenCLEventList &event_list=OpenCLEventList(), const std::vcl_size_t rowPitch=0, const std::vcl_size_t slicePitch=0)
bool Copy(const OpenCLImage &dest, const OpenCLSize &origin, const OpenCLSize &region, const OpenCLSize &destOrigin)
std::vcl_size_t GetWidth() const
void SetOrigin(std::vcl_size_t *origin_t, const OpenCLSize &origin) const
OpenCLImage & operator=(const OpenCLImage &other)
bool Write(const void *data, const OpenCLSize &origin, const OpenCLSize &region, const std::vcl_size_t rowPitch=0, const std::vcl_size_t slicePitch=0)
std::vcl_size_t GetSliceSizeInBytes() const
OpenCLImage(const OpenCLImage &other)
std::vcl_size_t GetDimension() const
std::vcl_size_t GetDepth() const
bool Copy(const OpenCLBuffer &dest, const OpenCLSize &origin, const OpenCLSize &region, const std::vcl_size_t dst_offset=0)
OpenCLImage(OpenCLContext *context, const cl_mem id)
void * Map(const OpenCLMemoryObject::Access access, const OpenCLSize &origin, const OpenCLSize &region, std::vcl_size_t *rowPitch=0, std::vcl_size_t *slicePitch=0)
OpenCLEvent CopyAsync(const OpenCLImage &dest, const OpenCLSize &origin, const OpenCLSize &region, const OpenCLSize &destOrigin, const OpenCLEventList &event_list=OpenCLEventList())
void SetSize(std::vcl_size_t *region_t, const OpenCLSize &region, const std::vcl_size_t value) const
OpenCLImage Self
void SetRegion(std::vcl_size_t *region_t, const OpenCLSize &region) const
OpenCLEvent CopyAsync(const OpenCLBuffer &dest, const OpenCLSize &origin, const OpenCLSize &region, const OpenCLEventList &event_list=OpenCLEventList(), const std::vcl_size_t dst_offset=0)
OpenCLImageFormat GetFormat() const
std::vcl_size_t GetHeight() const
OpenCLEvent WriteAsync(const void *data, const OpenCLSize &origin, const OpenCLSize &region, const OpenCLEventList &event_list=OpenCLEventList(), const std::vcl_size_t rowPitch=0, const std::vcl_size_t slicePitch=0)
bool Read(void *data, const OpenCLSize &origin, const OpenCLSize &region, const std::vcl_size_t rowPitch=0, const std::vcl_size_t slicePitch=0)
OpenCLEvent MapAsync(void **data, const OpenCLMemoryObject::Access access, const OpenCLSize &origin, const OpenCLSize &region, const OpenCLEventList &event_list=OpenCLEventList(), std::vcl_size_t *rowPitch=0, std::vcl_size_t *slicePitch=0)
std::vcl_size_t GetImageInfo(const cl_image_info name) const
The OpenCLMemoryObject class represents all common memory objects such as buffers and image objects.
The OpenCLSize class defines the size of an item of work for an OpenCL kernel.
Definition: itkOpenCLSize.h:50
#define ITKOpenCL_EXPORT
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &strm, const OpenCLCommandQueue &queue)


Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo