summaryrefslogtreecommitdiff
path: root/backend/src/libocl/include/ocl_image.h
blob: 5a679aa8bd6a574b8e140de4edce2b695e224644 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*
 * Copyright © 2012 - 2014 Intel Corporation
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 *
 */
#ifndef __OCL_IMAGE_H__
#define __OCL_IMAGE_H__

#include "ocl_types.h"

#define int1 int
#define float1 float

#define DECL_IMAGE_READ_SAMPLE_RETTYPE(IMG_TYPE, DATA_YPE, SUFFIX, N) \
  OVERLOADABLE DATA_YPE read_image ## SUFFIX(IMG_TYPE cl_image, const sampler_t sampler, int##N coord); \
  OVERLOADABLE DATA_YPE read_image ## SUFFIX(IMG_TYPE cl_image, const sampler_t sampler, float##N coord);

#define DECL_IMAGE_READ_NO_SAMPLE_RETTYPE(IMG_TYPE, DATA_YPE, SUFFIX, N) \
  OVERLOADABLE DATA_YPE read_image ## SUFFIX(IMG_TYPE cl_image, int##N coord);

#define DECL_IMAGE_WRITE_RETTYPE(IMG_TYPE, DATA_YPE, SUFFIX, N) \
  OVERLOADABLE void write_image ## SUFFIX(IMG_TYPE cl_image, int##N coord, DATA_YPE color);

#define DECL_IMAGE_TYPE_READ_NO_SAMPLE(IMG_TYPE, N)\
    DECL_IMAGE_READ_NO_SAMPLE_RETTYPE(IMG_TYPE, int4, i, N) \
    DECL_IMAGE_READ_NO_SAMPLE_RETTYPE(IMG_TYPE, uint4, ui, N) \
    DECL_IMAGE_READ_NO_SAMPLE_RETTYPE(IMG_TYPE, float4, f, N)

#define DECL_IMAGE_TYPE_READ_SAMPLE(IMG_TYPE, N)\
    DECL_IMAGE_READ_SAMPLE_RETTYPE(IMG_TYPE, int4, i, N) \
    DECL_IMAGE_READ_SAMPLE_RETTYPE(IMG_TYPE, uint4, ui, N) \
    DECL_IMAGE_READ_SAMPLE_RETTYPE(IMG_TYPE, float4, f, N)

#define DECL_IMAGE_TYPE_WRITE(IMG_TYPE, N)\
    DECL_IMAGE_WRITE_RETTYPE(IMG_TYPE, int4, i, N) \
    DECL_IMAGE_WRITE_RETTYPE(IMG_TYPE, uint4, ui, N) \
    DECL_IMAGE_WRITE_RETTYPE(IMG_TYPE, float4, f, N)

#if (__OPENCL_C_VERSION__ >= 200)
#define DECL_IMAGE(IMG_TYPE, N) \
    DECL_IMAGE_TYPE_READ_NO_SAMPLE(read_only IMG_TYPE, N) \
    DECL_IMAGE_TYPE_READ_NO_SAMPLE(read_write IMG_TYPE, N) \
    DECL_IMAGE_TYPE_READ_SAMPLE(read_only IMG_TYPE, N) \
    DECL_IMAGE_TYPE_WRITE(write_only IMG_TYPE, N) \
    DECL_IMAGE_TYPE_WRITE(read_write IMG_TYPE, N)
#else
#define DECL_IMAGE(IMG_TYPE, N) \
    DECL_IMAGE_TYPE_READ_NO_SAMPLE(read_only IMG_TYPE, N) \
    DECL_IMAGE_TYPE_READ_SAMPLE(read_only IMG_TYPE, N) \
    DECL_IMAGE_TYPE_WRITE(write_only IMG_TYPE, N)
#endif

