ITK  5.4.0
Insight Toolkit
itkGPUImageDataManager.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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
19#ifndef itkGPUImageDataManager_h
20#define itkGPUImageDataManager_h
21
22#include "itkObject.h"
23#include "itkTimeStamp.h"
24#include "itkLightObject.h"
25#include "itkObjectFactory.h"
26#include "itkOpenCLUtil.h"
27#include "itkGPUDataManager.h"
29#include <mutex>
30
31namespace itk
32{
33template <typename TPixel, unsigned int VDimension>
34class GPUImage;
35
44template <typename ImageType>
45class ITK_TEMPLATE_EXPORT GPUImageDataManager : public GPUDataManager
46{
47 // allow GPUKernelManager to access GPU buffer pointer
48 friend class GPUKernelManager;
49 friend class GPUImage<typename ImageType::PixelType, ImageType::ImageDimension>;
50
51public:
52 ITK_DISALLOW_COPY_AND_MOVE(GPUImageDataManager);
53
56 using Pointer = SmartPointer<Self>;
57 using ConstPointer = SmartPointer<const Self>;
58
59 itkNewMacro(Self);
60 itkOverrideGetNameOfClassMacro(GPUImageDataManager);
61
62 static constexpr unsigned int ImageDimension = ImageType::ImageDimension;
63
64 itkGetModifiableObjectMacro(GPUBufferedRegionIndex, GPUDataManager);
65 itkGetModifiableObjectMacro(GPUBufferedRegionSize, GPUDataManager);
66
67 void
68 SetImagePointer(ImageType * img);
69
70 ImageType *
71 GetImagePointer()
72 {
73 return this->m_Image.GetPointer();
74 }
75
77 virtual void
79
81 virtual void
83
84protected:
86 ~GPUImageDataManager() override = default;
87
88private:
89 WeakPointer<ImageType> m_Image{}; // WeakPointer has to be used here
90 // to avoid SmartPointer loop
91 int m_BufferedRegionIndex[ImageType::ImageDimension]{};
92 int m_BufferedRegionSize[ImageType::ImageDimension]{};
93 typename GPUDataManager::Pointer m_GPUBufferedRegionIndex{};
94 typename GPUDataManager::Pointer m_GPUBufferedRegionSize{};
95};
96
97} // namespace itk
98
99#ifndef ITK_MANUAL_INSTANTIATION
100# include "itkGPUImageDataManager.hxx"
101#endif
102
103#endif
GPU memory manager implemented using OpenCL. Required by GPUImage class.
virtual void MakeCPUBufferUpToDate()
~GPUImageDataManager() override=default
virtual void MakeGPUBufferUpToDate()
Templated n-dimensional image class for the GPU.
Definition: itkGPUImage.h:41
GPU kernel manager implemented using OpenCL.
Light weight base class for most itk classes.
ObjectType * GetPointer() const noexcept
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....