2 // Copyright 2013 Francisco Jerez
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 // OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef API_DISPATCH_HPP
24 #define API_DISPATCH_HPP
26 #define CL_USE_DEPRECATED_OPENCL_1_1_APIS
29 #include "CL/cl_ext.h"
33 /// OpenCL ICD vendor dispatch table.
35 /// The entry point ordering should always be in agreement with
36 /// Khronos' ICD loader.
38 struct _cl_icd_dispatch {
39 CL_API_ENTRY cl_int (CL_API_CALL *clGetPlatformIDs)(
41 cl_platform_id *platforms,
42 cl_uint *num_platforms);
44 CL_API_ENTRY cl_int (CL_API_CALL *clGetPlatformInfo)(
45 cl_platform_id platform,
46 cl_platform_info param_name,
47 size_t param_value_size,
49 size_t *param_value_size_ret);
51 CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDs)(
52 cl_platform_id platform,
53 cl_device_type device_type,
55 cl_device_id *devices,
56 cl_uint *num_devices);
58 CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceInfo)(
60 cl_device_info param_name,
61 size_t param_value_size,
63 size_t *param_value_size_ret);
65 CL_API_ENTRY cl_context (CL_API_CALL *clCreateContext)(
66 const cl_context_properties *properties,
68 const cl_device_id *devices,
69 void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *),
73 CL_API_ENTRY cl_context (CL_API_CALL *clCreateContextFromType)(
74 const cl_context_properties *properties,
75 cl_device_type device_type,
76 void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *),
80 CL_API_ENTRY cl_int (CL_API_CALL *clRetainContext)(
83 CL_API_ENTRY cl_int (CL_API_CALL *clReleaseContext)(
86 CL_API_ENTRY cl_int (CL_API_CALL *clGetContextInfo)(
88 cl_context_info param_name,
89 size_t param_value_size,
91 size_t *param_value_size_ret);
93 CL_API_ENTRY cl_command_queue (CL_API_CALL *clCreateCommandQueue)(
96 cl_command_queue_properties properties,
99 CL_API_ENTRY cl_int (CL_API_CALL *clRetainCommandQueue)(
100 cl_command_queue command_queue);
102 CL_API_ENTRY cl_int (CL_API_CALL *clReleaseCommandQueue)(
103 cl_command_queue command_queue);
105 CL_API_ENTRY cl_int (CL_API_CALL *clGetCommandQueueInfo)(
106 cl_command_queue command_queue,
107 cl_command_queue_info param_name,
108 size_t param_value_size,
110 size_t *param_value_size_ret);
112 CL_API_ENTRY cl_int (CL_API_CALL *clSetCommandQueueProperty)(
113 cl_command_queue command_queue,
114 cl_command_queue_properties properties,
116 cl_command_queue_properties *old_properties);
118 CL_API_ENTRY cl_mem (CL_API_CALL *clCreateBuffer)(
123 cl_int *errcode_ret);
125 CL_API_ENTRY cl_mem (CL_API_CALL *clCreateImage2D)(
128 const cl_image_format *image_format,
131 size_t image_row_pitch,
133 cl_int *errcode_ret);
135 CL_API_ENTRY cl_mem (CL_API_CALL *clCreateImage3D)(
138 const cl_image_format *image_format,
142 size_t image_row_pitch,
143 size_t image_slice_pitch,
145 cl_int *errcode_ret);
147 CL_API_ENTRY cl_int (CL_API_CALL *clRetainMemObject)(
150 CL_API_ENTRY cl_int (CL_API_CALL *clReleaseMemObject)(
153 CL_API_ENTRY cl_int (CL_API_CALL *clGetSupportedImageFormats)(
156 cl_mem_object_type image_type,
158 cl_image_format *image_formats,
159 cl_uint *num_image_formats);
161 CL_API_ENTRY cl_int (CL_API_CALL *clGetMemObjectInfo)(
163 cl_mem_info param_name,
164 size_t param_value_size,
166 size_t *param_value_size_ret);
168 CL_API_ENTRY cl_int (CL_API_CALL *clGetImageInfo)(
170 cl_image_info param_name,
171 size_t param_value_size,
173 size_t *param_value_size_ret);
175 CL_API_ENTRY cl_sampler (CL_API_CALL *clCreateSampler)(
177 cl_bool normalized_coords,
178 cl_addressing_mode addressing_mode,
179 cl_filter_mode filter_mode,
180 cl_int *errcode_ret);
182 CL_API_ENTRY cl_int (CL_API_CALL *clRetainSampler)(
185 CL_API_ENTRY cl_int (CL_API_CALL *clReleaseSampler)(
188 CL_API_ENTRY cl_int (CL_API_CALL *clGetSamplerInfo)(
190 cl_sampler_info param_name,
191 size_t param_value_size,
193 size_t *param_value_size_ret);
195 CL_API_ENTRY cl_program (CL_API_CALL *clCreateProgramWithSource)(
198 const char **strings,
199 const size_t *lengths,
200 cl_int *errcode_ret);
202 CL_API_ENTRY cl_program (CL_API_CALL *clCreateProgramWithBinary)(
205 const cl_device_id *device_list,
206 const size_t *lengths,
207 const unsigned char **binaries,
208 cl_int *binary_status,
209 cl_int *errcode_ret);
211 CL_API_ENTRY cl_int (CL_API_CALL *clRetainProgram)(
214 CL_API_ENTRY cl_int (CL_API_CALL *clReleaseProgram)(
217 CL_API_ENTRY cl_int (CL_API_CALL *clBuildProgram)(
220 const cl_device_id *device_list,
222 void (CL_CALLBACK *pfn_notify)(cl_program, void *),
225 CL_API_ENTRY cl_int (CL_API_CALL *clUnloadCompiler)(
228 CL_API_ENTRY cl_int (CL_API_CALL *clGetProgramInfo)(
230 cl_program_info param_name,
231 size_t param_value_size,
233 size_t *param_value_size_ret);
235 CL_API_ENTRY cl_int (CL_API_CALL *clGetProgramBuildInfo)(
238 cl_program_build_info param_name,
239 size_t param_value_size,
241 size_t *param_value_size_ret);
243 CL_API_ENTRY cl_kernel (CL_API_CALL *clCreateKernel)(
245 const char *kernel_name,
246 cl_int *errcode_ret);
248 CL_API_ENTRY cl_int (CL_API_CALL *clCreateKernelsInProgram)(
252 cl_uint *num_kernels_ret);
254 CL_API_ENTRY cl_int (CL_API_CALL *clRetainKernel)(
257 CL_API_ENTRY cl_int (CL_API_CALL *clReleaseKernel)(
260 CL_API_ENTRY cl_int (CL_API_CALL *clSetKernelArg)(
264 const void *arg_value);
266 CL_API_ENTRY cl_int (CL_API_CALL *clGetKernelInfo)(
268 cl_kernel_info param_name,
269 size_t param_value_size,
271 size_t *param_value_size_ret);
273 CL_API_ENTRY cl_int (CL_API_CALL *clGetKernelWorkGroupInfo)(
276 cl_kernel_work_group_info param_name,
277 size_t param_value_size,
279 size_t *param_value_size_ret);
281 CL_API_ENTRY cl_int (CL_API_CALL *clWaitForEvents)(
283 const cl_event *event_list);
285 CL_API_ENTRY cl_int (CL_API_CALL *clGetEventInfo)(
287 cl_event_info param_name,
288 size_t param_value_size,
290 size_t *param_value_size_ret);
292 CL_API_ENTRY cl_int (CL_API_CALL *clRetainEvent)(
295 CL_API_ENTRY cl_int (CL_API_CALL *clReleaseEvent)(
298 CL_API_ENTRY cl_int (CL_API_CALL *clGetEventProfilingInfo)(
300 cl_profiling_info param_name,
301 size_t param_value_size,
303 size_t *param_value_size_ret);
305 CL_API_ENTRY cl_int (CL_API_CALL *clFlush)(
306 cl_command_queue command_queue);
308 CL_API_ENTRY cl_int (CL_API_CALL *clFinish)(
309 cl_command_queue command_queue);
311 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReadBuffer)(
312 cl_command_queue command_queue,
314 cl_bool blocking_read,
318 cl_uint num_events_in_wait_list,
319 const cl_event *event_wait_list,
322 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueWriteBuffer)(
323 cl_command_queue command_queue,
325 cl_bool blocking_write,
329 cl_uint num_events_in_wait_list,
330 const cl_event *event_wait_list,
333 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueCopyBuffer)(
334 cl_command_queue command_queue,
340 cl_uint num_events_in_wait_list,
341 const cl_event *event_wait_list,
344 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReadImage)(
345 cl_command_queue command_queue,
347 cl_bool blocking_read,
348 const size_t *origin,
349 const size_t *region,
353 cl_uint num_events_in_wait_list,
354 const cl_event *event_wait_list,
357 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueWriteImage)(
358 cl_command_queue command_queue,
360 cl_bool blocking_write,
361 const size_t *origin,
362 const size_t *region,
363 size_t input_row_pitch,
364 size_t input_slice_pitch,
366 cl_uint num_events_in_wait_list,
367 const cl_event *event_wait_list,
370 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueCopyImage)(
371 cl_command_queue command_queue,
374 const size_t *src_origin,
375 const size_t *dst_origin,
376 const size_t *region,
377 cl_uint num_events_in_wait_list,
378 const cl_event *event_wait_list,
381 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueCopyImageToBuffer)(
382 cl_command_queue command_queue,
385 const size_t *src_origin,
386 const size_t *region,
388 cl_uint num_events_in_wait_list,
389 const cl_event *event_wait_list,
392 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueCopyBufferToImage)(
393 cl_command_queue command_queue,
397 const size_t *dst_origin,
398 const size_t *region,
399 cl_uint num_events_in_wait_list,
400 const cl_event *event_wait_list,
403 CL_API_ENTRY void *(CL_API_CALL *clEnqueueMapBuffer)(
404 cl_command_queue command_queue,
406 cl_bool blocking_map,
407 cl_map_flags map_flags,
410 cl_uint num_events_in_wait_list,
411 const cl_event *event_wait_list,
413 cl_int *errcode_ret);
415 CL_API_ENTRY void *(CL_API_CALL *clEnqueueMapImage)(
416 cl_command_queue command_queue,
418 cl_bool blocking_map,
419 cl_map_flags map_flags,
420 const size_t *origin,
421 const size_t *region,
422 size_t *image_row_pitch,
423 size_t *image_slice_pitch,
424 cl_uint num_events_in_wait_list,
425 const cl_event *event_wait_list,
427 cl_int *errcode_ret);
429 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueUnmapMemObject)(
430 cl_command_queue command_queue,
433 cl_uint num_events_in_wait_list,
434 const cl_event *event_wait_list,
437 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueNDRangeKernel)(
438 cl_command_queue command_queue,
441 const size_t *global_work_offset,
442 const size_t *global_work_size,
443 const size_t *local_work_size,
444 cl_uint num_events_in_wait_list,
445 const cl_event *event_wait_list,
448 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueTask)(
449 cl_command_queue command_queue,
451 cl_uint num_events_in_wait_list,
452 const cl_event *event_wait_list,
455 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueNativeKernel)(
456 cl_command_queue command_queue,
457 void (CL_CALLBACK *user_func)(void *),
460 cl_uint num_mem_objects,
461 const cl_mem *mem_list,
462 const void **args_mem_loc,
463 cl_uint num_events_in_wait_list,
464 const cl_event *event_wait_list,
467 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueMarker)(
468 cl_command_queue command_queue,
471 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueWaitForEvents)(
472 cl_command_queue command_queue,
474 const cl_event *event_list);
476 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueBarrier)(
477 cl_command_queue command_queue);
479 CL_API_ENTRY void *(CL_API_CALL *clGetExtensionFunctionAddress)(
480 const char *function_name);
482 CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromGLBuffer)(
488 CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromGLTexture2D)(
494 cl_int *errcode_ret);
496 CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromGLTexture3D)(
502 cl_int *errcode_ret);
504 CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromGLRenderbuffer)(
507 cl_GLuint renderbuffer,
508 cl_int *errcode_ret);
510 CL_API_ENTRY cl_int (CL_API_CALL *clGetGLObjectInfo)(
512 cl_gl_object_type *gl_object_type,
513 cl_GLuint *gl_object_name);
515 CL_API_ENTRY cl_int (CL_API_CALL *clGetGLTextureInfo)(
517 cl_gl_texture_info param_name,
518 size_t param_value_size,
520 size_t *param_value_size_ret);
522 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireGLObjects)(
523 cl_command_queue command_queue,
525 const cl_mem *mem_objects,
526 cl_uint num_events_in_wait_list,
527 const cl_event *event_wait_list,
530 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseGLObjects)(
531 cl_command_queue command_queue,
533 const cl_mem *mem_objects,
534 cl_uint num_events_in_wait_list,
535 const cl_event *event_wait_list,
538 CL_API_ENTRY cl_int (CL_API_CALL *clGetGLContextInfoKHR)(
539 const cl_context_properties *properties,
540 cl_gl_context_info param_name,
541 size_t param_value_size,
543 size_t *param_value_size_ret);
545 void *clGetDeviceIDsFromD3D10KHR;
546 void *clCreateFromD3D10BufferKHR;
547 void *clCreateFromD3D10Texture2DKHR;
548 void *clCreateFromD3D10Texture3DKHR;
549 void *clEnqueueAcquireD3D10ObjectsKHR;
550 void *clEnqueueReleaseD3D10ObjectsKHR;
552 CL_API_ENTRY cl_int (CL_API_CALL *clSetEventCallback)(
555 void (CL_CALLBACK *pfn_notify)(cl_event, cl_int, void *),
558 CL_API_ENTRY cl_mem (CL_API_CALL *clCreateSubBuffer)(
561 cl_buffer_create_type buffer_create_type,
562 const void *buffer_create_info,
563 cl_int *errcode_ret);
565 CL_API_ENTRY cl_int (CL_API_CALL *clSetMemObjectDestructorCallback)(
567 void (CL_CALLBACK *pfn_notify)(cl_mem, void *),
570 CL_API_ENTRY cl_event (CL_API_CALL *clCreateUserEvent)(
572 cl_int *errcode_ret);
574 CL_API_ENTRY cl_int (CL_API_CALL *clSetUserEventStatus)(
578 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReadBufferRect)(
579 cl_command_queue command_queue,
581 cl_bool blocking_read,
582 const size_t *buffer_origin,
583 const size_t *host_origin,
584 const size_t *region,
585 size_t buffer_row_pitch,
586 size_t buffer_slice_pitch,
587 size_t host_row_pitch,
588 size_t host_slice_pitch,
590 cl_uint num_events_in_wait_list,
591 const cl_event *event_wait_list,
594 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueWriteBufferRect)(
595 cl_command_queue command_queue,
597 cl_bool blocking_read,
598 const size_t *buffer_origin,
599 const size_t *host_origin,
600 const size_t *region,
601 size_t buffer_row_pitch,
602 size_t buffer_slice_pitch,
603 size_t host_row_pitch,
604 size_t host_slice_pitch,
606 cl_uint num_events_in_wait_list,
607 const cl_event *event_wait_list,
610 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueCopyBufferRect)(
611 cl_command_queue command_queue,
614 const size_t *src_origin,
615 const size_t *dst_origin,
616 const size_t *region,
617 size_t src_row_pitch,
618 size_t src_slice_pitch,
619 size_t dst_row_pitch,
620 size_t dst_slice_pitch,
621 cl_uint num_events_in_wait_list,
622 const cl_event *event_wait_list,
625 CL_API_ENTRY cl_int (CL_API_CALL *clCreateSubDevicesEXT)(
626 cl_device_id in_device,
627 const cl_device_partition_property_ext *partition_properties,
629 cl_device_id *out_devices,
630 cl_uint *num_devices);
632 CL_API_ENTRY cl_int (CL_API_CALL *clRetainDeviceEXT)(
633 cl_device_id device);
635 CL_API_ENTRY cl_int (CL_API_CALL *clReleaseDeviceEXT)(
636 cl_device_id device);
638 CL_API_ENTRY cl_event (CL_API_CALL *clCreateEventFromGLsyncKHR)(
641 cl_int *errcode_ret);
643 CL_API_ENTRY cl_int (CL_API_CALL *clCreateSubDevices)(
644 cl_device_id in_device,
645 const cl_device_partition_property *partition_properties,
647 cl_device_id *out_devices,
648 cl_uint *num_devices);
650 CL_API_ENTRY cl_int (CL_API_CALL *clRetainDevice)(
651 cl_device_id device);
653 CL_API_ENTRY cl_int (CL_API_CALL *clReleaseDevice)(
654 cl_device_id device);
658 CL_API_ENTRY cl_program (CL_API_CALL *clCreateProgramWithBuiltInKernels)(
661 const cl_device_id *device_list,
662 const char *kernel_names,
663 cl_int *errcode_ret);
665 CL_API_ENTRY cl_int (CL_API_CALL *clCompileProgram)(
668 const cl_device_id *device_list,
670 cl_uint num_input_headers,
671 const cl_program *input_headers,
672 const char **header_include_names,
673 void (CL_CALLBACK *pfn_notify)(cl_program, void *),
676 CL_API_ENTRY cl_program (CL_API_CALL *clLinkProgram)(
679 const cl_device_id *device_list,
681 cl_uint num_input_programs,
682 const cl_program *input_programs,
683 void (CL_CALLBACK *pfn_notify)(cl_program, void *),
685 cl_int *errcode_ret);
687 CL_API_ENTRY cl_int (CL_API_CALL *clUnloadPlatformCompiler)(
688 cl_platform_id platform);
690 void *clGetKernelArgInfo;
692 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueFillBuffer)(
693 cl_command_queue command_queue,
699 cl_uint num_events_in_wait_list,
700 const cl_event *event_wait_list,
703 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueFillImage)(
704 cl_command_queue command_queue,
706 const void *fill_color,
707 const size_t origin[3],
708 const size_t region[3],
709 cl_uint num_events_in_wait_list,
710 const cl_event *event_wait_list,
713 void *clEnqueueMigrateMemObjects;
715 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueMarkerWithWaitList)(
716 cl_command_queue command_queue,
717 cl_uint num_events_in_wait_list,
718 const cl_event *event_wait_list,
721 CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueBarrierWithWaitList)(
722 cl_command_queue command_queue,
723 cl_uint num_events_in_wait_list,
724 const cl_event *event_wait_list,
727 CL_API_ENTRY void *(CL_API_CALL *clGetExtensionFunctionAddressForPlatform)(
728 cl_platform_id platform,
729 const char *function_name);
731 CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromGLTexture)(
737 cl_int *errcode_ret);
739 void *clGetDeviceIDsFromD3D11KHR;
740 void *clCreateFromD3D11BufferKHR;
741 void *clCreateFromD3D11Texture2DKHR;
742 void *clCreateFromD3D11Texture3DKHR;
743 void *clCreateFromDX9MediaSurfaceKHR;
744 void *clEnqueueAcquireD3D11ObjectsKHR;
745 void *clEnqueueReleaseD3D11ObjectsKHR;
746 void *clGetDeviceIDsFromDX9MediaAdapterKHR;
747 void *clEnqueueAcquireDX9MediaSurfacesKHR;
748 void *clEnqueueReleaseDX9MediaSurfacesKHR;
752 extern const _cl_icd_dispatch _dispatch;
755 GetPlatformInfo(cl_platform_id d_platform, cl_platform_info param,
756 size_t size, void *r_buf, size_t *r_size);
759 GetExtensionFunctionAddress(const char *p_name);
762 IcdGetPlatformIDsKHR(cl_uint num_entries, cl_platform_id *rd_platforms,
763 cl_uint *rnum_platforms);