Skip to content
Permalink
Browse files

[opencl] Final rebase before merge

  • Loading branch information
elpaso committed Aug 8, 2018
1 parent e79f6d1 commit 44adfe53df98b640236110c82300f293b1882058
@@ -33,33 +33,16 @@ MESSAGE(STATUS "QGIS version: ${COMPLETE_VERSION} ${RELEASE_NAME} (${QGIS_VERSIO
OPTION(USE_OPENCL "Use OpenCL" ON)
IF (USE_OPENCL)
FIND_PACKAGE(OpenCL)
<<<<<<< c42a748afc413e235254d2a94dc8af75d2109822
if(${OpenCL_FOUND})
<<<<<<< a1a09d75e627b0f085c5a1177db5d58374ca6f44
=======
IF(${OpenCL_FOUND})
>>>>>>> [opencl] Uppercase CMake
SET(HAVE_OPENCL TRUE)
ELSE(${OpenCL_FOUND})
MESSAGE(STATUS "Couldn't find OpenCL: support DISABLED")
<<<<<<< c42a748afc413e235254d2a94dc8af75d2109822
=======
SET (USE_OPENCL TRUE CACHE BOOL "Use OpenCL")
IF(USE_OPENCL)
SET(HAVE_OPENCL TRUE)
ENDIF(USE_OPENCL)
<<<<<<< a420474ec4f22e581be5ba5c5ca47eae5d7e0447
>>>>>>> OpenCL POC 1
=======
else(${OpenCL_FOUND})
MESSAGE(FATAL_ERROR "Couldn't find OpenCL")
>>>>>>> [opencl] Error message when OpenCL could not be found
endif(${OpenCL_FOUND})
endif(USE_OPENCL)
=======
ENDIF(${OpenCL_FOUND})
ENDIF(USE_OPENCL)
>>>>>>> [opencl] Uppercase CMake

# Configure CCache if available
IF(NOT MSVC)
@@ -30,14 +30,6 @@ nodata value if not present or outside of the border. Must be implemented by sub
%End


<<<<<<< 573283f0dcf022e84bd615e84fd2656043a9722b
<<<<<<< d6e747ca57807318c0b3f6be8266f0b43c0f7747
=======


>>>>>>> More updates for opencl
=======
>>>>>>> [opencl] Fix small OpenCL alg issues
};

