GDAL
gdalwarpkernel_opencl.h
1/******************************************************************************
2 * $Id$
3 *
4 * Project: OpenCL Image Reprojector
5 * Purpose: Implementation of the GDALWarpKernel reprojector in OpenCL.
6 * Author: Seth Price, seth@pricepages.org
7 *
8 ******************************************************************************
9 * Copyright (c) 2010, Seth Price <seth@pricepages.org>
10 *
11 * SPDX-License-Identifier: MIT
12 ****************************************************************************/
13
14#if defined(HAVE_OPENCL)
15
16/* The following relates to the profiling calls to
17 clSetCommandQueueProperty() which are not available by default
18 with some OpenCL implementation (i.e. ATI) */
19
20#if defined(DEBUG_OPENCL) && DEBUG_OPENCL == 1
21#define CL_USE_DEPRECATED_OPENCL_1_0_APIS
22#endif
23
24#define CL_TARGET_OPENCL_VERSION 100
25
26#ifdef __APPLE__
27#include <OpenCL/opencl.h>
28#else
29#include <CL/opencl.h>
30#endif
31
32#ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
33extern "C"
34{
35#endif
36
37 typedef enum
38 {
39 OCL_Bilinear = 10,
40 OCL_Cubic = 11,
41 OCL_CubicSpline = 12,
42 OCL_Lanczos = 13
43 } OCLResampAlg;
44
45 typedef enum
46 {
47 VENDOR_OTHER,
48 VENDOR_AMD,
49 VENDOR_INTEL
50 } OCLVendor;
51
52 struct oclWarper
53 {
54 cl_command_queue queue;
55 cl_context context;
56 cl_device_id dev;
57 cl_kernel kern1;
58 cl_kernel kern4;
59
60 int srcWidth;
61 int srcHeight;
62 int dstWidth;
63 int dstHeight;
64
65 int useUnifiedSrcDensity;
66 int useUnifiedSrcValid;
67 int useDstDensity;
68 int useDstValid;
69
70 int numBands;
71 int numImages;
72 OCLResampAlg resampAlg;
73
74 cl_channel_type imageFormat;
75 cl_mem *realWorkCL;
76
77 union
78 {
79 void **v;
80 char **c;
81 unsigned char **uc;
82 short **s;
83 unsigned short **us;
84 float **f;
85 } realWork;
86
87 cl_mem *imagWorkCL;
88
89 union
90 {
91 void **v;
92 char **c;
93 unsigned char **uc;
94 short **s;
95 unsigned short **us;
96 float **f;
97 } imagWork;
98
99 cl_mem *dstRealWorkCL;
100
101 union
102 {
103 void **v;
104 char **c;
105 unsigned char **uc;
106 short **s;
107 unsigned short **us;
108 float **f;
109 } dstRealWork;
110
111 cl_mem *dstImagWorkCL;
112
113 union
114 {
115 void **v;
116 char **c;
117 unsigned char **uc;
118 short **s;
119 unsigned short **us;
120 float **f;
121 } dstImagWork;
122
123 unsigned int imgChSize1;
124 cl_channel_order imgChOrder1;
125 unsigned int imgChSize4;
126 cl_channel_order imgChOrder4;
127 char useVec;
128
129 cl_mem useBandSrcValidCL;
130 char *useBandSrcValid;
131
132 cl_mem nBandSrcValidCL;
133 float *nBandSrcValid;
134
135 cl_mem xyWorkCL;
136 float *xyWork;
137
138 int xyWidth;
139 int xyHeight;
140 int coordMult;
141
142 unsigned int xyChSize;
143 cl_channel_order xyChOrder;
144
145 cl_mem fDstNoDataRealCL;
146 float *fDstNoDataReal;
147
148 OCLVendor eCLVendor;
149 };
150
151 struct oclWarper *GDALWarpKernelOpenCL_createEnv(
152 int srcWidth, int srcHeight, int dstWidth, int dstHeight,
153 cl_channel_type imageFormat, int numBands, int coordMult, int useImag,
154 int useBandSrcValid, float *fDstDensity, double *dfDstNoDataReal,
155 OCLResampAlg resampAlg, cl_int *envErr);
156
157 cl_int GDALWarpKernelOpenCL_setSrcValid(struct oclWarper *warper,
158 int *bandSrcValid, int bandNum);
159
160 cl_int GDALWarpKernelOpenCL_setSrcImg(struct oclWarper *warper,
161 void *imgData, int bandNum);
162
163 cl_int GDALWarpKernelOpenCL_setDstImg(struct oclWarper *warper,
164 void *imgData, int bandNum);
165
166 cl_int GDALWarpKernelOpenCL_setCoordRow(struct oclWarper *warper,
167 double *rowSrcX, double *rowSrcY,
168 double srcXOff, double srcYOff,
169 int *success, int rowNum);
170
171 cl_int GDALWarpKernelOpenCL_runResamp(
172 struct oclWarper *warper, float *unifiedSrcDensity,
173 unsigned int *unifiedSrcValid, float *dstDensity,
174 unsigned int *dstValid, double dfXScale, double dfYScale,
175 double dfXFilter, double dfYFilter, int nXRadius, int nYRadius,
176 int nFiltInitX, int nFiltInitY);
177
178 cl_int GDALWarpKernelOpenCL_getRow(struct oclWarper *warper, void **rowReal,
179 void **rowImag, int rowNum, int bandNum);
180
181 cl_int GDALWarpKernelOpenCL_deleteEnv(struct oclWarper *warper);
182
183#ifdef __cplusplus /* If this is a C++ compiler, end C linkage */
184}
185#endif
186
187#endif /* defined(HAVE_OPENCL) */