Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
data/kernels/common.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2012 Michal Babej.
4 Copyright (C) 2013, 2016 Ulrich Pegelow.
5 Copyright (C) 2020-2022 Aurélien PIERRE.
6 Copyright (C) 2020 Pascal Obry.
7 Copyright (C) 2021 David Koller.
8
9 darktable is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 darktable is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with darktable. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#pragma once
24
25constant sampler_t sampleri = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
26
27constant sampler_t samplerf = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_LINEAR;
28
29constant sampler_t samplerc = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;
30
31// sampler for when the bound checks are already done manually
32constant sampler_t samplerA = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_NONE | CLK_FILTER_NEAREST;
33
34
35#ifndef M_PI_F
36#define M_PI_F 3.14159265358979323846 // should be defined by the OpenCL compiler acc. to standard
37#endif
38
39#define ICLAMP(a, mn, mx) ((a) < (mn) ? (mn) : ((a) > (mx) ? (mx) : (a)))
40#define RED 0
41#define GREEN 1
42#define BLUE 2
43#define ALPHA 3
44
45
46static inline int
47FC(const int row, const int col, const unsigned int filters)
48{
49 return filters >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3;
50}
51
52
53static inline int
54FCxtrans(const int row, const int col, global const unsigned char (*const xtrans)[6])
55{
56 return xtrans[row % 6][col % 6];
57}
58
59
60// Allow the compiler to convert a * b + c to fused multiply-add to use hardware acceleration
61// on compatible platforms
62#pragma OPENCL FP_CONTRACT ON
static const int row
Definition colorspaces_inline_conversions.h:175
constant sampler_t sampleri
Definition data/kernels/common.h:25
constant sampler_t samplerf
Definition data/kernels/common.h:27
constant sampler_t samplerA
Definition data/kernels/common.h:32
constant sampler_t samplerc
Definition data/kernels/common.h:29
static int FCxtrans(const int row, const int col, global const unsigned char(*const xtrans)[6])
Definition data/kernels/common.h:54
static int FC(const int row, const int col, const unsigned int filters)
Definition data/kernels/common.h:47