/************************************************************************
@@ -36,18 +36,6 @@ Starts the calculation, reads from mInputFile and stores the result in mOutputFi
:param feedback: feedback object that receives update and that is checked for cancelation.

:return: 0 in case of success
<<<<<<< 14f8c4361dc1f4103bed735a5cf46b38dcfa4a03
<<<<<<< 528302cc8952497513b44423dfca6fcf4857760c
<<<<<<< d6e747ca57807318c0b3f6be8266f0b43c0f7747
TODO: return an enum
=======
TODO: return an enum
>>>>>>> More updates for opencl
=======
TODO: return an enum
>>>>>>> Bindings for 9cell filter
=======
>>>>>>> Fix documentation for ninecell filters
%End

double cellSizeX() const;
@@ -73,16 +61,16 @@ Must be implemented by subclasses.

First index of the input cell is the row, second index is the column

@param x11 surrounding cell top left
@param x21 surrounding cell central left
@param x31 surrounding cell bottom left
@param x12 surrounding cell top central
@param x22 the central cell for which the value will be calculated
@param x32 surrounding cell bottom central
@param x13 surrounding cell top right
@param x23 surrounding cell central right
@param x33 surrounding cell bottom right
@return the calculated cell value for the central cell x22
:param x11: surrounding cell top left
:param x21: surrounding cell central left
:param x31: surrounding cell bottom left
:param x12: surrounding cell top central
:param x22: the central cell for which the value will be calculated
:param x32: surrounding cell bottom central
:param x13: surrounding cell top right
:param x23: surrounding cell central right
:param x33: surrounding cell bottom right
@return the calculated cell value for the central cell x22
%End

protected:
@@ -29,14 +29,7 @@ Calculates output value from nine input values. The input values and the output
nodata value if not present or outside of the border. Must be implemented by subclasses*
%End

<<<<<<< 573283f0dcf022e84bd615e84fd2656043a9722b
<<<<<<< d6e747ca57807318c0b3f6be8266f0b43c0f7747

=======
>>>>>>> More updates for opencl
=======

>>>>>>> [opencl] Fix small OpenCL alg issues
};

/************************************************************************
@@ -21,31 +21,11 @@
QgsHillshadeFilter::QgsHillshadeFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat, double lightAzimuth,
double lightAngle )
: QgsDerivativeFilter( inputFile, outputFile, outputFormat )
<<<<<<< 78a45b7db48bbf028fbb9ff9fa9690d2a596d7ef
<<<<<<< 573283f0dcf022e84bd615e84fd2656043a9722b
=======
>>>>>>> Fix some cast warnings, pre-calc values for speed
, mLightAzimuth( static_cast<float>( lightAzimuth ) )
, mLightAngle( static_cast<float>( lightAngle ) )
, mCosZenithRad( std::cos( static_cast<float>( lightAngle * M_PI ) / 180.0f ) )
, mSinZenithRad( std::sin( static_cast<float>( lightAngle * M_PI ) / 180.0f ) )
, mAzimuthRad( static_cast<float>( lightAzimuth * M_PI ) / 180.0f )
<<<<<<< 78a45b7db48bbf028fbb9ff9fa9690d2a596d7ef
=======
, mLightAzimuth( lightAzimuth )
, mLightAngle( lightAngle )
<<<<<<< 8f40129d09776c7fe96b88604405a908595f9ede
, mCosZenithRad( std::cos( mLightAngle * M_PI / 180.0 ) )
, mSinZenithRad( std::sin( mLightAngle * M_PI / 180.0 ) )
, mAzimuthRad( mLightAzimuth * M_PI / 180.0 )
>>>>>>> [opencl] Fix small OpenCL alg issues
=======
, mCosZenithRad( std::cos( mLightAngle * M_PI / 180.0f ) )
, mSinZenithRad( std::sin( mLightAngle * M_PI / 180.0f ) )
, mAzimuthRad( mLightAzimuth * M_PI / 180.0f )
>>>>>>> [opencl] Small optimization in hillshade
=======
>>>>>>> Fix some cast warnings, pre-calc values for speed
{
}

@@ -66,24 +46,12 @@ float QgsHillshadeFilter::processNineCellWindow( float *x11, float *x21, float *
float aspect_rad = 0;
if ( derX == 0 && derY == 0 ) //aspect undefined, take a neutral value. Better solutions?
{
<<<<<<< 78a45b7db48bbf028fbb9ff9fa9690d2a596d7ef
<<<<<<< 573283f0dcf022e84bd615e84fd2656043a9722b
aspect_rad = mAzimuthRad / 2.0f;
=======
aspect_rad = mAzimuthRad / 2.0;
>>>>>>> [opencl] Fix small OpenCL alg issues
=======
aspect_rad = mAzimuthRad / 2.0f;
>>>>>>> Fix some cast warnings, pre-calc values for speed
}
else
{
aspect_rad = M_PI + std::atan2( derX, derY );
}
<<<<<<< 78a45b7db48bbf028fbb9ff9fa9690d2a596d7ef
<<<<<<< 573283f0dcf022e84bd615e84fd2656043a9722b
=======
>>>>>>> Fix some cast warnings, pre-calc values for speed
return std::max( 0.0f, 255.0f * ( ( mCosZenithRad * std::cos( slope_rad ) ) +
( mSinZenithRad * std::sin( slope_rad ) *
std::cos( mAzimuthRad - aspect_rad ) ) ) );
@@ -100,34 +68,10 @@ void QgsHillshadeFilter::setLightAngle( float angle )
mLightAngle = angle;
mCosZenithRad = std::cos( angle * static_cast<float>( M_PI ) / 180.0f );
mSinZenithRad = std::sin( angle * static_cast<float>( M_PI ) / 180.0f );
<<<<<<< 78a45b7db48bbf028fbb9ff9fa9690d2a596d7ef
}

<<<<<<< a73bbbad21629d81b9b1d4217a096a930473eb5c
#ifdef HAVE_OPENCL

void QgsHillshadeFilter::addExtraRasterParams( std::vector<float> &params )
{

params.push_back( mCosZenithRad ); // cos_zenith_rad 5
params.push_back( mSinZenithRad ); // sin_zenith_rad 6
params.push_back( mAzimuthRad ); // azimuth_rad 7

}

#endif
=======
=======
return std::max( 0.0, 255.0 * ( ( mCosZenithRad * std::cos( slope_rad ) ) +
( mSinZenithRad * std::sin( slope_rad ) *
std::cos( mAzimuthRad - aspect_rad ) ) ) );
=======
>>>>>>> Fix some cast warnings, pre-calc values for speed
}

#ifdef HAVE_OPENCL

>>>>>>> [opencl] Fix small OpenCL alg issues
void QgsHillshadeFilter::addExtraRasterParams( std::vector<float> &params )
{

@@ -136,9 +80,5 @@ void QgsHillshadeFilter::addExtraRasterParams( std::vector<float> &params )
params.push_back( mAzimuthRad ); // azimuth_rad 7

}
<<<<<<< 573283f0dcf022e84bd615e84fd2656043a9722b
>>>>>>> [opencl] Use fast formula for hillshade
=======

#endif
>>>>>>> [opencl] Fix small OpenCL alg issues
@@ -44,48 +44,21 @@ class ANALYSIS_EXPORT QgsHillshadeFilter: public QgsDerivativeFilter
void setLightAngle( float angle );

private:
<<<<<<< 573283f0dcf022e84bd615e84fd2656043a9722b
<<<<<<< a73bbbad21629d81b9b1d4217a096a930473eb5c

#ifdef HAVE_OPENCL

=======
>>>>>>> [opencl] Use fast formula for hillshade
=======

#ifdef HAVE_OPENCL

>>>>>>> [opencl] Fix small OpenCL alg issues
const QString openClProgramBaseName() const override
{
return QStringLiteral( "hillshade" );
}
<<<<<<< 573283f0dcf022e84bd615e84fd2656043a9722b
<<<<<<< a73bbbad21629d81b9b1d4217a096a930473eb5c
#endif

=======
>>>>>>> [opencl] Use fast formula for hillshade
=======
#endif

>>>>>>> [opencl] Fix small OpenCL alg issues
float mLightAzimuth;
float mLightAngle;
// Precalculate for speed:
float mCosZenithRad;
float mSinZenithRad;
float mAzimuthRad;
<<<<<<< 573283f0dcf022e84bd615e84fd2656043a9722b


#ifdef HAVE_OPENCL
private:

void addExtraRasterParams( std::vector<float> &params ) override;
#endif
=======
>>>>>>> [opencl] Fix small OpenCL alg issues


#ifdef HAVE_OPENCL

0 comments on commit 44adfe5

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