mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[opencl] Add options widget
This commit is contained in:
parent
3054da0c00
commit
1decb48f65
@ -699,6 +699,7 @@
|
||||
<file>themes/default/mIndicatorEmbedded.svg</file>
|
||||
<file>themes/default/mIconHistory.svg</file>
|
||||
<file>themes/default/mIndicatorMemory.svg</file>
|
||||
<file>themes/default/mIconGPU.svg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/images/tips">
|
||||
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
|
||||
|
14
images/themes/default/mIconGPU.svg
Normal file
14
images/themes/default/mIconGPU.svg
Normal file
@ -0,0 +1,14 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
|
||||
<defs id="defs3051">
|
||||
<style type="text/css" id="current-color-scheme">
|
||||
.ColorScheme-Text {
|
||||
color:#4d4d4d;
|
||||
}
|
||||
</style>
|
||||
</defs>
|
||||
<path
|
||||
style="fill:currentColor;fill-opacity:1;stroke:none"
|
||||
d="M 6 3 L 6 5 L 5 5 L 5 6 L 3 6 L 3 7 L 5 7 L 5 9 L 3 9 L 3 10 L 5 10 L 5 12 L 3 12 L 3 13 L 5 13 L 5 15 L 3 15 L 3 16 L 5 16 L 5 17 L 6 17 L 6 19 L 7 19 L 7 17 L 9 17 L 9 19 L 10 19 L 10 17 L 12 17 L 12 19 L 13 19 L 13 17 L 15 17 L 15 19 L 16 19 L 16 17 L 17 17 L 17 16 L 19 16 L 19 15 L 17 15 L 17 13 L 19 13 L 19 12 L 17 12 L 17 10 L 19 10 L 19 9 L 17 9 L 17 7 L 19 7 L 19 6 L 17 6 L 17 5 L 16 5 L 16 3 L 15 3 L 15 5 L 13 5 L 13 3 L 12 3 L 12 5 L 10 5 L 10 3 L 9 3 L 9 5 L 7 5 L 7 3 L 6 3 z "
|
||||
class="ColorScheme-Text"
|
||||
/>
|
||||
</svg>
|
After Width: | Height: | Size: 832 B |
@ -51,6 +51,10 @@
|
||||
#include "qgslocatorwidget.h"
|
||||
#include "qgslocatoroptionswidget.h"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
#include "qgsopenclutils.h"
|
||||
#endif
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <QFileDialog>
|
||||
#include <QColorDialog>
|
||||
@ -1076,6 +1080,43 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
|
||||
mOptionsStackedWidget->addWidget( page );
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
// Setup OpenCL (GPU) widget
|
||||
mGPUEnableCheckBox->setChecked( QgsOpenClUtils::enabled( ) );
|
||||
if ( QgsOpenClUtils::available( ) )
|
||||
{
|
||||
mGPUEnableCheckBox->setEnabled( true );
|
||||
mGPUInfoLabel->setText( QStringLiteral( "OpenCL compatible GPU found on your system:<br>"
|
||||
"Name: <b>%1</b><br>"
|
||||
"Vendor: <b>%2</b><br>"
|
||||
"Profile: <b>%3</b><br>"
|
||||
"Version: <b>%4</b><br>"
|
||||
).arg( QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::Name ),
|
||||
QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::Vendor ),
|
||||
QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::Profile ),
|
||||
QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::Version ) )
|
||||
);
|
||||
connect( mGPUEnableCheckBox, &QCheckBox::toggled, this, []( bool status )
|
||||
{
|
||||
QgsOpenClUtils::setEnabled( status );
|
||||
}, Qt::UniqueConnection );
|
||||
}
|
||||
else
|
||||
{
|
||||
mGPUEnableCheckBox->setEnabled( false );
|
||||
mGPUInfoLabel->setText( QStringLiteral( "OpenCL compatible GPU was not found on your system. You may need to install additional libraries in order to enable OpenCL." ) );
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
mOptionsListWidget->removeItemWidget( mOptionsListWidget->findItems( QStringLiteral( "GPU" ), Qt::MatchExactly ).first() );
|
||||
mOptionsStackedWidget->removeWidget( mOptionsPageGPU );
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
connect( pbnEditCreateOptions, &QAbstractButton::pressed, this, &QgsOptions::editCreateOptions );
|
||||
connect( pbnEditPyramidsOptions, &QAbstractButton::pressed, this, &QgsOptions::editPyramidsOptions );
|
||||
|
||||
|
@ -114,10 +114,30 @@ void QgsOpenClUtils::setSourcePath( const QString &value )
|
||||
sSourcePath = value;
|
||||
}
|
||||
|
||||
QString QgsOpenClUtils::deviceInfo( const Info infoType )
|
||||
{
|
||||
if ( available( ) )
|
||||
{
|
||||
switch ( infoType )
|
||||
{
|
||||
case Info::Vendor:
|
||||
return QString::fromStdString( sDevice.getInfo<CL_DEVICE_VENDOR>() );
|
||||
case Info::Profile:
|
||||
return QString::fromStdString( sDevice.getInfo<CL_DEVICE_PROFILE>() );
|
||||
case Info::Version:
|
||||
return QString::fromStdString( sDevice.getInfo<CL_DEVICE_VERSION>() );
|
||||
case Info::Name:
|
||||
default:
|
||||
return QString::fromStdString( sDevice.getInfo<CL_DEVICE_NAME>() );
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
bool QgsOpenClUtils::enabled()
|
||||
{
|
||||
return QgsSettings().value( SETTINGS_KEY, true, QgsSettings::Section::Core ).toBool();
|
||||
return QgsSettings().value( SETTINGS_KEY, false, QgsSettings::Section::Core ).toBool();
|
||||
}
|
||||
|
||||
bool QgsOpenClUtils::available()
|
||||
|
@ -23,7 +23,6 @@
|
||||
#define CL_HPP_TARGET_OPENCL_VERSION 110
|
||||
#include <CL/cl2.hpp>
|
||||
|
||||
|
||||
#include "qgis_core.h"
|
||||
#include "qgis.h"
|
||||
|
||||
@ -51,6 +50,14 @@ class CORE_EXPORT QgsOpenClUtils
|
||||
Throw // Write errors in the message log and re-throw exceptions
|
||||
};
|
||||
|
||||
enum Info
|
||||
{
|
||||
Name = CL_DEVICE_NAME,
|
||||
Vendor = CL_DEVICE_VENDOR,
|
||||
Version = CL_DEVICE_VERSION,
|
||||
Profile = CL_DEVICE_PROFILE
|
||||
};
|
||||
|
||||
static bool enabled();
|
||||
static bool available();
|
||||
static void setEnabled( bool enabled );
|
||||
@ -63,6 +70,7 @@ class CORE_EXPORT QgsOpenClUtils
|
||||
static cl::Context context();
|
||||
static QString sourcePath();
|
||||
static void setSourcePath( const QString &value );
|
||||
static QString deviceInfo( const Info infoType = Info::Name );
|
||||
|
||||
/**
|
||||
* Tiny smart-pointer-like wrapper around CPLMalloc and CPLFree: this is needed because
|
||||
|
@ -287,6 +287,18 @@
|
||||
<normaloff>:/images/themes/default/mIconWarning.svg</normaloff>:/images/themes/default/mIconWarning.svg</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>GPU</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Configure GPU for processing algorithms</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mIconGPU.svg</normaloff>:/images/themes/default/mIconGPU.svg</iconset>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -320,7 +332,7 @@
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="mOptionsStackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>16</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="mOptionsPageGeneral">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
@ -1070,7 +1082,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>544</width>
|
||||
<width>843</width>
|
||||
<height>1094</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -5307,6 +5319,47 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="mOptionsPageGPU">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_29">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_53">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Some of the internal C++ processing core algorithms can take advantage of an OpenCL compatible GPU to increase the performances.<br/><span style=" font-weight:600;">QGIS support is highly experimental and can crash QGIS because of bugs in the underlying libraries, enable at your own risk!</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mGPUInfoLabel">
|
||||
<property name="text">
|
||||
<string>Placemark for OpenCL information results (mGPUInfoLabel)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mGPUEnableCheckBox">
|
||||
<property name="text">
|
||||
<string>Enable OpenCL GPU acceleration</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user