@@ -27,8 +27,6 @@ QLatin1String QgsOpenClUtils::SETTINGS_GLOBAL_ENABLED_KEY = QLatin1Literal( "Ope
27
27
QLatin1String QgsOpenClUtils::SETTINGS_DEFAULT_DEVICE_KEY = QLatin1Literal( " OpenClDefaultDevice" );
28
28
QLatin1String QgsOpenClUtils::LOGMESSAGE_TAG = QLatin1Literal( " OpenCL" );
29
29
bool QgsOpenClUtils::sAvailable = false ;
30
- cl::Platform QgsOpenClUtils::sDefaultPlatform = cl::Platform();
31
- cl::Device QgsOpenClUtils::sActiveDevice = cl::Device();
32
30
QString QgsOpenClUtils::sSourcePath = QString();
33
31
34
32
@@ -163,15 +161,15 @@ bool QgsOpenClUtils::enabled()
163
161
164
162
cl::Device QgsOpenClUtils::activeDevice ()
165
163
{
166
- return sActiveDevice ;
164
+ return cl::Device::getDefault () ;
167
165
}
168
166
169
167
QString QgsOpenClUtils::activePlatformVersion ()
170
168
{
171
169
QString version;
172
- if ( QgsOpenClUtils::sDefaultPlatform () )
170
+ if ( cl::Platform::getDefault () () )
173
171
{
174
- std::string platver = QgsOpenClUtils:: sDefaultPlatform .getInfo <CL_PLATFORM_VERSION>();
172
+ std::string platver = cl::Platform::getDefault () .getInfo <CL_PLATFORM_VERSION>();
175
173
if ( platver.find ( " OpenCL " ) != std::string::npos )
176
174
{
177
175
version = QString::fromStdString ( platver.substr ( 7 ) ).split ( ' ' ).first ();
@@ -203,6 +201,7 @@ bool QgsOpenClUtils::activate( const QString &preferredDeviceId )
203
201
{
204
202
if ( deviceId ( activeDevice () ) == preferredDeviceId )
205
203
{
204
+ sAvailable = true ;
206
205
return false ;
207
206
}
208
207
try
@@ -306,8 +305,6 @@ bool QgsOpenClUtils::activate( const QString &preferredDeviceId )
306
305
.arg ( QString::fromStdString ( dev.getInfo <CL_DEVICE_NAME>() ) ),
307
306
LOGMESSAGE_TAG, Qgis::Success );
308
307
sAvailable = true ;
309
- sActiveDevice = dev;
310
- sDefaultPlatform = plat;
311
308
}
312
309
}
313
310
}
@@ -526,9 +523,9 @@ cl::Context QgsOpenClUtils::context()
526
523
static std::once_flag contextCreated;
527
524
std::call_once ( contextCreated, [ = ]()
528
525
{
529
- if ( available () && sDefaultPlatform () && sActiveDevice () )
526
+ if ( available () && cl::Platform::getDefault ()() && cl::Device::getDefault () () )
530
527
{
531
- context = cl::Context ( sActiveDevice );
528
+ context = cl::Context ( cl::Device::getDefault () );
532
529
}
533
530
} );
534
531
return context;
0 commit comments