GDAL
gdalwarpkernel_opencl.h
1 /******************************************************************************
2  * $Id: gdalwarpkernel_opencl.h 21223 2010-12-08 20:40:33Z rouault $
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  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included
19  * in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  ****************************************************************************/
29 
30 #if defined(HAVE_OPENCL)
31 
32 /* The following relates to the profiling calls to
33  clSetCommandQueueProperty() which are not available by default
34  with some OpenCL implementation (ie. ATI) */
35 
36 #define CL_USE_DEPRECATED_OPENCL_1_0_APIS
37 
38 #ifdef __APPLE__
39 #include <OpenCL/OpenCL.h>
40 #else
41 #include <CL/opencl.h>
42 #endif
43 
44 #ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
45 extern "C" {
46 #endif
47 
48 typedef enum {
49  OCL_Bilinear=10,
50  OCL_Cubic=11,
51  OCL_CubicSpline=12,
52  OCL_Lanczos=13
53 } OCLResampAlg;
54 
55 struct oclWarper {
56  cl_command_queue queue;
57  cl_context context;
58  cl_device_id dev;
59  cl_kernel kern1;
60  cl_kernel kern4;
61 
62  int srcWidth;
63  int srcHeight;
64  int dstWidth;
65  int dstHeight;
66 
67  int useUnifiedSrcDensity;
68  int useUnifiedSrcValid;
69  int useDstDensity;
70  int useDstValid;
71 
72  int numBands;
73  int numImages;
74  OCLResampAlg resampAlg;
75 
76  cl_channel_type imageFormat;
77  cl_mem *realWorkCL;
78  union {
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  union {
89  void **v;
90  char **c;
91  unsigned char **uc;
92  short **s;
93  unsigned short **us;
94  float **f;
95  } imagWork;
96 
97  cl_mem *dstRealWorkCL;
98  union {
99  void **v;
100  char **c;
101  unsigned char **uc;
102  short **s;
103  unsigned short **us;
104  float **f;
105  } dstRealWork;
106 
107  cl_mem *dstImagWorkCL;
108  union {
109  void **v;
110  char **c;
111  unsigned char **uc;
112  short **s;
113  unsigned short **us;
114  float **f;
115  } dstImagWork;
116 
117  unsigned int imgChSize1;
118  cl_channel_order imgChOrder1;
119  unsigned int imgChSize4;
120  cl_channel_order imgChOrder4;
121  char useVec;
122 
123  cl_mem useBandSrcValidCL;
124  char *useBandSrcValid;
125 
126  cl_mem nBandSrcValidCL;
127  float *nBandSrcValid;
128 
129  cl_mem xyWorkCL;
130  float *xyWork;
131 
132  int xyWidth;
133  int xyHeight;
134  int coordMult;
135 
136  unsigned int xyChSize;
137  cl_channel_order xyChOrder;
138 
139  cl_mem fDstNoDataRealCL;
140  float *fDstNoDataReal;
141 
142  int bIsATI;
143 };
144 
145 struct oclWarper* GDALWarpKernelOpenCL_createEnv(int srcWidth, int srcHeight,
146  int dstWidth, int dstHeight,
147  cl_channel_type imageFormat,
148  int numBands, int coordMult,
149  int useImag, int useBandSrcValid,
150  float *fDstDensity,
151  double *dfDstNoDataReal,
152  OCLResampAlg resampAlg, cl_int *envErr);
153 
154 cl_int GDALWarpKernelOpenCL_setSrcValid(struct oclWarper *warper,
155  int *bandSrcValid, int bandNum);
156 
157 cl_int GDALWarpKernelOpenCL_setSrcImg(struct oclWarper *warper, void *imgData,
158  int bandNum);
159 
160 cl_int GDALWarpKernelOpenCL_setDstImg(struct oclWarper *warper, void *imgData,
161  int bandNum);
162 
163 cl_int GDALWarpKernelOpenCL_setCoordRow(struct oclWarper *warper,
164  double *rowSrcX, double *rowSrcY,
165  double srcXOff, double srcYOff,
166  int *success, int rowNum);
167 
168 cl_int GDALWarpKernelOpenCL_runResamp(struct oclWarper *warper,
169  float *unifiedSrcDensity,
170  unsigned int *unifiedSrcValid,
171  float *dstDensity,
172  unsigned int *dstValid,
173  double dfXScale, double dfYScale,
174  double dfXFilter, double dfYFilter,
175  int nXRadius, int nYRadius,
176  int nFiltInitX, int nFiltInitY);
177 
178 cl_int GDALWarpKernelOpenCL_getRow(struct oclWarper *warper,
179  void **rowReal, void **rowImag,
180  int rowNum, int bandNum);
181 
182 cl_int GDALWarpKernelOpenCL_deleteEnv(struct oclWarper *warper);
183 
184 #ifdef __cplusplus /* If this is a C++ compiler, end C linkage */
185 }
186 #endif
187 
188 #endif /* defined(HAVE_OPENCL) */
189 

Generated for GDAL by doxygen 1.8.1.2.