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:
44
46 OpenCLImage() = default;
47
52 OpenCLImage(OpenCLContext * context, const cl_mem id)
53 : OpenCLMemoryObject(context, id)
54 {}
55
57 OpenCLImage(const OpenCLImage & other);
58
61 operator=(const OpenCLImage & other);
62
65 GetFormat() const;
66
70 std::size_t
72
74 std::size_t
76
80 std::size_t
82
84 std::size_t
85 GetDimension() const;
86
89 std::size_t
90 GetWidth() const;
91
95 std::size_t
96 GetHeight() const;
97
102 std::size_t
103 GetDepth() const;
104
111 bool
112 Read(void * data,
113 const OpenCLSize & origin,
114 const OpenCLSize & region,
115 const std::size_t rowPitch = 0,
116 const std::size_t slicePitch = 0);
117
125 ReadAsync(void * data,
126 const OpenCLSize & origin,
127 const OpenCLSize & region,
128 const OpenCLEventList & event_list = OpenCLEventList(),
129 const std::size_t rowPitch = 0,
130 const std::size_t slicePitch = 0);
131
138 bool
139 Write(const void * data,
140 const OpenCLSize & origin,
141 const OpenCLSize & region,
142 const std::size_t rowPitch = 0,
143 const std::size_t slicePitch = 0);
144
152 WriteAsync(const void * data,
153 const OpenCLSize & origin,
154 const OpenCLSize & region,
155 const OpenCLEventList & event_list = OpenCLEventList(),
156 const std::size_t rowPitch = 0,
157 const std::size_t slicePitch = 0);
158
166 void *
168 const OpenCLSize & origin,
169 const OpenCLSize & region,
170 std::size_t * rowPitch = 0,
171 std::size_t * slicePitch = 0);
172
180 MapAsync(void ** data,
181 const OpenCLMemoryObject::Access access,
182 const OpenCLSize & origin,
183 const OpenCLSize & region,
184 const OpenCLEventList & event_list = OpenCLEventList(),
185 std::size_t * rowPitch = 0,
186 std::size_t * slicePitch = 0);
187
193 bool
194 Copy(const OpenCLImage & dest, const OpenCLSize & origin, const OpenCLSize & region, const OpenCLSize & destOrigin);
195
203 CopyAsync(const OpenCLImage & dest,
204 const OpenCLSize & origin,
205 const OpenCLSize & region,
206 const OpenCLSize & destOrigin,
207 const OpenCLEventList & event_list = OpenCLEventList());
208
214 bool
215 Copy(const OpenCLBuffer & dest,
216 const OpenCLSize & origin,
217 const OpenCLSize & region,
218 const std::size_t dst_offset = 0);
219
228 const OpenCLSize & origin,
229 const OpenCLSize & region,
230 const OpenCLEventList & event_list = OpenCLEventList(),
231 const std::size_t dst_offset = 0);
232
233#ifdef CL_VERSION_1_2
235 static void
236 SetImageDescription(cl_image_desc & imageDescription, const OpenCLImageFormat & format, const OpenCLSize & size);
237
238#endif
239
240protected:
242 std::size_t
243 GetImageInfo(const cl_image_info name) const;
244
246 void
247 SetOrigin(std::size_t * origin_t, const OpenCLSize & origin) const;
248
250 void
251 SetRegion(std::size_t * region_t, const OpenCLSize & region) const;
252
254 void
255 SetSize(std::size_t * region_t, const OpenCLSize & region, const std::size_t value) const;
256
258 friend class OpenCLBuffer;
259};
260
262template <typename charT, typename traits>
263inline std::basic_ostream<charT, traits> &
264operator<<(std::basic_ostream<charT, traits> & strm, const OpenCLImage & image)
265{
266 if (image.IsNull())
267 {
268 strm << "OpenCLImage(null)";
269 return strm;
270 }
271
272 const char indent = ' ';
273
274 strm << "OpenCLImage\n"
275 << indent << "Element size(bytes): " << image.GetElementSizeInBytes() << '\n'
276 << indent << "Row size(bytes): " << image.GetRowSizeInBytes() << '\n'
277 << indent << "Slice size(bytes): " << image.GetSliceSizeInBytes() << '\n'
278 << indent << "Dimension: " << image.GetDimension() << '\n'
279 << indent << "Width: " << image.GetWidth() << '\n'
280 << indent << "Height: " << image.GetHeight() << '\n'
281 << indent << "Depth: " << image.GetDepth() << std::endl;
282
283 // Stream OpenCLMemoryObject
284 const OpenCLMemoryObject & memObj = image;
285 strm << memObj;
286
287 return strm;
288}
289
290
291} // end namespace itk
292
293#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...
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()=default
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
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.
#define ITKOpenCL_EXPORT
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &strm, const OpenCLCommandQueue &queue)


Generated on 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo