GDAL

gdalwarpkernel_opencl.h

00001 /******************************************************************************
00002  * $Id: gdalwarpkernel_opencl.h 21223 2010-12-08 20:40:33Z rouault $
00003  *
00004  * Project:  OpenCL Image Reprojector
00005  * Purpose:  Implementation of the GDALWarpKernel reprojector in OpenCL.
00006  * Author:   Seth Price, seth@pricepages.org
00007  *
00008  ******************************************************************************
00009  * Copyright (c) 2010, Seth Price <seth@pricepages.org>
00010  *
00011  * Permission is hereby granted, free of charge, to any person obtaining a
00012  * copy of this software and associated documentation files (the "Software"),
00013  * to deal in the Software without restriction, including without limitation
00014  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00015  * and/or sell copies of the Software, and to permit persons to whom the
00016  * Software is furnished to do so, subject to the following conditions:
00017  *
00018  * The above copyright notice and this permission notice shall be included
00019  * in all copies or substantial portions of the Software.
00020  *
00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00022  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00023  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00024  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00025  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00026  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00027  * DEALINGS IN THE SOFTWARE.
00028  ****************************************************************************/
00029 
00030 #if defined(HAVE_OPENCL)
00031 
00032 /* The following relates to the profiling calls to 
00033    clSetCommandQueueProperty() which are not available by default
00034    with some OpenCL implementation (ie. ATI) */
00035 
00036 #define CL_USE_DEPRECATED_OPENCL_1_0_APIS
00037 
00038 #ifdef __APPLE__
00039 #include <OpenCL/OpenCL.h>
00040 #else
00041 #include <CL/opencl.h>
00042 #endif
00043 
00044 #ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
00045 extern "C" {
00046 #endif
00047 
00048 typedef enum {
00049     OCL_Bilinear=10,
00050     OCL_Cubic=11,
00051     OCL_CubicSpline=12,
00052     OCL_Lanczos=13
00053 } OCLResampAlg;
00054     
00055 struct oclWarper {
00056     cl_command_queue queue;
00057     cl_context context;
00058     cl_device_id dev;
00059     cl_kernel kern1;
00060     cl_kernel kern4;
00061     
00062     int srcWidth;
00063     int srcHeight;
00064     int dstWidth;
00065     int dstHeight;
00066     
00067     int useUnifiedSrcDensity;
00068     int useUnifiedSrcValid;
00069     int useDstDensity;
00070     int useDstValid;
00071     
00072     int numBands;
00073     int numImages;
00074     OCLResampAlg resampAlg;
00075     
00076     cl_channel_type imageFormat;
00077     cl_mem *realWorkCL;
00078     union {
00079         void **v;
00080         char **c;
00081         unsigned char **uc;
00082         short **s;
00083         unsigned short **us;
00084         float **f;
00085     } realWork;
00086     
00087     cl_mem *imagWorkCL;
00088     union {
00089         void **v;
00090         char **c;
00091         unsigned char **uc;
00092         short **s;
00093         unsigned short **us;
00094         float **f;
00095     } imagWork;
00096     
00097     cl_mem *dstRealWorkCL;
00098     union {
00099         void **v;
00100         char **c;
00101         unsigned char **uc;
00102         short **s;
00103         unsigned short **us;
00104         float **f;
00105     } dstRealWork;
00106     
00107     cl_mem *dstImagWorkCL;
00108     union {
00109         void **v;
00110         char **c;
00111         unsigned char **uc;
00112         short **s;
00113         unsigned short **us;
00114         float **f;
00115     } dstImagWork;
00116     
00117     unsigned int imgChSize1;
00118     cl_channel_order imgChOrder1;
00119     unsigned int imgChSize4;
00120     cl_channel_order imgChOrder4;
00121         char    useVec;
00122     
00123     cl_mem useBandSrcValidCL;
00124     char *useBandSrcValid;
00125     
00126     cl_mem nBandSrcValidCL;
00127     float *nBandSrcValid;
00128     
00129     cl_mem xyWorkCL;
00130     float *xyWork;
00131     
00132     int xyWidth;
00133     int xyHeight;
00134     int coordMult;
00135     
00136     unsigned int xyChSize;
00137     cl_channel_order xyChOrder;
00138     
00139     cl_mem fDstNoDataRealCL;
00140     float *fDstNoDataReal;
00141 
00142     int bIsATI;
00143 };
00144 
00145 struct oclWarper* GDALWarpKernelOpenCL_createEnv(int srcWidth, int srcHeight,
00146                                                  int dstWidth, int dstHeight,
00147                                                  cl_channel_type imageFormat,
00148                                                  int numBands, int coordMult,
00149                                                  int useImag, int useBandSrcValid,
00150                                                  float *fDstDensity,
00151                                                  double *dfDstNoDataReal,
00152                                                  OCLResampAlg resampAlg, cl_int *envErr);
00153 
00154 cl_int GDALWarpKernelOpenCL_setSrcValid(struct oclWarper *warper,
00155                                         int *bandSrcValid, int bandNum);
00156 
00157 cl_int GDALWarpKernelOpenCL_setSrcImg(struct oclWarper *warper, void *imgData,
00158                                       int bandNum);
00159 
00160 cl_int GDALWarpKernelOpenCL_setDstImg(struct oclWarper *warper, void *imgData,
00161                                       int bandNum);
00162 
00163 cl_int GDALWarpKernelOpenCL_setCoordRow(struct oclWarper *warper,
00164                                         double *rowSrcX, double *rowSrcY,
00165                                         double srcXOff, double srcYOff,
00166                                         int *success, int rowNum);
00167 
00168 cl_int GDALWarpKernelOpenCL_runResamp(struct oclWarper *warper,
00169                                       float *unifiedSrcDensity,
00170                                       unsigned int *unifiedSrcValid,
00171                                       float *dstDensity,
00172                                       unsigned int *dstValid,
00173                                       double dfXScale, double dfYScale,
00174                                       double dfXFilter, double dfYFilter,
00175                                       int nXRadius, int nYRadius,
00176                                       int nFiltInitX, int nFiltInitY);
00177 
00178 cl_int GDALWarpKernelOpenCL_getRow(struct oclWarper *warper,
00179                                    void **rowReal, void **rowImag,
00180                                    int rowNum, int bandNum);
00181 
00182 cl_int GDALWarpKernelOpenCL_deleteEnv(struct oclWarper *warper);
00183 
00184 #ifdef __cplusplus /* If this is a C++ compiler, end C linkage */
00185 }
00186 #endif
00187 
00188 #endif /* defined(HAVE_OPENCL) */
00189 

Generated for GDAL by doxygen 1.7.3.