16 #ifndef QGSOPENCLUTILS_H
17 #define QGSOPENCLUTILS_H
21 #define CL_HPP_ENABLE_EXCEPTIONS
25 #define CL_HPP_MINIMUM_OPENCL_VERSION 120
26 #define CL_HPP_TARGET_OPENCL_VERSION 120
27 #define CL_TARGET_OPENCL_VERSION 120
29 #define CL_USE_DEPRECATED_OPENCL_1_1_APIS
30 #define CL_HPP_TARGET_OPENCL_VERSION 200
31 #define CL_TARGET_OPENCL_VERSION 200
36 #include "qgis_core.h"
98 Q_ENUM( HardwareType )
107 Name = CL_DEVICE_NAME,
108 Vendor = CL_DEVICE_VENDOR,
109 Version = CL_DEVICE_VERSION,
110 Profile = CL_DEVICE_PROFILE,
111 ImageSupport = CL_DEVICE_IMAGE_SUPPORT,
112 Image2dMaxWidth = CL_DEVICE_IMAGE2D_MAX_WIDTH,
113 Image2dMaxHeight = CL_DEVICE_IMAGE2D_MAX_HEIGHT,
114 MaxMemAllocSize = CL_DEVICE_MAX_MEM_ALLOC_SIZE,
115 Type = CL_DEVICE_TYPE
127 static bool available();
130 static bool enabled();
133 static const std::vector<cl::Device> devices();
142 static cl::Device activeDevice( );
149 static QString activePlatformVersion( );
152 static void storePreferredDevice(
const QString deviceId );
155 static QString preferredDevice( );
158 static QString deviceId(
const cl::Device device );
163 static QString deviceDescription(
const cl::Device device );
168 static QString deviceDescription(
const QString deviceId );
171 static void setEnabled(
bool enabled );
174 static QString buildLog( cl::BuildError &error );
177 static QString sourceFromPath(
const QString &path );
180 static QString sourceFromBaseName(
const QString &baseName );
186 static QString errorText(
const int errorCode );
194 static cl::CommandQueue commandQueue();
202 Q_DECL_DEPRECATED
static cl::Program buildProgram(
const cl::Context &context,
const QString &source,
ExceptionBehavior exceptionBehavior = Catch );
208 static cl::Program buildProgram(
const QString &source,
ExceptionBehavior exceptionBehavior = Catch );
218 static cl::Context context();
221 static QString sourcePath();
224 static void setSourcePath(
const QString &value );
227 static QString activeDeviceInfo(
const Info infoType = Info::Name );
230 static QString deviceInfo(
const Info infoType, cl::Device device );
236 template <
typename T>
242 explicit CPLAllocator(
unsigned long size ): mMem( static_cast<T *>( CPLMalloc( sizeof( T ) * size ) ) ) { }
246 CPLFree(
static_cast<void *
>( mMem ) );
252 CPLFree(
static_cast<void *
>( mMem ) );
258 reset(
static_cast<T *
>( CPLMalloc(
sizeof( T ) *size ) ) );
306 static bool activate(
const QString &preferredDeviceId = QString() );
313 static bool sAvailable;
314 static QLatin1String SETTINGS_GLOBAL_ENABLED_KEY;
315 static QLatin1String SETTINGS_DEFAULT_DEVICE_KEY;
320 #endif // QGSOPENCLUTILS_H