Skip to content

Raster calculator fails when OpenCL acceleration is turned on #64574

Description

@simonreise

What is the bug or the crash?

I wanted to create yearly binary rasters for Global Forest Change dataset

I used if ("Hansen_GFC-2024-v1.12_lossyear_70N_080E_mosaic@1" = 1, 1, 0) expression in raster calculator

However, it just failed with message "could not create destination file"

When I tried to investigate further, I noticed that the actual error appears in OpenCL console and says:

2026-01-17T12:10:33     CRITICAL    Error building OpenCL program: <kernel>:16:94: error: used type 'float' where floating point type is not allowed
              resultLine[i] = ( ( float ) ( ( float ) input_raster_0_band_1[i] == ( float ) 1 ) ) ? ( ( float ) 1 ) : ( ( float ) 0 ) ;
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^

When I tried to run the same expression with acceleration turned off, everything worked nice

Even if it can not be fixed, probably a more user-friendly error message should be shown

Steps to reproduce the issue

  1. Enable OpenCL acceleration
  2. Download any Global Forest Change data (or probably any other data)
  3. Try to execute something like if ("Hansen_GFC-2024-v1.12_lossyear_70N_080E_mosaic@1" = 1, 1, 0) in a raster calculator

Versions

QGIS version3.44.7-Solothurn
QGIS code revisionea262bc5ed8
 
Libraries
Qt version5.15.13
Python version3.12.12
GDAL version3.12.1 — Chicoutimi
PROJ version9.7.1
EPSG Registry database versionv12.029 (2025-10-03)
GEOS version3.14.1-CAPI-1.20.5
SQLite version3.50.4
PDAL version2.9.0
PostgreSQL client version17.3
SpatiaLite version5.1.0
QWT version6.3.0
QScintilla2 version2.14.1
OS versionWindows 11 Version 2009
 
Active Python plugins
LAStools2.3.2
mmqgis2024.11.8
orfeoToolbox_provider3.0.3
OSMDownloader1.0.4
processing_saga_nextgen1.1.0
qfieldsyncv4.18.0
qgis2web3.31.0
qtiles1.8.0
quick_map_services1.1.0
db_manager0.1.20
grassprovider2.12.99
MetaSearch0.3.6
processing2.12.99

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

Metadata

Metadata

Assignees

Labels

BugEither a bug report, or a bug fix. Let's hope for the latter!RastersRelated to general raster layer handling (not specific data formats)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions