Skip to content

Commit 7df59c6

Browse files
committed
Merge branch 'opencl_vng_demosaicer'
* opencl_vng_demosaicer: VNG4 green correction for only_linear mode Some minimal VNG OpenCL performance improvement Fix misleading OpenCL oversize buffer log
2 parents c967d76 + a12eea9 commit 7df59c6

File tree

4 files changed

+111
-95
lines changed

4 files changed

+111
-95
lines changed

data/kernels/demosaic_vng.cl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2016-2025 darktable developers.
3+
Copyright (C) 2016-2026 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -19,6 +19,8 @@
1919
#include "common.h"
2020

2121
kernel void
22+
#define AVGWINDOW 1
23+
2224
vng_border_interpolate(read_only image2d_t in,
2325
write_only image2d_t out,
2426
const int width,
@@ -33,21 +35,20 @@ vng_border_interpolate(read_only image2d_t in,
3335
if(x >= width || y >= height) return;
3436

3537
const int colors = (filters == 9) ? 3 : 4;
36-
const int avgwindow = 1;
3738

3839
if(x >= border && x < width-border && y >= border && y < height-border) return;
3940

4041
float o[4] = { 0.0f };
4142
float sum[4] = { 0.0f };
4243
int count[4] = { 0 };
4344

44-
for(int j = y-avgwindow; j <= y+avgwindow; j++)
45-
for(int i = x-avgwindow; i <= x+avgwindow; i++)
45+
for(int j = y-AVGWINDOW; j <= y+AVGWINDOW; j++)
46+
for(int i = x-AVGWINDOW; i <= x+AVGWINDOW; i++)
4647
{
4748
if(j >= 0 && i >= 0 && j < height && i < width)
4849
{
4950
const int f = fcol(j, i, filters, xtrans);
50-
sum[f] += fmax(0.0f, read_imagef(in, sampleri, (int2)(i, j)).x);
51+
sum[f] += fmax(0.0f, read_imagef(in, samplerA, (int2)(i, j)).x);
5152
count[f]++;
5253
}
5354
}
@@ -118,7 +119,7 @@ vng_lin_interpolate(read_only image2d_t in, write_only image2d_t out, const int
118119
float o[4] = { 0.0f };
119120

120121
global const int *ip = lookup[y % size][x % size];
121-
int num_pixels = ip[0];
122+
const int num_pixels = ip[0];
122123
ip++;
123124

124125
// for each adjoining pixel not of this pixel's color, sum up its weighted values
@@ -239,7 +240,7 @@ vng_interpolate(read_only image2d_t in, write_only image2d_t out, const int widt
239240
return;
240241
}
241242

242-
float thold = gmin + (gmax * 0.5f);
243+
const float thold = gmin + (gmax * 0.5f);
243244
float sum[4] = { 0.0f };
244245
const int color = fcol(y, x, filters, xtrans);
245246
int num = 0;
@@ -298,7 +299,7 @@ vng_green_equilibrate(read_only image2d_t in, write_only image2d_t out, const in
298299

299300
if(x >= width || y >= height) return;
300301

301-
float4 pixel = read_imagef(in, sampleri, (int2)(x , y));
302+
float4 pixel = read_imagef(in, samplerA, (int2)(x , y));
302303

303304
pixel.y = (pixel.y + pixel.w) / 2.0f;
304305
pixel.w = 0.0f;

src/common/opencl.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2010-2025 darktable developers.
3+
Copyright (C) 2010-2026 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -3152,12 +3152,16 @@ void *dt_opencl_copy_host_to_device_constant(const int devid,
31523152
cl_mem dev = (darktable.opencl->dlocl->symbols->dt_clCreateBuffer)
31533153
(darktable.opencl->dev[devid].context, mode, size, host, &err);
31543154

3155-
if(err != CL_SUCCESS || oversize)
3155+
if(err != CL_SUCCESS)
31563156
dt_print(DT_DEBUG_OPENCL,
31573157
"[opencl copy_host_to_device_constant]"
3158-
" could not allocate %sbuffer on device '%s' id=%d: %s",
3159-
oversize ? "oversize " : "",
3158+
" could not allocate buffer on device '%s' id=%d: %s",
31603159
darktable.opencl->dev[devid].fullname, devid, cl_errstr(err));
3160+
if(oversize)
3161+
dt_print(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE,
3162+
"[opencl copy_host_to_device_constant]"
3163+
" fallback to non-const buffer on device '%s' id=%d",
3164+
darktable.opencl->dev[devid].fullname, devid);
31613165

31623166
dt_opencl_memory_statistics(devid, dev, OPENCL_MEMORY_ADD);
31633167

src/iop/demosaicing/capture.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2025 darktable developers.
3+
Copyright (C) 2026 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -731,7 +731,7 @@ static void _capture_radius(dt_iop_module_t *self,
731731

732732
dt_print_pipe(DT_DEBUG_PIPE, filters != 9u ? "bayer autoradius" : "xtrans autoradius",
733733
pipe, self, DT_DEVICE_NONE, NULL, NULL,
734-
"%sradius=%.2f from %s image data is %s reliable",
734+
"%sradius=%.2f from %s image data is %sreliable",
735735
same_radius ? "unchanged" : "", radius,
736736
enough ? "enough" : "small",
737737
reliable ? "" : "not ");

0 commit comments

Comments
 (0)