@@ -217,10 +217,20 @@ int QgsNineCellFilter::processRasterGPU( const QString &source, QgsFeedback *fee
217217
218218 // Prepare context and queue
219219 cl::Context ctx = QgsOpenClUtils::context ();
220+ <<<<<<< 16a49cddaa18cb6d0b12335fe24c68cda183e1c0
220221 cl::CommandQueue queue ( ctx );
221222
222223 // keep only three scanlines in memory at a time, make room for initial and final nodata
223224 QgsOpenClUtils::CPLAllocator<float > scanLine ( xSize + 2 );
225+ =======
226+ cl::Context::setDefault ( ctx );
227+ cl::CommandQueue queue ( ctx );
228+
229+ // keep only three scanlines in memory at a time, make room for initial and final nodata
230+ QgsOpenClUtils::CPLAllocator<float > scanLine1 ( xSize + 2 );
231+ QgsOpenClUtils::CPLAllocator<float > scanLine2 ( xSize + 2 );
232+ QgsOpenClUtils::CPLAllocator<float > scanLine3 ( xSize + 2 );
233+ >>>>>>> Use OpenCL command queue
224234 QgsOpenClUtils::CPLAllocator<float > resultLine ( xSize );
225235
226236 // Cast to float (because double just crashes on some GPUs)
@@ -289,7 +299,18 @@ int QgsNineCellFilter::processRasterGPU( const QString &source, QgsFeedback *fee
289299 {
290300 QgsDebugMsg ( " Raster IO Error" );
291301 }
302+ <<<<<<< 16a49cddaa18cb6d0b12335fe24c68cda183e1c0
292303 queue.enqueueWriteBuffer ( scanLine2Buffer, CL_TRUE, 0 , bufferSize, scanLine.get () );
304+ =======
305+ }
306+ else
307+ {
308+ // normally fetch only scanLine3 and release scanline 1 if we move forward one row
309+ scanLine1.reset ( scanLine2.release () );
310+ scanLine2.reset ( scanLine3.release () );
311+ scanLine3.reset ( xSize + 2 );
312+ }
313+ >>>>>>> Use OpenCL command queue
293314
294315 // Read scanline3: second real raster row
295316 if ( GDALRasterIO ( rasterBand, GF_Read, 0 , i + 1 , xSize, 1 , &scanLine[1 ], xSize, 1 , GDT_Float32, 0 , 0 ) != CE_None )
@@ -320,6 +341,23 @@ int QgsNineCellFilter::processRasterGPU( const QString &source, QgsFeedback *fee
320341 queue.enqueueWriteBuffer ( *scanLineBuffer[rowIndex[2 ]], CL_TRUE, 0 , bufferSize, scanLine.get () ); // row 0
321342 }
322343 }
344+ <<<<<<< 16a49cddaa18cb6d0b12335fe24c68cda183e1c0
345+ =======
346+ // Set first and last extra colums to nodata
347+ scanLine1[0 ] = scanLine1[xSize + 1 ] = mInputNodataValue ;
348+ scanLine2[0 ] = scanLine2[xSize + 1 ] = mInputNodataValue ;
349+ scanLine3[0 ] = scanLine3[xSize + 1 ] = mInputNodataValue ;
350+
351+ // TODO: There is room for further optimization here: instead of replacing the buffers
352+ // we could just replace just hthe new one (the top row) and switch the order
353+ // of buffer arguments in the kernell call.
354+ errorCode = cl::enqueueWriteBuffer ( scanLine1Buffer, CL_TRUE, 0 ,
355+ sizeof ( float ) * ( xSize + 2 ), scanLine1.get () );
356+ errorCode = cl::enqueueWriteBuffer ( scanLine2Buffer, CL_TRUE, 0 ,
357+ sizeof ( float ) * ( xSize + 2 ), scanLine2.get () );
358+ errorCode = cl::enqueueWriteBuffer ( scanLine3Buffer, CL_TRUE, 0 ,
359+ sizeof ( float ) * ( xSize + 2 ), scanLine3.get () );
360+ >>>>>>> Use OpenCL command queue
323361
324362 kernel ( cl::EnqueueArgs (
325363 queue,
0 commit comments