Skip to content
Permalink
Browse files

Move nodeCalc unique ptr to the GPU function

... and spare some CPU cycles
  • Loading branch information
elpaso committed Dec 3, 2018
1 parent 5ef8737 commit 61dd729517d1aab5fb22d4bc35e162748df9c84f
Showing with 5 additions and 5 deletions.
  1. +3 −4 src/analysis/raster/qgsrastercalculator.cpp
  2. +2 −1 src/analysis/raster/qgsrastercalculator.h
@@ -17,7 +17,6 @@

#include "qgsgdalutils.h"
#include "qgsrastercalculator.h"
#include "qgsrastercalcnode.h"
#include "qgsrasterdataprovider.h"
#include "qgsrasterinterface.h"
#include "qgsrasterlayer.h"
@@ -95,7 +94,7 @@ QgsRasterCalculator::Result QgsRasterCalculator::processCalculation( QgsFeedback
// Check for matrix nodes, GPU implementation does not support them
QList<const QgsRasterCalcNode *> nodeList;
if ( QgsOpenClUtils::enabled() && QgsOpenClUtils::available() && calcNode->findNodes( QgsRasterCalcNode::Type::tMatrix ).isEmpty() )
return processCalculationGPU( feedback );
return processCalculationGPU( std::move( calcNode ), feedback );
#endif

//open output dataset for writing
@@ -313,9 +312,9 @@ QgsRasterCalculator::Result QgsRasterCalculator::processCalculation( QgsFeedback
}

#ifdef HAVE_OPENCL
QgsRasterCalculator::Result QgsRasterCalculator::processCalculationGPU( QgsFeedback *feedback )
QgsRasterCalculator::Result QgsRasterCalculator::processCalculationGPU( std::unique_ptr< QgsRasterCalcNode > calcNode, QgsFeedback *feedback )
{
std::unique_ptr< QgsRasterCalcNode > calcNode( QgsRasterCalcNode::parseRasterCalcString( mFormulaString, mLastError ) );

QString cExpression( calcNode->toString( true ) );

QList<const QgsRasterCalcNode *> nodeList( calcNode->findNodes( QgsRasterCalcNode::Type::tRasterRef ) );
@@ -25,6 +25,7 @@
#include "gdal.h"
#include "qgis_analysis.h"
#include "qgsogrutils.h"
#include "qgsrastercalcnode.h"

class QgsRasterLayer;
class QgsFeedback;
@@ -152,7 +153,7 @@ class ANALYSIS_EXPORT QgsRasterCalculator
void outputGeoTransform( double *transform ) const;

//! Execute calculations on GPU
Result processCalculationGPU( QgsFeedback *feedback = nullptr );
Result processCalculationGPU( std::unique_ptr< QgsRasterCalcNode > calcNode, QgsFeedback *feedback = nullptr );

QString mFormulaString;
QString mOutputFile;

0 comments on commit 61dd729

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