mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Wrap make program in OpenCL utils
This commit is contained in:
parent
79f0eadb05
commit
16a49cddaa
@ -528,3 +528,35 @@ cl::Program QgsOpenClUtils::buildProgram( const cl::Context &context, const QStr
|
||||
}
|
||||
return program;
|
||||
}
|
||||
|
||||
cl::Program QgsOpenClUtils::buildProgram( const cl::Context &context, const QString &source, ExceptionBehavior exceptionBehavior )
|
||||
{
|
||||
cl::Program program;
|
||||
try
|
||||
{
|
||||
program = cl::Program( context, source.toStdString( ) );
|
||||
program.build( "-cl-std=CL1.1" );
|
||||
}
|
||||
catch ( cl::BuildError &e )
|
||||
{
|
||||
cl::BuildLogType build_logs = e.getBuildLog();
|
||||
QString build_log;
|
||||
if ( build_logs.size() > 0 )
|
||||
build_log = QString::fromStdString( build_logs[0].second );
|
||||
else
|
||||
build_log = QObject::tr( "Build logs not available!" );
|
||||
QString err = QObject::tr( "Error building OpenCL program: %1" )
|
||||
.arg( build_log );
|
||||
QgsMessageLog::logMessage( err, LOGMESSAGE_TAG, Qgis::Critical );
|
||||
if ( exceptionBehavior == Throw )
|
||||
throw e;
|
||||
}
|
||||
catch ( cl::Error &e )
|
||||
{
|
||||
QString err = QObject::tr( "Error %1 running OpenCL program in %2" )
|
||||
.arg( errorText( e.err() ), QString::fromStdString( e.what() ) );
|
||||
QgsMessageLog::logMessage( err, LOGMESSAGE_TAG, Qgis::Critical );
|
||||
throw e;
|
||||
}
|
||||
return program;
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ class CORE_EXPORT QgsOpenClUtils
|
||||
|
||||
public:
|
||||
|
||||
<<<<<<< 79f0eadb05fe4d845ab29045c40c34e1e08b4710
|
||||
/**
|
||||
* The ExceptionBehavior enum define how exceptions generated by OpenCL should be treated
|
||||
*/
|
||||
@ -113,6 +114,15 @@ class CORE_EXPORT QgsOpenClUtils
|
||||
*
|
||||
* This function must always be called before using QGIS OpenCL utils
|
||||
*/
|
||||
=======
|
||||
enum ExceptionBehavior
|
||||
{
|
||||
Catch,
|
||||
Throw
|
||||
};
|
||||
|
||||
static bool enabled();
|
||||
>>>>>>> Wrap make program in OpenCL utils
|
||||
static bool available();
|
||||
|
||||
//! Returns true if OpenCL is enabled in the user settings
|
||||
@ -166,6 +176,7 @@ class CORE_EXPORT QgsOpenClUtils
|
||||
|
||||
//! Returns a string representation from an OpenCL \a errorCode
|
||||
static QString errorText( const int errorCode );
|
||||
<<<<<<< 79f0eadb05fe4d845ab29045c40c34e1e08b4710
|
||||
|
||||
/**
|
||||
* Build the program from \a source in the given \a context and depending on \a exceptionBehavior
|
||||
@ -181,6 +192,9 @@ class CORE_EXPORT QgsOpenClUtils
|
||||
* no device were identified or OpenCL support is not available
|
||||
* and enabled
|
||||
*/
|
||||
=======
|
||||
static cl::Program buildProgram( const cl::Context &context, const QString &source, ExceptionBehavior exceptionBehavior = Catch );
|
||||
>>>>>>> Wrap make program in OpenCL utils
|
||||
static cl::Context context();
|
||||
|
||||
//! Returns the base path to OpenCL program directory
|
||||
|
Loading…
x
Reference in New Issue
Block a user