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