@@ -57,29 +57,9 @@ int QgsNineCellFilter::processRaster( QgsFeedback *feedback )
57
57
.arg ( openClProgramBaseName ( ) ), QgsOpenClUtils::LOGMESSAGE_TAG, Qgis::Info );
58
58
return processRasterGPU ( source, feedback );
59
59
}
60
- <<<<<<< 583c7ae28727cddaff53706903980733bd4b8979
61
60
catch ( cl::Error &e )
62
61
{
63
62
QString err = QObject::tr ( " Error running OpenCL program: %1 - %2" ).arg ( e.what ( ) ).arg ( QgsOpenClUtils::errorText ( e.err ( ) ) );
64
- =======
65
- catch ( cl::BuildError &e )
66
- {
67
- cl::BuildLogType build_logs = e.getBuildLog ();
68
- QString build_log;
69
- if ( build_logs.size () > 0 )
70
- build_log = QString::fromStdString ( build_logs[0 ].second );
71
- else
72
- build_log = QObject::tr ( " Build logs not available!" );
73
- QString err = QObject::tr ( " Error building OpenCL program: %1" )
74
- .arg ( build_log );
75
- QgsMessageLog::logMessage ( err, QgsOpenClUtils::LOGMESSAGE_TAG, Qgis::Critical );
76
- throw QgsProcessingException ( err );
77
- }
78
- catch ( cl::Error &e )
79
- {
80
- QString err = QObject::tr ( " Error %1 running OpenCL program in %2" )
81
- .arg ( QgsOpenClUtils::errorText ( e.err () ), QString::fromStdString ( e.what () ) );
82
- >>>>>>> Try to avoid crash on intel haswell
83
63
QgsMessageLog::logMessage ( err, QgsOpenClUtils::LOGMESSAGE_TAG, Qgis::Critical );
84
64
throw QgsProcessingException ( err );
85
65
}
@@ -235,21 +215,9 @@ int QgsNineCellFilter::processRasterGPU( const QString &source, QgsFeedback *fee
235
215
return 6 ;
236
216
}
237
217
238
- <<<<<<< 7e1d9298000637436eb49d0a886978ad33476894
239
218
// Prepare context and queue
240
219
cl::Context ctx = QgsOpenClUtils::context ();
241
220
cl::CommandQueue queue ( ctx );
242
- =======
243
- // keep only three scanlines in memory at a time, make room for initial and final nodata
244
- QgsOpenClUtils::CPLAllocator<float > scanLine1 ( xSize + 2 );
245
- QgsOpenClUtils::CPLAllocator<float > scanLine2 ( xSize + 2 );
246
- QgsOpenClUtils::CPLAllocator<float > scanLine3 ( xSize + 2 );
247
- // float *scanLine2 = ( float * ) CPLMalloc( sizeof( float ) * ( xSize + 2 ) );
248
- // float *scanLine3 = ( float * ) CPLMalloc( sizeof( float ) * ( xSize + 2 ) );
249
-
250
- // float *resultLine = ( float * ) CPLMalloc( sizeof( float ) * xSize );
251
- QgsOpenClUtils::CPLAllocator<float > resultLine ( xSize );
252
- >>>>>>> CPLAllocator smart wrapper
253
221
254
222
// keep only three scanlines in memory at a time, make room for initial and final nodata
255
223
QgsOpenClUtils::CPLAllocator<float > scanLine ( xSize + 2 );
@@ -268,8 +236,6 @@ int QgsNineCellFilter::processRasterGPU( const QString &source, QgsFeedback *fee
268
236
// used to pass additional args to opencl program
269
237
addExtraRasterParams ( rasterParams );
270
238
271
- <<<<<<< 7e1d9298000637436eb49d0a886978ad33476894
272
- <<<<<<< 583c7ae28727cddaff53706903980733bd4b8979
273
239
std::size_t bufferSize ( sizeof ( float ) * ( xSize + 2 ) );
274
240
std::size_t inputSize ( sizeof ( float ) * ( xSize ) );
275
241
@@ -297,43 +263,17 @@ int QgsNineCellFilter::processRasterGPU( const QString &source, QgsFeedback *fee
297
263
298
264
// values outside the layer extent (if the 3x3 window is on the border) are sent to the processing method as (input) nodata values
299
265
for ( int i = 0 ; i < ySize; ++i )
300
- =======
301
- try
302
- >>>>>>> Try to avoid crash on intel haswell
303
- {
304
- =======
305
- >>>>>>> CPLAllocator smart wrapper
306
-
307
- cl::Buffer rasterParamsBuffer ( rasterParams.begin (), rasterParams.end (), true , false , &errorCode );
308
- cl::Buffer scanLine1Buffer ( CL_MEM_READ_ONLY, sizeof ( float ) * ( xSize + 2 ), nullptr , &errorCode );
309
- cl::Buffer scanLine2Buffer ( CL_MEM_READ_ONLY, sizeof ( float ) * ( xSize + 2 ), nullptr , &errorCode );
310
- cl::Buffer scanLine3Buffer ( CL_MEM_READ_ONLY, sizeof ( float ) * ( xSize + 2 ), nullptr , &errorCode );
311
- cl::Buffer resultLineBuffer ( CL_MEM_WRITE_ONLY, sizeof ( float ) * xSize, nullptr , &errorCode );
312
-
313
- // Create a program from the kernel source
314
- cl::Program program ( source.toStdString () );
315
- // Use CL 1.1 for compatibility with older libs
316
- program.build ( " -cl-std=CL1.1" );
317
-
318
- // Create the OpenCL kernel
319
- auto kernel = cl::KernelFunctor <
320
- cl::Buffer &,
321
- cl::Buffer &,
322
- cl::Buffer &,
323
- cl::Buffer &,
324
- cl::Buffer &
325
- > ( program, " processNineCellWindow" );
326
-
327
- // values outside the layer extent (if the 3x3 window is on the border) are sent to the processing method as (input) nodata values
328
- for ( int i = 0 ; i < ySize; ++i )
329
266
{
330
267
if ( feedback && feedback->isCanceled () )
331
268
{
332
269
break ;
333
270
}
334
271
335
- <<<<<<< 7e1d9298000637436eb49d0a886978ad33476894
336
- <<<<<<< 583c7ae28727cddaff53706903980733bd4b8979
272
+ if ( feedback )
273
+ {
274
+ feedback->setProgress ( 100.0 * static_cast < double >( i ) / ySize );
275
+ }
276
+
337
277
if ( i == 0 )
338
278
{
339
279
// Fill scanline 1 with (input) nodata for the values above the first row and
@@ -346,35 +286,9 @@ int QgsNineCellFilter::processRasterGPU( const QString &source, QgsFeedback *fee
346
286
347
287
// Read scanline2: first real raster row
348
288
if ( GDALRasterIO ( rasterBand, GF_Read, 0 , i, xSize, 1 , &scanLine[1 ], xSize, 1 , GDT_Float32, 0 , 0 ) != CE_None )
349
- =======
350
- if ( feedback )
351
- {
352
- feedback->setProgress ( 100.0 * static_cast < double >( i ) / ySize );
353
- }
354
-
355
- if ( i == 0 )
356
- >>>>>>> Try to avoid crash on intel haswell
357
- =======
358
- if ( feedback )
359
- {
360
- feedback->setProgress ( 100.0 * static_cast < double >( i ) / ySize );
361
- }
362
-
363
- if ( i == 0 )
364
- {
365
- // fill scanline 1 with (input) nodata for the values above the first row and feed scanline2 with the first row
366
- for ( int a = 0 ; a < xSize + 2 ; ++a )
367
- >>>>>>> CPLAllocator smart wrapper
368
- {
369
- scanLine1[a] = mInputNodataValue ;
370
- }
371
- // Read scanline2
372
- if ( GDALRasterIO ( rasterBand, GF_Read, 0 , 0 , xSize, 1 , &scanLine2[1 ], xSize, 1 , GDT_Float32, 0 , 0 ) != CE_None )
373
289
{
374
290
QgsDebugMsg ( " Raster IO Error" );
375
291
}
376
- <<<<<<< 7e1d9298000637436eb49d0a886978ad33476894
377
- <<<<<<< 583c7ae28727cddaff53706903980733bd4b8979
378
292
queue.enqueueWriteBuffer ( scanLine2Buffer, CL_TRUE, 0 , bufferSize, scanLine.get () );
379
293
380
294
// Read scanline3: second real raster row
@@ -389,69 +303,13 @@ int QgsNineCellFilter::processRasterGPU( const QString &source, QgsFeedback *fee
389
303
// Normally fetch only scanLine3 and move forward one row
390
304
// Read scanline 3, fill the last row with nodata values if it's the last iteration
391
305
if ( i == ySize - 1 ) // fill the row below the bottom with nodata values
392
- =======
393
- =======
394
- }
395
- else
396
- {
397
- // normally fetch only scanLine3 and release scanline 1 if we move forward one row
398
- // scanLine1 = scanLine2;
399
- // scanLine2 = scanLine3;
400
- // scanLine3 = ( float * ) CPLMalloc( sizeof( float ) * ( xSize + 2 ) );
401
- scanLine1.reset ( scanLine2.release () );
402
- scanLine2.reset ( scanLine3.release () );
403
- scanLine3.reset ( xSize + 2 );
404
- }
405
- >>>>>>> CPLAllocator smart wrapper
406
-
407
- // Read scanline 3
408
- if ( i == ySize - 1 ) // fill the row below the bottom with nodata values
409
- {
410
- for ( int a = 0 ; a < xSize + 2 ; ++a )
411
- {
412
- scanLine3[a] = mInputNodataValue ;
413
- }
414
- <<<<<<< 7e1d9298000637436eb49d0a886978ad33476894
415
- // Set first and last extra colums to nodata
416
- scanLine1[0 ] = scanLine1[xSize + 1 ] = mInputNodataValue ;
417
- scanLine2[0 ] = scanLine2[xSize + 1 ] = mInputNodataValue ;
418
- scanLine3[0 ] = scanLine3[xSize + 1 ] = mInputNodataValue ;
419
-
420
- errorCode = cl::enqueueWriteBuffer ( scanLine1Buffer, CL_TRUE, 0 ,
421
- sizeof ( float ) * ( xSize + 2 ), scanLine1 );
422
- errorCode = cl::enqueueWriteBuffer ( scanLine2Buffer, CL_TRUE, 0 ,
423
- sizeof ( float ) * ( xSize + 2 ), scanLine2 );
424
- errorCode = cl::enqueueWriteBuffer ( scanLine3Buffer, CL_TRUE, 0 ,
425
- sizeof ( float ) * ( xSize + 2 ), scanLine3 );
426
-
427
- kernel ( cl::EnqueueArgs (
428
- cl::NDRange ( xSize )
429
- ),
430
- scanLine1Buffer,
431
- scanLine2Buffer,
432
- scanLine3Buffer,
433
- resultLineBuffer,
434
- rasterParamsBuffer
435
- );
436
-
437
- cl::enqueueReadBuffer ( resultLineBuffer, CL_TRUE, 0 , xSize * sizeof ( float ), resultLine );
438
-
439
- if ( GDALRasterIO ( outputRasterBand, GF_Write, 0 , i, xSize, 1 , resultLine, xSize, 1 , GDT_Float32, 0 , 0 ) != CE_None )
440
- >>>>>>> Try to avoid crash on intel haswell
441
- =======
442
- }
443
- else
444
- {
445
- if ( GDALRasterIO ( rasterBand, GF_Read, 0 , i + 1 , xSize, 1 , &scanLine3[1 ], xSize, 1 , GDT_Float32, 0 , 0 ) != CE_None )
446
- >>>>>>> CPLAllocator smart wrapper
447
306
{
448
307
for ( int a = 0 ; a < xSize + 2 ; ++a )
449
308
{
450
309
scanLine[a] = mInputNodataValue ;
451
310
}
452
311
queue.enqueueWriteBuffer ( *scanLineBuffer[rowIndex[2 ]], CL_TRUE, 0 , bufferSize, scanLine.get () ); // row 0
453
312
}
454
- <<<<<<< 7e1d9298000637436eb49d0a886978ad33476894
455
313
else // Read line i + 1 and put it into scanline 3
456
314
// Overwrite from input, skip first and last
457
315
{
@@ -461,7 +319,6 @@ int QgsNineCellFilter::processRasterGPU( const QString &source, QgsFeedback *fee
461
319
}
462
320
queue.enqueueWriteBuffer ( *scanLineBuffer[rowIndex[2 ]], CL_TRUE, 0 , bufferSize, scanLine.get () ); // row 0
463
321
}
464
- <<<<<<< 583c7ae28727cddaff53706903980733bd4b8979
465
322
}
466
323
467
324
kernel ( cl::EnqueueArgs (
@@ -482,54 +339,8 @@ int QgsNineCellFilter::processRasterGPU( const QString &source, QgsFeedback *fee
482
339
QgsDebugMsg ( " Raster IO Error" );
483
340
}
484
341
std::rotate ( rowIndex.begin (), rowIndex.begin () + 1 , rowIndex.end () );
485
- =======
486
- =======
487
- }
488
- // Set first and last extra colums to nodata
489
- scanLine1[0 ] = scanLine1[xSize + 1 ] = mInputNodataValue ;
490
- scanLine2[0 ] = scanLine2[xSize + 1 ] = mInputNodataValue ;
491
- scanLine3[0 ] = scanLine3[xSize + 1 ] = mInputNodataValue ;
492
- >>>>>>> CPLAllocator smart wrapper
493
-
494
- errorCode = cl::enqueueWriteBuffer ( scanLine1Buffer, CL_TRUE, 0 ,
495
- sizeof ( float ) * ( xSize + 2 ), scanLine1.get () );
496
- errorCode = cl::enqueueWriteBuffer ( scanLine2Buffer, CL_TRUE, 0 ,
497
- sizeof ( float ) * ( xSize + 2 ), scanLine2.get () );
498
- errorCode = cl::enqueueWriteBuffer ( scanLine3Buffer, CL_TRUE, 0 ,
499
- sizeof ( float ) * ( xSize + 2 ), scanLine3.get () );
500
-
501
- kernel ( cl::EnqueueArgs (
502
- cl::NDRange ( xSize )
503
- ),
504
- scanLine1Buffer,
505
- scanLine2Buffer,
506
- scanLine3Buffer,
507
- resultLineBuffer,
508
- rasterParamsBuffer
509
- );
510
-
511
- cl::enqueueReadBuffer ( resultLineBuffer, CL_TRUE, 0 , xSize * sizeof ( float ), resultLine.get () );
512
-
513
- if ( GDALRasterIO ( outputRasterBand, GF_Write, 0 , i, xSize, 1 , resultLine.get (), xSize, 1 , GDT_Float32, 0 , 0 ) != CE_None )
514
- {
515
- QgsDebugMsg ( " Raster IO Error" );
516
- }
517
- }
518
- <<<<<<< 7e1d9298000637436eb49d0a886978ad33476894
519
- catch ( cl::Error &e )
520
- {
521
- CPLFree ( resultLine );
522
- CPLFree ( scanLine1 );
523
- CPLFree ( scanLine2 );
524
- CPLFree ( scanLine3 );
525
- throw e;
526
- >>>>>>> Try to avoid crash on intel haswell
527
342
}
528
343
529
- =======
530
-
531
-
532
- >>>>>>> CPLAllocator smart wrapper
533
344
if ( feedback && feedback->isCanceled () )
534
345
{
535
346
// delete the dataset without closing (because it is faster)
0 commit comments