Skip to content
Permalink
Browse files

[opencl] Fix device selection on start

  • Loading branch information
elpaso committed Aug 8, 2018
1 parent d846804 commit add3d074b8e41439494f146abb8438860adf81b3
Showing with 14 additions and 8 deletions.
  1. +6 −3 src/app/qgsoptions.cpp
  2. +8 −5 src/core/qgsopenclutils.cpp
@@ -1090,13 +1090,16 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti

for ( const auto &dev : QgsOpenClUtils::devices( ) )
{
mOpenClDevicesCombo->addItem( QgsOpenClUtils::deviceId( dev ), QgsOpenClUtils::deviceId( dev ) );
mOpenClDevicesCombo->addItem( QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::Name, dev ), QgsOpenClUtils::deviceId( dev ) );
}
connect( mOpenClDevicesCombo, qgis::overload< int >::of( &QComboBox::currentIndexChanged ), [ = ]( int )
// Info updater
std::function<void( int )> infoUpdater = [ = ]( int )
{
mGPUInfoLabel->setText( QgsOpenClUtils::deviceDescription( mOpenClDevicesCombo->currentData().toString() ) );
} );
};
connect( mOpenClDevicesCombo, qgis::overload< int >::of( &QComboBox::currentIndexChanged ), infoUpdater );
mOpenClDevicesCombo->setCurrentIndex( mOpenClDevicesCombo->findData( QgsOpenClUtils::deviceId( QgsOpenClUtils::activeDevice() ) ) );
infoUpdater( -1 );
}
else
{
@@ -149,9 +149,10 @@ QString QgsOpenClUtils::deviceInfo( const Info infoType, cl::Device device )
}
catch ( cl::Error &e )
{
QgsMessageLog::logMessage( QObject::tr( "Error %1 getting info for OpenCL device: %2" )
.arg( errorText( e.err() ), QString::fromStdString( e.what() ) ),
LOGMESSAGE_TAG, Qgis::Critical );
// This can be a legitimate error when initializing, let's log it quietly
QgsDebugMsgLevel( QStringLiteral( "Error %1 getting info for OpenCL device: %2" )
.arg( errorText( e.err() ), QString::fromStdString( e.what() ) ),
4 );
return QString();
}
}
@@ -193,7 +194,7 @@ QString QgsOpenClUtils::deviceId( const cl::Device device )

bool QgsOpenClUtils::activate( const QString preferredDeviceId )
{
if ( preferredDeviceId.isEmpty() || deviceId( activeDevice() ) == preferredDeviceId )
if ( deviceId( activeDevice() ) == preferredDeviceId )
{
return false;
}
@@ -275,6 +276,7 @@ bool QgsOpenClUtils::activate( const QString preferredDeviceId )
QString QgsOpenClUtils::deviceDescription( const cl::Device device )
{
return QStringLiteral(
"Type: <b>%9</b><br>"
"Name: <b>%1</b><br>"
"Vendor: <b>%2</b><br>"
"Profile: <b>%3</b><br>"
@@ -290,7 +292,8 @@ QString QgsOpenClUtils::deviceDescription( const cl::Device device )
QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::ImageSupport, device ),
QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::Image2dMaxWidth, device ),
QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::Image2dMaxHeight, device ),
QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::MaxMemAllocSize, device ) );
QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::MaxMemAllocSize, device ),
QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::Type, device ) );
}

QString QgsOpenClUtils::deviceDescription( const QString deviceId )

0 comments on commit add3d07

Please sign in to comment.
You can’t perform that action at this time.