GDAL
gdalwarpkernel_opencl.h
00001 /******************************************************************************
00002  * $Id: gdalwarpkernel_opencl.h 25068 2012-10-07 14:01:47Z 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 #if defined(DEBUG_OPENCL) && DEBUG_OPENCL == 1
00037 #define CL_USE_DEPRECATED_OPENCL_1_0_APIS
00038 #endif
00039 
00040 #ifdef __APPLE__
00041 #include <OpenCL/OpenCL.h>
00042 #else
00043 #include <CL/opencl.h>
00044 #endif
00045 
00046 #ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
00047 extern "C" {
00048 #endif
00049 
00050 typedef enum {
00051     OCL_Bilinear=10,
00052     OCL_Cubic=11,
00053     OCL_CubicSpline=12,
00054     OCL_Lanczos=13
00055 } OCLResampAlg;
00056 
00057 typedef enum
00058 {
00059     VENDOR_OTHER,
00060     VENDOR_AMD,
00061     VENDOR_INTEL
00062 } OCLVendor;
00063 
00064 struct oclWarper {
00065     cl_command_queue queue;
00066     cl_context context;
00067     cl_device_id dev;
00068     cl_kernel kern1;
00069     cl_kernel kern4;
00070     
00071     int srcWidth;
00072     int srcHeight;
00073     int dstWidth;
00074     int dstHeight;
00075     
00076     int useUnifiedSrcDensity;
00077     int useUnifiedSrcValid;
00078     int useDstDensity;
00079     int useDstValid;
00080     
00081     int numBands;
00082     int numImages;
00083     OCLResampAlg resampAlg;
00084     
00085     cl_channel_type imageFormat;
00086     cl_mem *realWorkCL;
00087     union {
00088         void **v;
00089         char **c;
00090         unsigned char **uc;
00091         short **s;
00092         unsigned short **us;
00093         float **f;
00094     } realWork;
00095     
00096     cl_mem *imagWorkCL;
00097     union {
00098         void **v;
00099         char **c;
00100         unsigned char **uc;
00101         short **s;
00102         unsigned short **us;
00103         float **f;
00104     } imagWork;
00105     
00106     cl_mem *dstRealWorkCL;
00107     union {
00108         void **v;
00109         char **c;
00110         unsigned char **uc;
00111         short **s;
00112         unsigned short **us;
00113         float **f;
00114     } dstRealWork;
00115     
00116     cl_mem *dstImagWorkCL;
00117     union {
00118         void **v;
00119         char **c;
00120         unsigned char **uc;
00121         short **s;
00122         unsigned short **us;
00123         float **f;
00124     } dstImagWork;
00125     
00126     unsigned int imgChSize1;
00127     cl_channel_order imgChOrder1;
00128     unsigned int imgChSize4;
00129     cl_channel_order imgChOrder4;
00130         char    useVec;
00131     
00132     cl_mem useBandSrcValidCL;
00133     char *useBandSrcValid;
00134     
00135     cl_mem nBandSrcValidCL;
00136     float *nBandSrcValid;
00137     
00138     cl_mem xyWorkCL;
00139     float *xyWork;
00140     
00141     int xyWidth;
00142     int xyHeight;
00143     int coordMult;
00144     
00145     unsigned int xyChSize;
00146     cl_channel_order xyChOrder;
00147     
00148     cl_mem fDstNoDataRealCL;
00149     float *fDstNoDataReal;
00150 
00151     OCLVendor eCLVendor;
00152 };
00153 
00154 struct oclWarper* GDALWarpKernelOpenCL_createEnv(int srcWidth, int srcHeight,
00155                                                  int dstWidth, int dstHeight,
00156                                                  cl_channel_type imageFormat,
00157                                                  int numBands, int coordMult,
00158                                                  int useImag, int useBandSrcValid,
00159                                                  float *fDstDensity,
00160                                                  double *dfDstNoDataReal,
00161                                                  OCLResampAlg resampAlg, cl_int *envErr);
00162 
00163 cl_int GDALWarpKernelOpenCL_setSrcValid(struct oclWarper *warper,
00164                                         int *bandSrcValid, int bandNum);
00165 
00166 cl_int GDALWarpKernelOpenCL_setSrcImg(struct oclWarper *warper, void *imgData,
00167                                       int bandNum);
00168 
00169 cl_int GDALWarpKernelOpenCL_setDstImg(struct oclWarper *warper, void *imgData,
00170                                       int bandNum);
00171 
00172 cl_int GDALWarpKernelOpenCL_setCoordRow(struct oclWarper *warper,
00173                                         double *rowSrcX, double *rowSrcY,
00174                                         double srcXOff, double srcYOff,
00175                                         int *success, int rowNum);
00176 
00177 cl_int GDALWarpKernelOpenCL_runResamp(struct oclWarper *warper,
00178                                       float *unifiedSrcDensity,
00179                                       unsigned int *unifiedSrcValid,
00180                                       float *dstDensity,
00181                                       unsigned int *dstValid,
00182                                       double dfXScale, double dfYScale,
00183                                       double dfXFilter, double dfYFilter,
00184                                       int nXRadius, int nYRadius,
00185                                       int nFiltInitX, int nFiltInitY);
00186 
00187 cl_int GDALWarpKernelOpenCL_getRow(struct oclWarper *warper,
00188                                    void **rowReal, void **rowImag,
00189                                    int rowNum, int bandNum);
00190 
00191 cl_int GDALWarpKernelOpenCL_deleteEnv(struct oclWarper *warper);
00192 
00193 #ifdef __cplusplus /* If this is a C++ compiler, end C linkage */
00194 }
00195 #endif
00196 
00197 #endif /* defined(HAVE_OPENCL) */
00198 

Generated for GDAL by doxygen 1.7.6.1.