DECL_IMAGE(image1d_t, 1)
DECL_IMAGE(image2d_t, 2)
DECL_IMAGE(image1d_array_t, 2)
DECL_IMAGE(image3d_t, 3)
DECL_IMAGE(image3d_t, 4)
DECL_IMAGE(image2d_array_t, 3)
DECL_IMAGE(image2d_array_t, 4)

#undef DECL_IMAGE

#if (__OPENCL_C_VERSION__ >= 200)
#define DECL_IMAGE(IMG_TYPE, N) \
    DECL_IMAGE_TYPE_READ_NO_SAMPLE(read_only IMG_TYPE, N) \
    DECL_IMAGE_TYPE_READ_NO_SAMPLE(read_write IMG_TYPE, N) \
    DECL_IMAGE_TYPE_WRITE(write_only IMG_TYPE, N) \
    DECL_IMAGE_TYPE_WRITE(read_write IMG_TYPE, N)
#else
#define DECL_IMAGE(IMG_TYPE, N) \
    DECL_IMAGE_TYPE_READ_NO_SAMPLE(read_only IMG_TYPE, N) \
    DECL_IMAGE_TYPE_WRITE(write_only IMG_TYPE, N)
#endif

DECL_IMAGE(image1d_buffer_t, 1)

#undef int1
#undef float1
#undef DECL_IMAGE_TYPE_READ_NO_SAMPLE
#undef DECL_IMAGE_TYPE_WRITE
#undef DECL_IMAGE

OVERLOADABLE int get_image_channel_data_type(read_only image1d_t image);
OVERLOADABLE int get_image_channel_order(read_only image1d_t image);
OVERLOADABLE int get_image_width(read_only image1d_t image);

OVERLOADABLE int get_image_channel_data_type(read_only image1d_buffer_t image);
OVERLOADABLE int get_image_channel_order(read_only image1d_buffer_t image);
OVERLOADABLE int get_image_width(read_only image1d_buffer_t image);

OVERLOADABLE int get_image_channel_data_type(read_only image2d_t image);
OVERLOADABLE int get_image_channel_order(read_only image2d_t image);
OVERLOADABLE int get_image_width(read_only image2d_t image);
OVERLOADABLE int get_image_height(read_only image2d_t image);
OVERLOADABLE int2 get_image_dim(read_only image2d_t image);

OVERLOADABLE int get_image_channel_data_type(read_only image1d_array_t image);
OVERLOADABLE int get_image_channel_order(read_only image1d_array_t image);
OVERLOADABLE int get_image_width(read_only image1d_array_t image);
OVERLOADABLE size_t get_image_array_size(read_only image1d_array_t image);

OVERLOADABLE int get_image_channel_data_type(read_only image3d_t image);
OVERLOADABLE int get_image_channel_order(read_only image3d_t image);
OVERLOADABLE int get_image_width(read_only image3d_t image);
OVERLOADABLE int get_image_height(read_only image3d_t image);
OVERLOADABLE int get_image_depth(read_only image3d_t image);
OVERLOADABLE int4 get_image_dim(read_only image3d_t image);

OVERLOADABLE int get_image_channel_data_type(read_only image2d_array_t image);
OVERLOADABLE int get_image_channel_order(read_only image2d_array_t image);
OVERLOADABLE int get_image_width(read_only image2d_array_t image);
OVERLOADABLE int get_image_height(read_only image2d_array_t image);
OVERLOADABLE int2 get_image_dim(read_only image2d_array_t image);
OVERLOADABLE size_t get_image_array_size(read_only image2d_array_t image);

#if __clang_major__*10 + __clang_minor__ >= 39
OVERLOADABLE int get_image_channel_data_type(write_only image1d_t image);
OVERLOADABLE int get_image_channel_order(write_only image1d_t image);
OVERLOADABLE int get_image_width(write_only image1d_t image);

OVERLOADABLE int get_image_channel_data_type(write_only image1d_buffer_t image);
OVERLOADABLE int get_image_channel_order(write_only image1d_buffer_t image);
OVERLOADABLE int get_image_width(write_only image1d_buffer_t image);

