Skip to content
Permalink
Browse files

[opencl] Small optimization in hillshade

... and more tolerant epsilon for float comparison in tests
  • Loading branch information
elpaso committed Aug 8, 2018
1 parent 82b60df commit b89808f5736bbc8144aa34dccc6ccf3c72174337
Showing with 1 addition and 22 deletions.
  1. +0 −21 resources/opencl_programs/hillshade.cl
  2. +1 −1 tests/src/analysis/testqgsninecellfilters.cpp
@@ -1,11 +1,8 @@
#include "calcfirstder.cl"
<<<<<<< 30a62e1addd2541bdbecda4398381772eb8034d4

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
=======
>>>>>>> [opencl] Fix small OpenCL alg issues

__kernel void processNineCellWindow( __global float *scanLine1,
__global float *scanLine2,
@@ -42,7 +39,6 @@ __kernel void processNineCellWindow( __global float *scanLine1,
else
{

<<<<<<< 30a62e1addd2541bdbecda4398381772eb8034d4
float slope_rad = sqrt( derX * derX + derY * derY );
slope_rad = atan( slope_rad );
float aspect_rad;
@@ -54,23 +50,6 @@ __kernel void processNineCellWindow( __global float *scanLine1,
resultLine[i] = max(0.0f, 255.0f * ( ( rasterParams[5] * cos( slope_rad ) ) +
( rasterParams[6] * sin( slope_rad ) *
cos( rasterParams[7] - aspect_rad ) ) ) );
=======
float zenith_rad = rasterParams[5];
float azimuth_rad = rasterParams[6];
float slope_rad = sqrt( derX * derX + derY * derY );


slope_rad = atan( slope_rad );
float aspect_rad;
if ( derX == 0.0f && derY == 0.0f)
aspect_rad = azimuth_rad / 2.0f;
else
aspect_rad = M_PI + atan2( derX, derY );

resultLine[i] = max(0.0f, 255.0f * ( ( cos( zenith_rad ) * cos( slope_rad ) ) +
( sin( zenith_rad ) * sin( slope_rad ) *
cos( azimuth_rad - aspect_rad ) ) ) );
>>>>>>> [opencl] Fix small OpenCL alg issues

}
}
@@ -180,7 +180,7 @@ void TestNineCellFilters::_rasterCompare( QgsAlignRaster::RasterInfo &out, QgsA
QCOMPARE( out.cellSize(), refCellSize );

// If the values differ less than tolerance they are considered equal
double tolerance = 0.0000001;
double tolerance = 0.0001;

// Check three points
std::map<int, int> controlPoints;

0 comments on commit b89808f

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