1(*******************************************************************************
2 * Copyright (c) 2008-2009 The Khronos Group Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and/or associated documentation files (the
6 * "Materials"), to deal in the Materials without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Materials, and to
9 * permit persons to whom the Materials are furnished to do so, subject to
10 * the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Materials.
14 *
15 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22 ******************************************************************************)
23
24// ported to FPC by Dmitry 'skalogryz' Boyarintsev: 28th apr 2009
25// due to name conflict with type names, some constants have been renamed
26
27// Original C name           Ported_name
28// CL_DEVICE_TYPE            CL_DEVICE_TYPE_INFO
29// CL_DEVICE_LOCAL_MEM_TYPE  CL_DEVICE_LOCAL_MEM_TYPE_INFO
30// CL_CONTEXT_PROPERTIES     CL_CONTEXT_PROPERTIES_INFO
31// CL_CONTEXT_PLATFORM       CL_CONTEXT_PLATFORM_INFO
32// CL_FLOAT                  CL_FLOAT_TYPE
33// CL_MEM_FLAGS              CL_MEM_FLAGS_INFO
34// CL_IMAGE_FORMAT           CL_IMAGE_FORMAT_INFO
35
36unit cl;
37
38interface
39
40uses
41  ctypes;
42
43{$MACRO ON}
44
45{$IFDEF WINDOWS}
46  {$DEFINE DYNLINK}
47const
48  OpenCLlib = 'OpenCL.dll';
49  {$DEFINE extdecl := stdcall}
50{$ELSE}
51  {$IFDEF LINUX}
52  {$DEFINE DYNLINK}
53const
54  OpenCLlib = 'libOpenCL.so';
55  {$DEFINE extdecl := cdecl}
56  {$ENDIF}
57
58  {$IFDEF DARWIN}
59  {$linkframework OpenCL}
60  {$DEFINE extdecl := cdecl}
61  {$ENDIF}
62{$ENDIF}
63
64{cl_platform.h}
65
66const
67  CL_PLATFORM_NVIDIA  = $3001; // NVidia specific platform value
68
69{* scalar types  *}
70
71type
72  intptr_t = PtrInt;
73
74  cl_char     = cint8;
75  cl_uchar    = cuint8;
76  cl_short    = cint16;
77  cl_ushort   = cuint16;
78  cl_int      = cint32;
79  cl_uint     = cuint32;
80  cl_long     = cint64;
81  cl_ulong    = cuint64;
82
83  cl_half     = cuint16;
84  cl_float    = cfloat;
85  cl_double   = cdouble;
86
87  Pcl_char     = ^cl_char;
88  Pcl_uchar    = ^cl_uchar;
89  Pcl_short    = ^cl_short;
90  Pcl_ushort   = ^cl_ushort;
91  Pcl_int      = ^cl_int;
92  Pcl_uint     = ^cl_uint;
93  Pcl_long     = ^cl_long;
94  Pcl_ulong    = ^cl_ulong;
95
96  Pcl_half     = ^cl_half;
97  Pcl_float    = ^cl_float;
98  Pcl_double   = ^cl_double;
99
100
101const
102  CL_CHAR_BIT         = 8;
103  CL_SCHAR_MAX        = 127;
104  CL_SCHAR_MIN        = (-127-1);
105  CL_CHAR_MAX         = CL_SCHAR_MAX;
106  CL_CHAR_MIN         = CL_SCHAR_MIN;
107  CL_UCHAR_MAX        = 255;
108  CL_SHRT_MAX         = 32767;
109  CL_SHRT_MIN         = (-32767-1);
110  CL_USHRT_MAX        = 65535;
111  CL_INT_MAX          = 2147483647;
112  CL_INT_MIN          = (-2147483647-1);
113  CL_UINT_MAX         = $ffffffff;
114  CL_LONG_MAX         = $7FFFFFFFFFFFFFFF;
115  CL_LONG_MIN         = -$7FFFFFFFFFFFFFFF - 1;
116  CL_ULONG_MAX        = $FFFFFFFFFFFFFFFF;
117
118  CL_FLT_DIG          = 6;
119  CL_FLT_MANT_DIG     = 24;
120  CL_FLT_MAX_10_EXP   = +38;
121  CL_FLT_MAX_EXP      = +128;
122  CL_FLT_MIN_10_EXP   = -37;
123  CL_FLT_MIN_EXP      = -125;
124  CL_FLT_RADIX        = 2;
125//  CL_FLT_MAX          = 0x1.fffffep127f;
126//  CL_FLT_MIN          = 0x1.0p-126f;
127//  CL_FLT_EPSILON      = 0x1.0p-23f;
128
129  CL_DBL_DIG          = 15;
130  CL_DBL_MANT_DIG     = 53;
131  CL_DBL_MAX_10_EXP   = +308;
132  CL_DBL_MAX_EXP      = +1024;
133  CL_DBL_MIN_10_EXP   = -307;
134  CL_DBL_MIN_EXP      = -1021;
135  CL_DBL_RADIX        = 2;
136// CL_DBL_MAX          0x1.fffffffffffffp1023
137// CL_DBL_MIN          0x1.0p-1022
138// CL_DBL_EPSILON      0x1.0p-52
139
140{*
141 * Vector types
142 *
143 *  Note:   OpenCL requires that all types be naturally aligned.
144 *          This means that vector types must be naturally aligned.
145 *          For example, a vector of four floats must be aligned to
146 *          a 16 byte boundary (calculated as 4 * the natural 4-byte
147 *          alignment of the float).  The alignment qualifiers here
148 *          will only function properly if your compiler supports them
149 *          and if you don't actively work to defeat them.  For example,
150 *          in order for a cl_float4 to be 16 byte aligned in a struct,
151 *          the start of the struct must itself be 16-byte aligned.
152 *
153 *          Maintaining proper alignment is the user's responsibility.
154 *}
155type
156  cl_char2  = array [0..1] of cint8;
157  cl_char4  = array [0..3] of cint8;
158  cl_char8  = array [0..7] of cint8;
159  cl_char16 = array [0..15] of cint8;
160
161  cl_uchar2 = array [0..1] of cuint8;
162  cl_uchar4 = array [0..3] of cuint8;
163  cl_uchar8 = array [0..7] of cuint8;
164  cl_uchar16 = array [0..15] of cuint8;
165
166  cl_short2  = array [0..1] of cint16;
167  cl_short4  = array [0..3] of cint16;
168  cl_short8  = array [0..7] of cint16;
169  cl_short16 = array [0..15] of cint16;
170
171  cl_ushort2  = array [0..1] of cuint16;
172  cl_ushort4  = array [0..3] of cuint16;
173  cl_ushort8  = array [0..7] of cuint16;
174  cl_ushort16 = array [0..15] of cuint16;
175
176  cl_int2  = array [0..1] of cint32;
177  cl_int4  = array [0..3] of cint32;
178  cl_int8  = array [0..7] of cint32;
179  cl_int16 = array [0..15] of cint32;
180
181  cl_uint2  = array [0..1] of cuint32;
182  cl_uint4  = array [0..3] of cuint32;
183  cl_uint8  = array [0..7] of cuint32;
184  cl_uint16 = array [0..15] of cuint32;
185
186  cl_long2  = array [0..1] of cint64;
187  cl_long4  = array [0..3] of cint64;
188  cl_long8  = array [0..7] of cint64;
189  cl_long16 = array [0..15] of cint64;
190
191  cl_ulong2  = array [0..1] of cuint64;
192  cl_ulong4  = array [0..3] of cuint64;
193  cl_ulong8  = array [0..7] of cuint64;
194  cl_ulong16 = array [0..15] of cuint64;
195
196  cl_float2  = array [0..1] of cfloat;
197  cl_float4  = array [0..3] of cfloat;
198  cl_float8  = array [0..7] of cfloat;
199  cl_float16 = array [0..15] of cfloat;
200
201  cl_double2  = array [0..1] of cdouble;
202  cl_double4  = array [0..3] of cdouble;
203  cl_double8  = array [0..7] of cdouble;
204  cl_double16 = array [0..15] of cdouble;
205
206{* There are no vector types for half *}
207
208// ****************************************************************************
209
210{cl.h}
211
212type
213  _cl_platform_id   = record end;
214  _cl_device_id     = record end;
215  _cl_context       = record end;
216  _cl_command_queue = record end;
217  _cl_mem           = record end;
218  _cl_program       = record end;
219  _cl_kernel        = record end;
220  _cl_event         = record end;
221  _cl_sampler       = record end;
222
223  cl_platform_id    = ^_cl_platform_id;
224  cl_device_id      = ^_cl_device_id;
225  cl_context        = ^_cl_context;
226  cl_command_queue  = ^_cl_command_queue;
227  cl_mem            = ^_cl_mem;
228  cl_program        = ^_cl_program;
229  cl_kernel         = ^_cl_kernel;
230  cl_event          = ^_cl_event;
231  cl_sampler        = ^_cl_sampler;
232
233  Pcl_platform_id    = ^cl_platform_id;
234  Pcl_device_id      = ^cl_device_id;
235  Pcl_context        = ^cl_context;
236  Pcl_command_queue  = ^cl_command_queue;
237  Pcl_mem            = ^cl_mem;
238  Pcl_program        = ^cl_program;
239  Pcl_kernel         = ^cl_kernel;
240  Pcl_event          = ^cl_event;
241  Pcl_sampler        = ^cl_sampler;
242
243
244  cl_bool = cl_uint; //  WARNING!  Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels.
245  cl_bitfield                 = cl_ulong;
246  cl_device_type              = cl_bitfield;
247  cl_platform_info            = cl_uint;
248  cl_device_info              = cl_uint;
249  cl_device_address_info      = cl_bitfield;
250  cl_device_fp_config         = cl_bitfield;
251  cl_device_mem_cache_type    = cl_uint;
252  cl_device_local_mem_type    = cl_uint;
253  cl_device_exec_capabilities = cl_bitfield;
254  cl_command_queue_properties = cl_bitfield;
255
256  cl_context_properties   = intptr_t;
257  cl_context_info         = cl_uint;
258  cl_command_queue_info   = cl_uint;
259  cl_channel_order        = cl_uint;
260  cl_channel_type         = cl_uint;
261  cl_mem_flags            = cl_bitfield;
262  cl_mem_object_type      = cl_uint;
263  cl_mem_info             = cl_uint;
264  cl_image_info           = cl_uint;
265  cl_addressing_mode      = cl_uint;
266  cl_filter_mode          = cl_uint;
267  cl_sampler_info         = cl_uint;
268  cl_map_flags            = cl_bitfield;
269  cl_program_info         = cl_uint;
270  cl_program_build_info   = cl_uint;
271  cl_build_status         = cl_int;
272  cl_kernel_info            = cl_uint;
273  cl_kernel_work_group_info = cl_uint;
274  cl_event_info             = cl_uint;
275  cl_command_type           = cl_uint;
276  cl_profiling_info         = cl_uint;
277
278  _cl_image_format = packed record
279    image_channel_order     : cl_channel_order;
280    image_channel_data_type : cl_channel_type;
281  end;
282  cl_image_format = _cl_image_format;
283
284  Pcl_context_properties  = ^cl_context_properties;
285  Pcl_image_format        = ^cl_image_format;
286
287const
288// Error Codes
289  CL_SUCCESS                                  = 0;
290  CL_DEVICE_NOT_FOUND                         = -1;
291  CL_DEVICE_NOT_AVAILABLE                     = -2;
292  CL_DEVICE_COMPILER_NOT_AVAILABLE            = -3;
293  CL_MEM_OBJECT_ALLOCATION_FAILURE            = -4;
294  CL_OUT_OF_RESOURCES                         = -5;
295  CL_OUT_OF_HOST_MEMORY                       = -6;
296  CL_PROFILING_INFO_NOT_AVAILABLE             = -7;
297  CL_MEM_COPY_OVERLAP                         = -8;
298  CL_IMAGE_FORMAT_MISMATCH                    = -9;
299  CL_IMAGE_FORMAT_NOT_SUPPORTED               = -10;
300  CL_BUILD_PROGRAM_FAILURE                    = -11;
301  CL_MAP_FAILURE                              = -12;
302
303  CL_INVALID_VALUE                            = -30;
304  CL_INVALID_DEVICE_TYPE                      = -31;
305  CL_INVALID_PLATFORM                         = -32;
306  CL_INVALID_DEVICE                           = -33;
307  CL_INVALID_CONTEXT                          = -34;
308  CL_INVALID_QUEUE_PROPERTIES                 = -35;
309  CL_INVALID_COMMAND_QUEUE                    = -36;
310  CL_INVALID_HOST_PTR                         = -37;
311  CL_INVALID_MEM_OBJECT                       = -38;
312  CL_INVALID_IMAGE_FORMAT_DESCRIPTOR          = -39;
313  CL_INVALID_IMAGE_SIZE                       = -40;
314  CL_INVALID_SAMPLER                          = -41;
315  CL_INVALID_BINARY                           = -42;
316  CL_INVALID_BUILD_OPTIONS                    = -43;
317  CL_INVALID_PROGRAM                          = -44;
318  CL_INVALID_PROGRAM_EXECUTABLE               = -45;
319  CL_INVALID_KERNEL_NAME                      = -46;
320  CL_INVALID_KERNEL_DEFINITION                = -47;
321  CL_INVALID_KERNEL                           = -48;
322  CL_INVALID_ARG_INDEX                        = -49;
323  CL_INVALID_ARG_VALUE                        = -50;
324  CL_INVALID_ARG_SIZE                         = -51;
325  CL_INVALID_KERNEL_ARGS                      = -52;
326  CL_INVALID_WORK_DIMENSION                   = -53;
327  CL_INVALID_WORK_GROUP_SIZE                  = -54;
328  CL_INVALID_WORK_ITEM_SIZE                   = -55;
329  CL_INVALID_GLOBAL_OFFSET                    = -56;
330  CL_INVALID_EVENT_WAIT_LIST                  = -57;
331  CL_INVALID_EVENT                            = -58;
332  CL_INVALID_OPERATION                        = -59;
333  CL_INVALID_GL_OBJECT                        = -60;
334  CL_INVALID_BUFFER_SIZE                      = -61;
335  CL_INVALID_MIP_LEVEL                        = -62;
336
337// OpenCL Version
338  CL_VERSION_1_0                              = 1;
339
340// cl_bool
341  CL_FALSE                                    = 0;
342  CL_TRUE                                     = 1;
343
344// cl_platform_info
345  CL_PLATFORM_PROFILE                         = $0900;
346  CL_PLATFORM_VERSION                         = $0901;
347  CL_PLATFORM_NAME                            = $0902;
348  CL_PLATFORM_VENDOR                          = $0903;
349  CL_PLATFORM_EXTENSIONS                      = $0904;
350
351
352// cl_device_type - bitfield
353  CL_DEVICE_TYPE_DEFAULT                      = (1 shl 0);
354  CL_DEVICE_TYPE_CPU                          = (1 shl 1);
355  CL_DEVICE_TYPE_GPU                          = (1 shl 2);
356  CL_DEVICE_TYPE_ACCELERATOR                  = (1 shl 3);
357  CL_DEVICE_TYPE_ALL                          = $FFFFFFFF;
358
359// cl_device_info
360  CL_DEVICE_TYPE_INFO                         = $1000; // CL_DEVICE_TYPE
361  CL_DEVICE_VENDOR_ID                         = $1001;
362  CL_DEVICE_MAX_COMPUTE_UNITS                 = $1002;
363  CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS          = $1003;
364  CL_DEVICE_MAX_WORK_GROUP_SIZE               = $1004;
365  CL_DEVICE_MAX_WORK_ITEM_SIZES               = $1005;
366  CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR       = $1006;
367  CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT      = $1007;
368  CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT        = $1008;
369  CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG       = $1009;
370  CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT      = $100A;
371  CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE     = $100B;
372  CL_DEVICE_MAX_CLOCK_FREQUENCY               = $100C;
373  CL_DEVICE_ADDRESS_BITS                      = $100D;
374  CL_DEVICE_MAX_READ_IMAGE_ARGS               = $100E;
375  CL_DEVICE_MAX_WRITE_IMAGE_ARGS              = $100F;
376  CL_DEVICE_MAX_MEM_ALLOC_SIZE                = $1010;
377  CL_DEVICE_IMAGE2D_MAX_WIDTH                 = $1011;
378  CL_DEVICE_IMAGE2D_MAX_HEIGHT                = $1012;
379  CL_DEVICE_IMAGE3D_MAX_WIDTH                 = $1013;
380  CL_DEVICE_IMAGE3D_MAX_HEIGHT                = $1014;
381  CL_DEVICE_IMAGE3D_MAX_DEPTH                 = $1015;
382  CL_DEVICE_IMAGE_SUPPORT                     = $1016;
383  CL_DEVICE_MAX_PARAMETER_SIZE                = $1017;
384  CL_DEVICE_MAX_SAMPLERS                      = $1018;
385  CL_DEVICE_MEM_BASE_ADDR_ALIGN               = $1019;
386  CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE          = $101A;
387  CL_DEVICE_SINGLE_FP_CONFIG                  = $101B;
388  CL_DEVICE_DOUBLE_FP_CONFIG                  = $1032;
389  CL_DEVICE_GLOBAL_MEM_CACHE_TYPE             = $101C;
390  CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE         = $101D;
391  CL_DEVICE_GLOBAL_MEM_CACHE_SIZE             = $101E;
392  CL_DEVICE_GLOBAL_MEM_SIZE                   = $101F;
393  CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE          = $1020;
394  CL_DEVICE_MAX_CONSTANT_ARGS                 = $1021;
395  CL_DEVICE_LOCAL_MEM_TYPE_INFO               = $1022; // CL_DEVICE_LOCAL_MEM_TYPE
396  CL_DEVICE_LOCAL_MEM_SIZE                    = $1023;
397  CL_DEVICE_ERROR_CORRECTION_SUPPORT          = $1024;
398  CL_DEVICE_PROFILING_TIMER_RESOLUTION        = $1025;
399  CL_DEVICE_ENDIAN_LITTLE                     = $1026;
400  CL_DEVICE_AVAILABLE                         = $1027;
401  CL_DEVICE_COMPILER_AVAILABLE                = $1028;
402  CL_DEVICE_EXECUTION_CAPABILITIES            = $1029;
403  CL_DEVICE_QUEUE_PROPERTIES                  = $102A;
404  CL_DEVICE_NAME                              = $102B;
405  CL_DEVICE_VENDOR                            = $102C;
406  CL_DRIVER_VERSION                           = $102D;
407  CL_DEVICE_PROFILE                           = $102E;
408  CL_DEVICE_VERSION                           = $102F;
409  CL_DEVICE_EXTENSIONS                        = $1030;
410  CL_DEVICE_PLATFORM                          = $1031;
411  CL_DEVICE_OPENCL_C_VERSION                  = $103D;
412
413// cl_device_address_info - bitfield
414  CL_DEVICE_ADDRESS_32_BITS                   = (1 shl 0);
415  CL_DEVICE_ADDRESS_64_BITS                   = (1 shl 1);
416
417// cl_device_fp_config - bitfield
418  CL_FP_DENORM                                = (1 shl 0);
419  CL_FP_INF_NAN                               = (1 shl 1);
420  CL_FP_ROUND_TO_NEAREST                      = (1 shl 2);
421  CL_FP_ROUND_TO_ZERO                         = (1 shl 3);
422  CL_FP_ROUND_TO_INF                          = (1 shl 4);
423  CL_FP_FMA                                   = (1 shl 5);
424
425// cl_device_mem_cache_type
426  CL_NONE                                     = $0;
427  CL_READ_ONLY_CACHE                          = $1;
428  CL_READ_WRITE_CACHE                         = $2;
429
430// cl_device_local_mem_type
431  CL_LOCAL                                    = $1;
432  CL_GLOBAL                                   = $2;
433
434// cl_device_exec_capabilities - bitfield
435  CL_EXEC_KERNEL                              = (1 shl 0);
436  CL_EXEC_NATIVE_KERNEL                       = (1 shl 1);
437
438// cl_command_queue_properties - bitfield
439  CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE      = (1 shl 0);
440  CL_QUEUE_PROFILING_ENABLE                   = (1 shl 1);
441
442// cl_context_info
443  CL_CONTEXT_REFERENCE_COUNT                  = $1080;
444  CL_CONTEXT_DEVICES                          = $1081;
445  CL_CONTEXT_PROPERTIES_INFO                  = $1082; // CL_CONTEXT_PROPERTIES
446  CL_CONTEXT_NUM_DEVICES                      = $1083;
447  CL_CONTEXT_PLATFORM_INFO                    = $1084; // CL_CONTEXT_PLATFORM
448
449// cl_command_queue_info
450  CL_QUEUE_CONTEXT                            = $1090;
451  CL_QUEUE_DEVICE                             = $1091;
452  CL_QUEUE_REFERENCE_COUNT                    = $1092;
453  CL_QUEUE_PROPERTIES                         = $1093;
454
455// cl_mem_flags - bitfield
456  CL_MEM_READ_WRITE                           = (1 shl 0);
457  CL_MEM_WRITE_ONLY                           = (1 shl 1);
458  CL_MEM_READ_ONLY                            = (1 shl 2);
459  CL_MEM_USE_HOST_PTR                         = (1 shl 3);
460  CL_MEM_ALLOC_HOST_PTR                       = (1 shl 4);
461  CL_MEM_COPY_HOST_PTR                        = (1 shl 5);
462
463// cl_channel_order
464  CL_R                                        = $10B0;
465  CL_A                                        = $10B1;
466  CL_RG                                       = $10B2;
467  CL_RA                                       = $10B3;
468  CL_RGB                                      = $10B4;
469  CL_RGBA                                     = $10B5;
470  CL_BGRA                                     = $10B6;
471  CL_ARGB                                     = $10B7;
472  CL_INTENSITY                                = $10B8;
473  CL_LUMINANCE                                = $10B9;
474
475// cl_channel_type
476  CL_SNORM_INT8                               = $10D0;
477  CL_SNORM_INT16                              = $10D1;
478  CL_UNORM_INT8                               = $10D2;
479  CL_UNORM_INT16                              = $10D3;
480  CL_UNORM_SHORT_565                          = $10D4;
481  CL_UNORM_SHORT_555                          = $10D5;
482  CL_UNORM_INT_101010                         = $10D6;
483  CL_SIGNED_INT8                              = $10D7;
484  CL_SIGNED_INT16                             = $10D8;
485  CL_SIGNED_INT32                             = $10D9;
486  CL_UNSIGNED_INT8                            = $10DA;
487  CL_UNSIGNED_INT16                           = $10DB;
488  CL_UNSIGNED_INT32                           = $10DC;
489  CL_HALF_FLOAT                               = $10DD;
490  CL_FLOAT_TYPE                               = $10DE; // CL_FLOAT
491
492// cl_mem_object_type
493  CL_MEM_OBJECT_BUFFER                        = $10F0;
494  CL_MEM_OBJECT_IMAGE2D                       = $10F1;
495  CL_MEM_OBJECT_IMAGE3D                       = $10F2;
496
497// cl_mem_info
498  CL_MEM_TYPE                                 = $1100;
499  CL_MEM_FLAGS_INFO                           = $1101; // CL_MEM_FLAGS
500  CL_MEM_SIZE                                 = $1102;
501  CL_MEM_HOST_PTR                             = $1103;
502  CL_MEM_MAP_COUNT                            = $1104;
503  CL_MEM_REFERENCE_COUNT                      = $1105;
504  CL_MEM_CONTEXT                              = $1106;
505
506// cl_image_info
507  CL_IMAGE_FORMAT_INFO                        = $1110; // CL_IMAGE_FORMAT
508  CL_IMAGE_ELEMENT_SIZE                       = $1111;
509  CL_IMAGE_ROW_PITCH                          = $1112;
510  CL_IMAGE_SLICE_PITCH                        = $1113;
511  CL_IMAGE_WIDTH                              = $1114;
512  CL_IMAGE_HEIGHT                             = $1115;
513  CL_IMAGE_DEPTH                              = $1116;
514
515// cl_addressing_mode
516  CL_ADDRESS_NONE                             = $1130;
517  CL_ADDRESS_CLAMP_TO_EDGE                    = $1131;
518  CL_ADDRESS_CLAMP                            = $1132;
519  CL_ADDRESS_REPEAT                           = $1133;
520
521// cl_filter_mode
522  CL_FILTER_NEAREST                           = $1140;
523  CL_FILTER_LINEAR                            = $1141;
524
525// cl_sampler_info
526  CL_SAMPLER_REFERENCE_COUNT                  = $1150;
527  CL_SAMPLER_CONTEXT                          = $1151;
528  CL_SAMPLER_NORMALIZED_COORDS                = $1152;
529  CL_SAMPLER_ADDRESSING_MODE                  = $1153;
530  CL_SAMPLER_FILTER_MODE                      = $1154;
531
532// cl_map_flags - bitfield
533  CL_MAP_READ                                 = (1 shl 0);
534  CL_MAP_WRITE                                = (1 shl 1);
535
536// cl_program_info
537  CL_PROGRAM_REFERENCE_COUNT                  = $1160;
538  CL_PROGRAM_CONTEXT                          = $1161;
539  CL_PROGRAM_NUM_DEVICES                      = $1162;
540  CL_PROGRAM_DEVICES                          = $1163;
541  CL_PROGRAM_SOURCE                           = $1164;
542  CL_PROGRAM_BINARY_SIZES                     = $1165;
543  CL_PROGRAM_BINARIES                         = $1166;
544
545// cl_program_build_info
546  CL_PROGRAM_BUILD_STATUS                     = $1181;
547  CL_PROGRAM_BUILD_OPTIONS                    = $1182;
548  CL_PROGRAM_BUILD_LOG                        = $1183;
549
550// cl_build_status
551  CL_BUILD_SUCCESS                            = 0;
552  CL_BUILD_NONE                               = -1;
553  CL_BUILD_ERROR                              = -2;
554  CL_BUILD_IN_PROGRESS                        = -3;
555
556// cl_kernel_info
557  CL_KERNEL_FUNCTION_NAME                     = $1190;
558  CL_KERNEL_NUM_ARGS                          = $1191;
559  CL_KERNEL_REFERENCE_COUNT                   = $1192;
560  CL_KERNEL_CONTEXT                           = $1193;
561  CL_KERNEL_PROGRAM                           = $1194;
562
563// cl_kernel_work_group_info
564  CL_KERNEL_WORK_GROUP_SIZE                   = $11B0;
565  CL_KERNEL_COMPILE_WORK_GROUP_SIZE           = $11B1;
566  CL_KERNEL_LOCAL_MEM_SIZE                    = $11B2;
567
568// cl_event_info
569  CL_EVENT_COMMAND_QUEUE                      = $11D0;
570  CL_EVENT_COMMAND_TYPE                       = $11D1;
571  CL_EVENT_REFERENCE_COUNT                    = $11D2;
572  CL_EVENT_COMMAND_EXECUTION_STATUS           = $11D3;
573
574// cl_command_type
575  CL_COMMAND_NDRANGE_KERNEL                   = $11F0;
576  CL_COMMAND_TASK                             = $11F1;
577  CL_COMMAND_NATIVE_KERNEL                    = $11F2;
578  CL_COMMAND_READ_BUFFER                      = $11F3;
579  CL_COMMAND_WRITE_BUFFER                     = $11F4;
580  CL_COMMAND_COPY_BUFFER                      = $11F5;
581  CL_COMMAND_READ_IMAGE                       = $11F6;
582  CL_COMMAND_WRITE_IMAGE                      = $11F7;
583  CL_COMMAND_COPY_IMAGE                       = $11F8;
584  CL_COMMAND_COPY_IMAGE_TO_BUFFER             = $11F9;
585  CL_COMMAND_COPY_BUFFER_TO_IMAGE             = $11FA;
586  CL_COMMAND_MAP_BUFFER                       = $11FB;
587  CL_COMMAND_MAP_IMAGE                        = $11FC;
588  CL_COMMAND_UNMAP_MEM_OBJECT                 = $11FD;
589  CL_COMMAND_MARKER                           = $11FE;
590  CL_COMMAND_WAIT_FOR_EVENTS                  = $11FF;
591  CL_COMMAND_BARRIER                          = $1200;
592  CL_COMMAND_ACQUIRE_GL_OBJECTS               = $1201;
593  CL_COMMAND_RELEASE_GL_OBJECTS               = $1202;
594
595// command execution status
596  CL_COMPLETE                                 = $0;
597  CL_RUNNING                                  = $1;
598  CL_SUBMITTED                                = $2;
599  CL_QUEUED                                   = $3;
600
601// cl_profiling_info
602  CL_PROFILING_COMMAND_QUEUED                 = $1280;
603  CL_PROFILING_COMMAND_SUBMIT                 = $1281;
604  CL_PROFILING_COMMAND_START                  = $1282;
605  CL_PROFILING_COMMAND_END                    = $1283;
606
607// ****************************************************************************
608
609  // Platform APIs
610function clGetPlatformIDs(
611  num_entries   : cl_uint;
612  platforms     : Pcl_platform_id;
613  num_platforms : Pcl_uint
614  ): cl_int; extdecl;
615  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetPlatformIDs';
616
617function clGetPlatformInfo(
618  _platform    : cl_platform_id;
619  param_name   : cl_platform_info;
620  value_size   : csize_t;
621  value        : Pointer;
622  var size_ret : csize_t
623  ): cl_int; extdecl;
624  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetPlatformInfo';
625
626  //  Device APIs
627function clGetDeviceIDs(
628  _platform       : cl_platform_id;
629  device_type     : cl_device_type;
630  num_entries     : cl_uint;
631  devices         : Pcl_device_id;
632  num_devices     : pcl_uint
633  ): cl_int; extdecl;
634  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetDeviceIDs';
635
636function clGetDeviceInfo(
637  device       : cl_device_id;
638  param_name   : cl_device_info;
639  value_size   : csize_t;
640  value        : Pointer;
641  var size_ret : csize_t
642  ): cl_int; extdecl;
643  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetDeviceInfo';
644
645  //  Context APIs
646type
647  TContextNotify = procedure (name: Pchar; data: Pointer; size: csize_t; data2: Pointer); extdecl;
648
649
650function clCreateContext(
651  properties      : Pcl_context_properties;
652  num_devices     : cl_uint;
653  devices         : Pcl_device_id;
654  notify          : TContextNotify;
655  user_data       : Pointer;
656  var errcode_ret : cl_int
657  ): cl_context; extdecl;
658  external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateContext';
659
660function clCreateContextFromType(
661  properties      : Pcl_context_properties;
662  device_type     : cl_device_type;
663  notify          : TContextNotify;
664  user_data       : Pointer;
665  var errcode_ret : cl_int
666  ): cl_context; extdecl;
667  external name 'clCreateContextFromType';
668
669function clRetainContext(context: cl_context): cl_int; extdecl;
670  external {$ifdef DYNLINK}opencllib{$endif} name 'clRetainContext';
671
672function clReleaseContext(context: cl_context): cl_int; extdecl;
673  external {$ifdef DYNLINK}opencllib{$endif} name 'clReleaseContext';
674
675function clGetContextInfo(
676  context       : cl_context;
677  param_name    : cl_context_info;
678  value_size    : csize_t;
679  value         : Pointer;
680  var size_ret  : csize_t
681  ): cl_int; extdecl;
682  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetContextInfo';
683
684  //  Command Queue APIs
685function clCreateCommandQueue(
686  context    : cl_context;
687  device     : cl_device_id;
688  properties : cl_command_queue_properties;
689  errcode_ret: cl_int
690  ): cl_command_queue; extdecl;
691  external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateCommandQueue';
692
693function clRetainCommandQueue(command_queue : cl_command_queue): cl_int; extdecl;
694  external {$ifdef DYNLINK}opencllib{$endif} name 'clRetainCommandQueue';
695
696function clReleaseCommandQueue(command_queue : cl_command_queue): cl_int; extdecl;
697  external {$ifdef DYNLINK}opencllib{$endif} name 'clReleaseCommandQueue';
698
699function clGetCommandQueueInfo(
700  command_queue: cl_command_queue;
701  param_name   : cl_command_queue_info;
702  value_size   : csize_t;
703  value        : Pointer;
704  var size_ret : csize_t
705  ): cl_int; extdecl;
706  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetCommandQueueInfo';
707
708function clSetCommandQueueProperty(
709  command_queue       : cl_command_queue;
710  properties          : cl_command_queue_properties;
711  enable              : cl_bool;
712  var old_properties  : cl_command_queue_properties
713  ): cl_int; extdecl;
714  external {$ifdef DYNLINK}opencllib{$endif} name 'clSetCommandQueueProperty';
715
716  //  Memory Object APIs
717function clCreateBuffer(
718  context          : cl_context;
719  flags            : cl_mem_flags;
720  size             : csize_t;
721  host_ptr         : Pointer;
722  var errcode_ret  : cl_int
723  ): cl_mem; extdecl;
724  external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateBuffer';
725
726function clCreateImage2D(
727  context         : cl_context;
728  flags   	      : cl_mem_flags;
729  image_format    : Pcl_image_format;
730  image_width     : csize_t;
731  image_height    : csize_t;
732  image_row_pitch : csize_t;
733  host_ptr        : Pointer;
734  var errcode_ret : cl_int
735  ): cl_mem; extdecl;
736  external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateImage2D';
737
738function clCreateImage3D(
739  context 			    : cl_context;
740  flags 			      : cl_mem_flags;
741  image_format      : Pcl_image_format;
742  image_width 	    : csize_t;
743  image_height      : csize_t;
744  image_depth 	    : csize_t;
745  image_row_pitch 	: csize_t;
746  image_slice_pitch : csize_t;
747  host_ptr 		      : Pointer;
748  var errcode_ret		: cl_int
749  ): cl_mem; extdecl;
750  external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateImage3D';
751
752function clRetainMemObject(memobj: cl_mem): cl_int; extdecl;
753  external {$ifdef DYNLINK}opencllib{$endif} name 'clRetainMemObject';
754
755function clReleaseMemObject(memobj: cl_mem): cl_int; extdecl;
756  external {$ifdef DYNLINK}opencllib{$endif} name 'clReleaseMemObject';
757
758function clGetSupportedImageFormats(
759  context		    	: cl_context;
760  flags 			    : cl_mem_flags;
761  image_type 		  : cl_mem_object_type;
762  num_entries 		: cl_uint;
763  image_formats   : Pcl_image_format;
764  var num_formats : cl_uint
765  ): cl_int; extdecl;
766  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetSupportedImageFormats';
767
768function clGetMemObjectInfo(
769  memobj      	: cl_mem;
770  param_name    : cl_mem_info;
771  value_size    : csize_t;
772  value     	  : Pointer;
773  var size_ret  : csize_t
774  ): cl_int; extdecl;
775  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetMemObjectInfo';
776
777function clGetImageInfo(
778  image         : cl_mem;
779  param_name    : cl_image_info;
780  value_size    : csize_t;
781  value         : Pointer;
782  var size_ret  : csize_t
783  ): cl_int; extdecl;
784  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetImageInfo';
785
786  //  Sampler APIs
787function clCreateSampler(
788  context         : cl_context;
789  is_norm_coords  : cl_bool;
790  addr_mode       : cl_addressing_mode;
791  filter_mode     : cl_filter_mode;
792  var errcode_ret : cl_int
793  ): cl_sampler; extdecl;
794  external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateSampler';
795
796function clRetainSampler(sampler: cl_sampler): cl_int; extdecl;
797  external {$ifdef DYNLINK}opencllib{$endif} name 'clRetainSampler';
798
799function clReleaseSampler(sampler: cl_sampler): cl_int; extdecl;
800  external {$ifdef DYNLINK}opencllib{$endif} name 'clReleaseSampler';
801
802function clGetSamplerInfo(
803  sampler      : cl_sampler;
804  param_name   : cl_sampler_info;
805  value_size   : csize_t;
806  value        : Pointer;
807  var size_ret : csize_t
808  ): cl_int; extdecl;
809  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetSamplerInfo';
810
811  //  Program Object APIs
812function clCreateProgramWithSource(
813  context         : cl_context;
814  count           : cl_uint;
815  strings         : PPChar;
816  lengths         : Pcsize_t;
817  var errcode_ret : cl_int
818  ): cl_program; extdecl;
819  external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateProgramWithSource';
820
821type
822  PPByte = ^PByte;
823
824function clCreateProgramWithBinary(
825  context     : cl_context;
826  num_devices : cl_uint;
827  device_list : Pcl_device_id;
828  lengths     : Pcsize_t;
829  binaries    : PPByte;
830  var binary_status: cl_int;
831  var errcode_ret: cl_int
832  ): cl_program; extdecl;
833  external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateProgramWithBinary';
834
835function clRetainProgram(_program: cl_program): cl_int; extdecl;
836  external {$ifdef DYNLINK}opencllib{$endif} name 'clRetainProgram';
837
838function clReleaseProgram(_program: cl_program): cl_int; extdecl;
839  external {$ifdef DYNLINK}opencllib{$endif} name 'clReleaseProgram';
840
841type
842  TProgramNotify = procedure (_program: cl_program; user_data: Pointer); extdecl;
843
844//extern   cl_int
845
846function clBuildProgram(
847  _program     : cl_program;
848  num_devices  : cl_uint;
849  device_list  : Pcl_device_id;
850  options      : PChar;
851  notify       : TProgramNotify;
852  user_data    : Pointer
853  ): cl_int; extdecl;
854  external {$ifdef DYNLINK}opencllib{$endif} name 'clBuildProgram';
855
856function clUnloadCompiler: cl_int; extdecl;
857  external {$ifdef DYNLINK}opencllib{$endif} name 'clUnloadCompiler';
858
859function clGetProgramInfo(
860  _program      : cl_program;
861  param_name    : cl_program_info;
862  value_size    : csize_t;
863  value         : Pointer;
864  var size_ret  : csize_t
865  ): cl_int; extdecl;
866  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetProgramInfo';
867
868function clGetProgramBuildInfo(
869  _program      : cl_program;
870  device        : cl_device_id;
871  param_name    : cl_program_build_info;
872  value_size    : csize_t;
873  value         : Pointer;
874  var size_ret  : csize_t
875  ): cl_int; extdecl;
876  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetProgramBuildInfo';
877
878  //  Kernel Object APIs
879function clCreateKernel(
880  _program        : cl_program;
881  kernel_name     : PChar;
882  var errcode_ret : cl_int
883  ): cl_kernel; extdecl;
884  external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateKernel';
885
886function clCreateKernelsInProgram(
887  _program      : cl_program;
888  num_kernels   : cl_uint;
889  kernels       : Pcl_kernel;
890  var num_ret   : cl_uint
891  ): cl_int; extdecl; external name 'clCreateKernelsInProgram';
892
893function clRetainKernel(kernel: cl_kernel): cl_int; extdecl;
894  external {$ifdef DYNLINK}opencllib{$endif} name 'clRetainKernel';
895
896function clReleaseKernel(kernel: cl_kernel): cl_int; extdecl;
897  external {$ifdef DYNLINK}opencllib{$endif} name 'clReleaseKernel';
898
899function clSetKernelArg(
900  kernel    : cl_kernel;
901  arg_index : cl_uint;
902  arg_size  : csize_t;
903  arg_value : Pointer
904  ): cl_int; extdecl;
905  external {$ifdef DYNLINK}opencllib{$endif} name 'clSetKernelArg';
906
907function clGetKernelInfo(
908  kernel        : cl_kernel;
909  param_name    : cl_kernel_info;
910  value_size    : csize_t;
911  value         : Pointer;
912  var size_ret  : csize_t
913  ): cl_int; extdecl;
914  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetKernelInfo';
915
916function clGetKernelWorkGroupInfo(
917  kernel        : cl_kernel;
918  device        : cl_device_id;
919  param_name    : cl_kernel_work_group_info;
920  value_size    : csize_t;
921  value         : Pointer;
922  size_ret      : pcsize_t
923  ): cl_int; extdecl;
924  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetKernelWorkGroupInfo';
925
926  //  Event Object APIs
927function clWaitForEvents(
928  num_events  : cl_uint;
929  event_list  : cl_event
930  ): cl_int; extdecl;
931  external {$ifdef DYNLINK}opencllib{$endif} name 'clWaitForEvents';
932
933function clGetEventInfo(
934  event         : cl_event;
935  param_name    : cl_event_info;
936  value_size    : csize_t;
937  value         : Pointer;
938  var size_ret  : csize_t
939  ): cl_int; extdecl;
940  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetEventInfo';
941
942function clRetainEvent(event: cl_event): cl_int; extdecl;
943  external {$ifdef DYNLINK}opencllib{$endif} name 'clRetainEvent';
944
945function clReleaseEvent(event: cl_event): cl_int; extdecl;
946  external {$ifdef DYNLINK}opencllib{$endif} name 'clReleaseEvent';
947
948  //  Profiling APIs
949function clGetEventProfilingInfo(
950  event         : cl_event;
951  param_name    : cl_profiling_info;
952  value_size    : csize_t;
953  value         : Pointer;
954  var size_ret  : csize_t
955  ): cl_int; extdecl;
956  external {$ifdef DYNLINK}opencllib{$endif} name 'clGetEventProfilingInfo';
957
958  //  Flush and Finish APIs
959function clFlush(command_queue: cl_command_queue): cl_int; extdecl;
960  external  {$ifdef DYNLINK}opencllib{$endif} name 'clFlush';
961
962function clFinish(command_queue: cl_command_queue): cl_int; extdecl;
963  external {$ifdef DYNLINK}opencllib{$endif} name 'clFinish';
964
965  //  Enqueued Commands APIs
966function clEnqueueReadBuffer(
967  command_queue : cl_command_queue;
968  buffer        : cl_mem;
969  blocking_read : cl_bool;
970  offset        : csize_t;
971  cb            : csize_t;
972  ptr           : Pointer;
973  num_events    : cl_uint;
974  events_list   : Pcl_event;
975  event         : Pcl_event
976  ): cl_int; extdecl;
977  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueReadBuffer';
978
979function clEnqueueWriteBuffer(
980  command_queue   : cl_command_queue;
981  buffer          : cl_mem;
982  blocking_write  : cl_bool;
983  offset          : csize_t;
984  cb              : csize_t;
985  ptr             : Pointer;
986  num_events      : cl_uint;
987  events_list     : Pcl_event;
988  event           : Pcl_event
989  ): cl_int; extdecl;
990  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueWriteBuffer';
991
992function clEnqueueCopyBuffer(
993  command_queue : cl_command_queue;
994  src_buffer    : cl_mem;
995  dst_buffer    : cl_mem;
996  src_offset    : csize_t;
997  dst_offset    : csize_t;
998  cb            : csize_t;
999  num_events    : cl_uint;
1000  events_list   : Pcl_event;
1001  event         : Pcl_event
1002  ): cl_int; extdecl;
1003  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueCopyBuffer';
1004
1005function clEnqueueReadImage(
1006  command_queue : cl_command_queue;
1007  image         : cl_mem;
1008  blocking_read : cl_bool;
1009  origin        : Pcsize_t;
1010  region        : Pcsize_t;
1011  row_pitch     : csize_t;
1012  slice_pitch   : csize_t;
1013  ptr           : Pointer;
1014  num_events    : cl_uint;
1015  events_list   : Pcl_event;
1016  event         : Pcl_event
1017  ): cl_int; extdecl;
1018  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueReadImage';
1019
1020function clEnqueueWriteImage(
1021  command_queue   : cl_command_queue;
1022  image           : cl_mem;
1023  blocking_write  : cl_bool;
1024  origin          : Pcsize_t;
1025  region          : Pcsize_t;
1026  row_pitch       : csize_t;
1027  slice_pitch     : csize_t;
1028  ptr             : Pointer;
1029  num_events      : cl_uint;
1030  events_list     : Pcl_event;
1031  event           : Pcl_event
1032  ): cl_int; extdecl;
1033  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueWriteImage';
1034
1035function clEnqueueCopyImage(
1036  command_queue : cl_command_queue;
1037  src_image     : cl_mem;
1038  dst_image     : cl_mem;
1039  src_origin    : Pcsize_t;
1040  dst_origin    : Pcsize_t;
1041  region        : Pcsize_t;
1042  num_events    : cl_uint;
1043  events_list   : Pcl_event;
1044  event         : Pcl_event
1045  ): cl_int; extdecl;
1046  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueCopyImage';
1047
1048function clEnqueueCopyImageToBuffer(
1049  command_queue : cl_command_queue;
1050  src_image     : cl_mem;
1051  dst_buffre    : cl_mem;
1052  src_origin    : Pcsize_t;
1053  region        : Pcsize_t;
1054  dst_offset    : csize_t;
1055  num_events    : cl_uint;
1056  events_list   : Pcl_event;
1057  event         : Pcl_event
1058  ): cl_int; extdecl;
1059  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueCopyImageToBuffer';
1060
1061function clEnqueueCopyBufferToImage(
1062  command_queue : cl_command_queue;
1063  src_buffer    : cl_mem;
1064  dst_image     : cl_mem;
1065  src_offset    : csize_t;
1066  dst_origin    : Pcsize_t;
1067  region        : Pcsize_t;
1068  num_events    : cl_uint;
1069  events_list   : Pcl_event;
1070  event         : Pcl_event
1071  ): cl_int; extdecl;
1072  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueCopyBufferToImage';
1073
1074function clEnqueueMapBuffer(
1075  command_queue   : cl_command_queue;
1076  buffer          : cl_mem;
1077  blocking_map    : cl_bool;
1078  map_flags       : cl_map_flags;
1079  offset          : csize_t;
1080  cb              : csize_t;
1081  num_events      : cl_uint;
1082  events_list     : Pcl_event;
1083  event           : Pcl_event;
1084  var errcode_ret : cl_int
1085  ): Pointer; extdecl;
1086  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueMapBuffer';
1087
1088function clEnqueueMapImage(
1089  command_queue   : cl_command_queue;
1090  image           : cl_mem;
1091  blocking_map    : cl_bool;
1092  map_flags       : cl_map_flags;
1093  origin          : Pcsize_t;
1094  region          : Pcsize_t;
1095  row_pitch       : csize_t;
1096  slice_pitch     : csize_t;
1097  num_events      : cl_uint;
1098  events_list     : Pcl_event;
1099  event           : Pcl_event;
1100  var errcode_ret : cl_int
1101  ): Pointer; extdecl;
1102  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueMapImage';
1103
1104function clEnqueueUnmapMemObject(
1105  command_queue : cl_command_queue;
1106  memobj        : cl_mem;
1107  mapped_ptr    : Pointer;
1108  num_events    : cl_uint;
1109  events_list   : Pcl_event;
1110  event         : Pcl_event
1111  ): cl_int; extdecl;
1112  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueUnmapMemObject';
1113
1114function clEnqueueNDRangeKernel(
1115  command_queue : cl_command_queue;
1116  kernel        : cl_kernel;
1117  work_dim      : cl_uint;
1118  global_offset,
1119  global_size,
1120  local_size    : Pcsize_t;
1121  num_events    : cl_uint;
1122  events_list   : Pcl_event;
1123  event         : Pcl_event
1124  ): cl_int; extdecl;
1125  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueNDRangeKernel';
1126
1127function clEnqueueTask(
1128  command_queue : cl_command_queue;
1129  kernel        : cl_kernel;
1130  num_events    : cl_uint;
1131  events_list   : Pcl_event;
1132  event         : Pcl_event
1133  ): cl_int; extdecl;
1134  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueTask';
1135
1136type
1137  TEnqueueUserProc = procedure (userdata: Pointer); extdecl;
1138
1139function clEnqueueNativeKernel(
1140  command_queue   : cl_command_queue;
1141  user_func       : TEnqueueUserProc;
1142  args            : Pointer;
1143  cb_args         : csize_t;
1144  num_mem_objects : cl_uint;
1145  mem_list        : Pcl_mem;
1146  args_mem_loc    : PPointer;
1147  num_events      : cl_uint;
1148  event_wait_list : Pcl_event;
1149  event           : Pcl_event
1150  ): cl_int; extdecl;
1151  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueNativeKernel';
1152
1153function clEnqueueMarker(command_queue: cl_command_queue; event: Pcl_event
1154  ): cl_int; extdecl;
1155  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueMarker';
1156
1157function clEnqueueWaitForEvents(command_queue: cl_command_queue;
1158  num_events: cl_uint; event_list: Pcl_event
1159  ): cl_int; extdecl;
1160  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueWaitForEvents';
1161
1162function clEnqueueBarrier(command_queue: cl_command_queue
1163  ): cl_int; extdecl;
1164  external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueBarrier';
1165
1166function clErrorText(err:cl_int):string;
1167
1168implementation
1169
1170function clErrorText(err:cl_int):string;
1171begin
1172  case err of
1173    CL_DEVICE_NOT_FOUND : clErrorText:='CL_DEVICE_NOT_FOUND';
1174    CL_DEVICE_NOT_AVAILABLE : clErrorText:='CL_DEVICE_NOT_AVAILABLE';
1175    CL_DEVICE_COMPILER_NOT_AVAILABLE : clErrorText:='CL_DEVICE_COMPILER_NOT_AVAILABLE';
1176    CL_MEM_OBJECT_ALLOCATION_FAILURE : clErrorText:='CL_MEM_OBJECT_ALLOCATION_FAILURE';
1177    CL_OUT_OF_RESOURCES : clErrorText:='CL_OUT_OF_RESOURCES';
1178    CL_OUT_OF_HOST_MEMORY : clErrorText:='CL_OUT_OF_HOST_MEMORY';
1179    CL_PROFILING_INFO_NOT_AVAILABLE : clErrorText:='CL_PROFILING_INFO_NOT_AVAILABLE';
1180    CL_MEM_COPY_OVERLAP : clErrorText:='CL_MEM_COPY_OVERLAP';
1181    CL_IMAGE_FORMAT_MISMATCH : clErrorText:='CL_IMAGE_FORMAT_MISMATCH';
1182    CL_IMAGE_FORMAT_NOT_SUPPORTED : clErrorText:='CL_IMAGE_FORMAT_NOT_SUPPORTED';
1183    CL_BUILD_PROGRAM_FAILURE : clErrorText:='CL_BUILD_PROGRAM_FAILURE';
1184    CL_MAP_FAILURE : clErrorText:='CL_MAP_FAILURE';
1185
1186    CL_INVALID_VALUE : clErrorText:='CL_INVALID_VALUE';
1187    CL_INVALID_DEVICE_TYPE : clErrorText:='CL_INVALID_DEVICE_TYPE';
1188    CL_INVALID_PLATFORM : clErrorText:='CL_INVALID_PLATFORM';
1189    CL_INVALID_DEVICE : clErrorText:='CL_INVALID_DEVICE';
1190    CL_INVALID_CONTEXT : clErrorText:='CL_INVALID_CONTEXT';
1191    CL_INVALID_QUEUE_PROPERTIES : clErrorText:='CL_INVALID_QUEUE_PROPERTIES';
1192    CL_INVALID_COMMAND_QUEUE : clErrorText:='CL_INVALID_COMMAND_QUEUE';
1193    CL_INVALID_HOST_PTR : clErrorText:='CL_INVALID_HOST_PTR';
1194    CL_INVALID_MEM_OBJECT : clErrorText:='CL_INVALID_MEM_OBJECT';
1195    CL_INVALID_IMAGE_FORMAT_DESCRIPTOR : clErrorText:='CL_INVALID_IMAGE_FORMAT_DESCRIPTOR';
1196    CL_INVALID_IMAGE_SIZE : clErrorText:='CL_INVALID_IMAGE_SIZE';
1197    CL_INVALID_SAMPLER : clErrorText:='CL_INVALID_SAMPLER';
1198    CL_INVALID_BINARY : clErrorText:='CL_INVALID_BINARY';
1199    CL_INVALID_BUILD_OPTIONS : clErrorText:='CL_INVALID_BUILD_OPTIONS';
1200    CL_INVALID_PROGRAM : clErrorText:='CL_INVALID_PROGRAM';
1201    CL_INVALID_PROGRAM_EXECUTABLE : clErrorText:='CL_INVALID_PROGRAM_EXECUTABLE';
1202    CL_INVALID_KERNEL_NAME : clErrorText:='CL_INVALID_KERNEL_NAME';
1203    CL_INVALID_KERNEL_DEFINITION : clErrorText:='CL_INVALID_KERNEL_DEFINITION';
1204    CL_INVALID_KERNEL : clErrorText:='CL_INVALID_KERNEL';
1205    CL_INVALID_ARG_INDEX : clErrorText:='CL_INVALID_ARG_INDEX';
1206    CL_INVALID_ARG_VALUE : clErrorText:='CL_INVALID_ARG_VALUE';
1207    CL_INVALID_ARG_SIZE : clErrorText:='CL_INVALID_ARG_SIZE';
1208    CL_INVALID_KERNEL_ARGS : clErrorText:='CL_INVALID_KERNEL_ARGS';
1209    CL_INVALID_WORK_DIMENSION : clErrorText:='CL_INVALID_WORK_DIMENSION';
1210    CL_INVALID_WORK_GROUP_SIZE : clErrorText:='CL_INVALID_WORK_GROUP_SIZE';
1211    CL_INVALID_WORK_ITEM_SIZE : clErrorText:='CL_INVALID_WORK_ITEM_SIZE';
1212    CL_INVALID_GLOBAL_OFFSET : clErrorText:='CL_INVALID_GLOBAL_OFFSET';
1213    CL_INVALID_EVENT_WAIT_LIST : clErrorText:='CL_INVALID_EVENT_WAIT_LIST';
1214    CL_INVALID_EVENT : clErrorText:='CL_INVALID_EVENT';
1215    CL_INVALID_OPERATION : clErrorText:='CL_INVALID_OPERATION';
1216    CL_INVALID_GL_OBJECT : clErrorText:='CL_INVALID_GL_OBJECT';
1217    CL_INVALID_BUFFER_SIZE : clErrorText:='CL_INVALID_BUFFER_SIZE';
1218    CL_INVALID_MIP_LEVEL : clErrorText:='CL_INVALID_MIP_LEVEL';
1219  else
1220     clErrorText:='Unknown OpenCL error';
1221  end;
1222end;
1223
1224end.
1225