OVERLOADABLE int get_image_channel_data_type(write_only image2d_t image);
OVERLOADABLE int get_image_channel_order(write_only image2d_t image);
OVERLOADABLE int get_image_width(write_only image2d_t image);
OVERLOADABLE int get_image_height(write_only image2d_t image);
OVERLOADABLE int2 get_image_dim(write_only image2d_t image);

OVERLOADABLE int get_image_channel_data_type(write_only image1d_array_t image);
OVERLOADABLE int get_image_channel_order(write_only image1d_array_t image);
OVERLOADABLE int get_image_width(write_only image1d_array_t image);
OVERLOADABLE size_t get_image_array_size(write_only image1d_array_t image);

OVERLOADABLE int get_image_channel_data_type(write_only image3d_t image);
OVERLOADABLE int get_image_channel_order(write_only image3d_t image);
OVERLOADABLE int get_image_width(write_only image3d_t image);
OVERLOADABLE int get_image_height(write_only image3d_t image);
OVERLOADABLE int get_image_depth(write_only image3d_t image);
OVERLOADABLE int4 get_image_dim(write_only image3d_t image);

OVERLOADABLE int get_image_channel_data_type(write_only image2d_array_t image);
OVERLOADABLE int get_image_channel_order(write_only image2d_array_t image);
OVERLOADABLE int get_image_width(write_only image2d_array_t image);
OVERLOADABLE int get_image_height(write_only image2d_array_t image);
OVERLOADABLE int2 get_image_dim(write_only image2d_array_t image);
OVERLOADABLE size_t get_image_array_size(write_only image2d_array_t image);
#endif

#if (__OPENCL_C_VERSION__ >= 200)
OVERLOADABLE int get_image_channel_data_type(read_write image1d_t image);
OVERLOADABLE int get_image_channel_order(read_write image1d_t image);
OVERLOADABLE int get_image_width(read_write image1d_t image);

OVERLOADABLE int get_image_channel_data_type(read_write image1d_buffer_t image);
OVERLOADABLE int get_image_channel_order(read_write image1d_buffer_t image);
OVERLOADABLE int get_image_width(read_write image1d_buffer_t image);

OVERLOADABLE int get_image_channel_data_type(read_write image2d_t image);
OVERLOADABLE int get_image_channel_order(read_write image2d_t image);
OVERLOADABLE int get_image_width(read_write image2d_t image);
OVERLOADABLE int get_image_height(read_write image2d_t image);
OVERLOADABLE int2 get_image_dim(read_write image2d_t image);

OVERLOADABLE int get_image_channel_data_type(read_write image1d_array_t image);
OVERLOADABLE int get_image_channel_order(read_write image1d_array_t image);
OVERLOADABLE int get_image_width(read_write image1d_array_t image);
OVERLOADABLE size_t get_image_array_size(read_write image1d_array_t image);

OVERLOADABLE int get_image_channel_data_type(read_write image3d_t image);
OVERLOADABLE int get_image_channel_order(read_write image3d_t image);
OVERLOADABLE int get_image_width(read_write image3d_t image);
OVERLOADABLE int get_image_height(read_write image3d_t image);
OVERLOADABLE int get_image_depth(read_write image3d_t image);
OVERLOADABLE int4 get_image_dim(read_write image3d_t image);

OVERLOADABLE int get_image_channel_data_type(read_write image2d_array_t image);
OVERLOADABLE int get_image_channel_order(read_write image2d_array_t image);
OVERLOADABLE int get_image_width(read_write image2d_array_t image);
OVERLOADABLE int get_image_height(read_write image2d_array_t image);
OVERLOADABLE int2 get_image_dim(read_write image2d_array_t image);
OVERLOADABLE size_t get_image_array_size(read_write image2d_array_t image);
#endif

#endif