gdalwarpkernel_opencl.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /******************************************************************************
  2. * $Id: gdalwarpkernel_opencl.h 25068 2012-10-07 14:01:47Z 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. #if defined(HAVE_OPENCL)
  30. /* The following relates to the profiling calls to
  31. clSetCommandQueueProperty() which are not available by default
  32. with some OpenCL implementation (ie. ATI) */
  33. #if defined(DEBUG_OPENCL) && DEBUG_OPENCL == 1
  34. #define CL_USE_DEPRECATED_OPENCL_1_0_APIS
  35. #endif
  36. #ifdef __APPLE__
  37. #include <OpenCL/OpenCL.h>
  38. #else
  39. #include <CL/opencl.h>
  40. #endif
  41. #ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
  42. extern "C" {
  43. #endif
  44. typedef enum {
  45. OCL_Bilinear=10,
  46. OCL_Cubic=11,
  47. OCL_CubicSpline=12,
  48. OCL_Lanczos=13
  49. } OCLResampAlg;
  50. typedef enum
  51. {
  52. VENDOR_OTHER,
  53. VENDOR_AMD,
  54. VENDOR_INTEL
  55. } OCLVendor;
  56. struct oclWarper {
  57. cl_command_queue queue;
  58. cl_context context;
  59. cl_device_id dev;
  60. cl_kernel kern1;
  61. cl_kernel kern4;
  62. int srcWidth;
  63. int srcHeight;
  64. int dstWidth;
  65. int dstHeight;
  66. int useUnifiedSrcDensity;
  67. int useUnifiedSrcValid;
  68. int useDstDensity;
  69. int useDstValid;
  70. int numBands;
  71. int numImages;
  72. OCLResampAlg resampAlg;
  73. cl_channel_type imageFormat;
  74. cl_mem *realWorkCL;
  75. union {
  76. void **v;
  77. char **c;
  78. unsigned char **uc;
  79. short **s;
  80. unsigned short **us;
  81. float **f;
  82. } realWork;
  83. cl_mem *imagWorkCL;
  84. union {
  85. void **v;
  86. char **c;
  87. unsigned char **uc;
  88. short **s;
  89. unsigned short **us;
  90. float **f;
  91. } imagWork;
  92. cl_mem *dstRealWorkCL;
  93. union {
  94. void **v;
  95. char **c;
  96. unsigned char **uc;
  97. short **s;
  98. unsigned short **us;
  99. float **f;
  100. } dstRealWork;
  101. cl_mem *dstImagWorkCL;
  102. union {
  103. void **v;
  104. char **c;
  105. unsigned char **uc;
  106. short **s;
  107. unsigned short **us;
  108. float **f;
  109. } dstImagWork;
  110. unsigned int imgChSize1;
  111. cl_channel_order imgChOrder1;
  112. unsigned int imgChSize4;
  113. cl_channel_order imgChOrder4;
  114. char useVec;
  115. cl_mem useBandSrcValidCL;
  116. char *useBandSrcValid;
  117. cl_mem nBandSrcValidCL;
  118. float *nBandSrcValid;
  119. cl_mem xyWorkCL;
  120. float *xyWork;
  121. int xyWidth;
  122. int xyHeight;
  123. int coordMult;
  124. unsigned int xyChSize;
  125. cl_channel_order xyChOrder;
  126. cl_mem fDstNoDataRealCL;
  127. float *fDstNoDataReal;
  128. OCLVendor eCLVendor;
  129. };
  130. struct oclWarper* GDALWarpKernelOpenCL_createEnv(int srcWidth, int srcHeight,
  131. int dstWidth, int dstHeight,
  132. cl_channel_type imageFormat,
  133. int numBands, int coordMult,
  134. int useImag, int useBandSrcValid,
  135. float *fDstDensity,
  136. double *dfDstNoDataReal,
  137. OCLResampAlg resampAlg, cl_int *envErr);
  138. cl_int GDALWarpKernelOpenCL_setSrcValid(struct oclWarper *warper,
  139. int *bandSrcValid, int bandNum);
  140. cl_int GDALWarpKernelOpenCL_setSrcImg(struct oclWarper *warper, void *imgData,
  141. int bandNum);
  142. cl_int GDALWarpKernelOpenCL_setDstImg(struct oclWarper *warper, void *imgData,
  143. int bandNum);
  144. cl_int GDALWarpKernelOpenCL_setCoordRow(struct oclWarper *warper,
  145. double *rowSrcX, double *rowSrcY,
  146. double srcXOff, double srcYOff,
  147. int *success, int rowNum);
  148. cl_int GDALWarpKernelOpenCL_runResamp(struct oclWarper *warper,
  149. float *unifiedSrcDensity,
  150. unsigned int *unifiedSrcValid,
  151. float *dstDensity,
  152. unsigned int *dstValid,
  153. double dfXScale, double dfYScale,
  154. double dfXFilter, double dfYFilter,
  155. int nXRadius, int nYRadius,
  156. int nFiltInitX, int nFiltInitY);
  157. cl_int GDALWarpKernelOpenCL_getRow(struct oclWarper *warper,
  158. void **rowReal, void **rowImag,
  159. int rowNum, int bandNum);
  160. cl_int GDALWarpKernelOpenCL_deleteEnv(struct oclWarper *warper);
  161. #ifdef __cplusplus /* If this is a C++ compiler, end C linkage */
  162. }
  163. #endif
  164. #endif /* defined(HAVE_OPENCL) */