WinGui: Fix another instance of the Caliburn vs Json.net sillyness where objects...
[HandBrake.git] / libhb / opencl.h
blobe19bfb89f9bc095e730aabda3088948f4591472f
1 /* opencl.h
3 Copyright (c) 2003-2015 HandBrake Team
4 This file is part of the HandBrake source code
5 Homepage: <http://handbrake.fr/>.
6 It may be used under the terms of the GNU General Public License v2.
7 For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html
8 */
10 #ifndef HB_OPENCL_H
11 #define HB_OPENCL_H
13 #include "extras/cl.h"
14 #include "openclwrapper.h"
16 // we only support OpenCL 1.1 or later
17 #define HB_OCL_MINVERSION_MAJOR 1
18 #define HB_OCL_MINVERSION_MINOR 1
20 #define HB_OCL_FUNC_TYPE(name) hb_opencl_##name##_func
21 #define HB_OCL_FUNC_DECL(name) HB_OCL_FUNC_TYPE(name) name
22 #define HB_OCL_API(ret, attr, name) typedef ret (attr* HB_OCL_FUNC_TYPE(name))
24 #ifdef __APPLE__
25 #pragma mark -
26 #pragma mark OpenCL API
27 #endif // __APPLE__
29 /* Platform API */
30 HB_OCL_API(cl_int, CL_API_CALL, clGetPlatformIDs)
31 (cl_uint /* num_entries */,
32 cl_platform_id * /* platforms */,
33 cl_uint * /* num_platforms */);
35 HB_OCL_API(cl_int, CL_API_CALL, clGetPlatformInfo)
36 (cl_platform_id /* platform */,
37 cl_platform_info /* param_name */,
38 size_t /* param_value_size */,
39 void * /* param_value */,
40 size_t * /* param_value_size_ret */);
42 /* Device APIs */
43 HB_OCL_API(cl_int, CL_API_CALL, clGetDeviceIDs)
44 (cl_platform_id /* platform */,
45 cl_device_type /* device_type */,
46 cl_uint /* num_entries */,
47 cl_device_id * /* devices */,
48 cl_uint * /* num_devices */);
50 HB_OCL_API(cl_int, CL_API_CALL, clGetDeviceInfo)
51 (cl_device_id /* device */,
52 cl_device_info /* param_name */,
53 size_t /* param_value_size */,
54 void * /* param_value */,
55 size_t * /* param_value_size_ret */);
57 HB_OCL_API(cl_int, CL_API_CALL, clCreateSubDevices)
58 (cl_device_id /* in_device */,
59 const cl_device_partition_property * /* properties */,
60 cl_uint /* num_devices */,
61 cl_device_id * /* out_devices */,
62 cl_uint * /* num_devices_ret */);
64 HB_OCL_API(cl_int, CL_API_CALL, clRetainDevice)
65 (cl_device_id /* device */);
67 HB_OCL_API(cl_int, CL_API_CALL, clReleaseDevice)
68 (cl_device_id /* device */);
70 /* Context APIs */
71 HB_OCL_API(cl_context, CL_API_CALL, clCreateContext)
72 (const cl_context_properties * /* properties */,
73 cl_uint /* num_devices */,
74 const cl_device_id * /* devices */,
75 void (CL_CALLBACK * /* pfn_notify */)(const char *, const void *, size_t, void *),
76 void * /* user_data */,
77 cl_int * /* errcode_ret */);
79 HB_OCL_API(cl_context, CL_API_CALL, clCreateContextFromType)
80 (const cl_context_properties * /* properties */,
81 cl_device_type /* device_type */,
82 void (CL_CALLBACK * /* pfn_notify*/ )(const char *, const void *, size_t, void *),
83 void * /* user_data */,
84 cl_int * /* errcode_ret */);
86 HB_OCL_API(cl_int, CL_API_CALL, clRetainContext)
87 (cl_context /* context */);
89 HB_OCL_API(cl_int, CL_API_CALL, clReleaseContext)
90 (cl_context /* context */);
92 HB_OCL_API(cl_int, CL_API_CALL, clGetContextInfo)
93 (cl_context /* context */,
94 cl_context_info /* param_name */,
95 size_t /* param_value_size */,
96 void * /* param_value */,
97 size_t * /* param_value_size_ret */);
99 /* Command Queue APIs */
100 HB_OCL_API(cl_command_queue, CL_API_CALL, clCreateCommandQueue)
101 (cl_context /* context */,
102 cl_device_id /* device */,
103 cl_command_queue_properties /* properties */,
104 cl_int * /* errcode_ret */);
106 HB_OCL_API(cl_int, CL_API_CALL, clRetainCommandQueue)
107 (cl_command_queue /* command_queue */);
109 HB_OCL_API(cl_int, CL_API_CALL, clReleaseCommandQueue)
110 (cl_command_queue /* command_queue */);
112 HB_OCL_API(cl_int, CL_API_CALL, clGetCommandQueueInfo)
113 (cl_command_queue /* command_queue */,
114 cl_command_queue_info /* param_name */,
115 size_t /* param_value_size */,
116 void * /* param_value */,
117 size_t * /* param_value_size_ret */);
119 /* Memory Object APIs */
120 HB_OCL_API(cl_mem, CL_API_CALL, clCreateBuffer)
121 (cl_context /* context */,
122 cl_mem_flags /* flags */,
123 size_t /* size */,
124 void * /* host_ptr */,
125 cl_int * /* errcode_ret */);
127 HB_OCL_API(cl_mem, CL_API_CALL, clCreateSubBuffer)
128 (cl_mem /* buffer */,
129 cl_mem_flags /* flags */,
130 cl_buffer_create_type /* buffer_create_type */,
131 const void * /* buffer_create_info */,
132 cl_int * /* errcode_ret */);
134 HB_OCL_API(cl_mem, CL_API_CALL, clCreateImage)
135 (cl_context /* context */,
136 cl_mem_flags /* flags */,
137 const cl_image_format * /* image_format */,
138 const cl_image_desc * /* image_desc */,
139 void * /* host_ptr */,
140 cl_int * /* errcode_ret */);
142 HB_OCL_API(cl_int, CL_API_CALL, clRetainMemObject)
143 (cl_mem /* memobj */);
145 HB_OCL_API(cl_int, CL_API_CALL, clReleaseMemObject)
146 (cl_mem /* memobj */);
148 HB_OCL_API(cl_int, CL_API_CALL, clGetSupportedImageFormats)
149 (cl_context /* context */,
150 cl_mem_flags /* flags */,
151 cl_mem_object_type /* image_type */,
152 cl_uint /* num_entries */,
153 cl_image_format * /* image_formats */,
154 cl_uint * /* num_image_formats */);
156 HB_OCL_API(cl_int, CL_API_CALL, clGetMemObjectInfo)
157 (cl_mem /* memobj */,
158 cl_mem_info /* param_name */,
159 size_t /* param_value_size */,
160 void * /* param_value */,
161 size_t * /* param_value_size_ret */);
163 HB_OCL_API(cl_int, CL_API_CALL, clGetImageInfo)
164 (cl_mem /* image */,
165 cl_image_info /* param_name */,
166 size_t /* param_value_size */,
167 void * /* param_value */,
168 size_t * /* param_value_size_ret */);
170 HB_OCL_API(cl_int, CL_API_CALL, clSetMemObjectDestructorCallback)
171 (cl_mem /* memobj */,
172 void (CL_CALLBACK * /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/),
173 void * /*user_data */ );
175 /* Sampler APIs */
176 HB_OCL_API(cl_sampler, CL_API_CALL, clCreateSampler)
177 (cl_context /* context */,
178 cl_bool /* normalized_coords */,
179 cl_addressing_mode /* addressing_mode */,
180 cl_filter_mode /* filter_mode */,
181 cl_int * /* errcode_ret */);
183 HB_OCL_API(cl_int, CL_API_CALL, clRetainSampler)
184 (cl_sampler /* sampler */);
186 HB_OCL_API(cl_int, CL_API_CALL, clReleaseSampler)
187 (cl_sampler /* sampler */);
189 HB_OCL_API(cl_int, CL_API_CALL, clGetSamplerInfo)
190 (cl_sampler /* sampler */,
191 cl_sampler_info /* param_name */,
192 size_t /* param_value_size */,
193 void * /* param_value */,
194 size_t * /* param_value_size_ret */);
196 /* Program Object APIs */
197 HB_OCL_API(cl_program, CL_API_CALL, clCreateProgramWithSource)
198 (cl_context /* context */,
199 cl_uint /* count */,
200 const char ** /* strings */,
201 const size_t * /* lengths */,
202 cl_int * /* errcode_ret */);
204 HB_OCL_API(cl_program, CL_API_CALL, clCreateProgramWithBinary)
205 (cl_context /* context */,
206 cl_uint /* num_devices */,
207 const cl_device_id * /* device_list */,
208 const size_t * /* lengths */,
209 const unsigned char ** /* binaries */,
210 cl_int * /* binary_status */,
211 cl_int * /* errcode_ret */);
213 HB_OCL_API(cl_program, CL_API_CALL, clCreateProgramWithBuiltInKernels)
214 (cl_context /* context */,
215 cl_uint /* num_devices */,
216 const cl_device_id * /* device_list */,
217 const char * /* kernel_names */,
218 cl_int * /* errcode_ret */);
220 HB_OCL_API(cl_int, CL_API_CALL, clRetainProgram)
221 (cl_program /* program */);
223 HB_OCL_API(cl_int, CL_API_CALL, clReleaseProgram)
224 (cl_program /* program */);
226 HB_OCL_API(cl_int, CL_API_CALL, clBuildProgram)
227 (cl_program /* program */,
228 cl_uint /* num_devices */,
229 const cl_device_id * /* device_list */,
230 const char * /* options */,
231 void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
232 void * /* user_data */);
234 HB_OCL_API(cl_int, CL_API_CALL, clCompileProgram)
235 (cl_program /* program */,
236 cl_uint /* num_devices */,
237 const cl_device_id * /* device_list */,
238 const char * /* options */,
239 cl_uint /* num_input_headers */,
240 const cl_program * /* input_headers */,
241 const char ** /* header_include_names */,
242 void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
243 void * /* user_data */);
245 HB_OCL_API(cl_program, CL_API_CALL, clLinkProgram)
246 (cl_context /* context */,
247 cl_uint /* num_devices */,
248 const cl_device_id * /* device_list */,
249 const char * /* options */,
250 cl_uint /* num_input_programs */,
251 const cl_program * /* input_programs */,
252 void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
253 void * /* user_data */,
254 cl_int * /* errcode_ret */ );
257 HB_OCL_API(cl_int, CL_API_CALL, clUnloadPlatformCompiler)
258 (cl_platform_id /* platform */);
260 HB_OCL_API(cl_int, CL_API_CALL, clGetProgramInfo)
261 (cl_program /* program */,
262 cl_program_info /* param_name */,
263 size_t /* param_value_size */,
264 void * /* param_value */,
265 size_t * /* param_value_size_ret */);
267 HB_OCL_API(cl_int, CL_API_CALL, clGetProgramBuildInfo)
268 (cl_program /* program */,
269 cl_device_id /* device */,
270 cl_program_build_info /* param_name */,
271 size_t /* param_value_size */,
272 void * /* param_value */,
273 size_t * /* param_value_size_ret */);
275 /* Kernel Object APIs */
276 HB_OCL_API(cl_kernel, CL_API_CALL, clCreateKernel)
277 (cl_program /* program */,
278 const char * /* kernel_name */,
279 cl_int * /* errcode_ret */);
281 HB_OCL_API(cl_int, CL_API_CALL, clCreateKernelsInProgram)
282 (cl_program /* program */,
283 cl_uint /* num_kernels */,
284 cl_kernel * /* kernels */,
285 cl_uint * /* num_kernels_ret */);
287 HB_OCL_API(cl_int, CL_API_CALL, clRetainKernel)
288 (cl_kernel /* kernel */);
290 HB_OCL_API(cl_int, CL_API_CALL, clReleaseKernel)
291 (cl_kernel /* kernel */);
293 HB_OCL_API(cl_int, CL_API_CALL, clSetKernelArg)
294 (cl_kernel /* kernel */,
295 cl_uint /* arg_index */,
296 size_t /* arg_size */,
297 const void * /* arg_value */);
299 HB_OCL_API(cl_int, CL_API_CALL, clGetKernelInfo)
300 (cl_kernel /* kernel */,
301 cl_kernel_info /* param_name */,
302 size_t /* param_value_size */,
303 void * /* param_value */,
304 size_t * /* param_value_size_ret */);
306 HB_OCL_API(cl_int, CL_API_CALL, clGetKernelArgInfo)
307 (cl_kernel /* kernel */,
308 cl_uint /* arg_indx */,
309 cl_kernel_arg_info /* param_name */,
310 size_t /* param_value_size */,
311 void * /* param_value */,
312 size_t * /* param_value_size_ret */);
314 HB_OCL_API(cl_int, CL_API_CALL, clGetKernelWorkGroupInfo)
315 (cl_kernel /* kernel */,
316 cl_device_id /* device */,
317 cl_kernel_work_group_info /* param_name */,
318 size_t /* param_value_size */,
319 void * /* param_value */,
320 size_t * /* param_value_size_ret */);
322 /* Event Object APIs */
323 HB_OCL_API(cl_int, CL_API_CALL, clWaitForEvents)
324 (cl_uint /* num_events */,
325 const cl_event * /* event_list */);
327 HB_OCL_API(cl_int, CL_API_CALL, clGetEventInfo)
328 (cl_event /* event */,
329 cl_event_info /* param_name */,
330 size_t /* param_value_size */,
331 void * /* param_value */,
332 size_t * /* param_value_size_ret */);
334 HB_OCL_API(cl_event, CL_API_CALL, clCreateUserEvent)
335 (cl_context /* context */,
336 cl_int * /* errcode_ret */);
338 HB_OCL_API(cl_int, CL_API_CALL, clRetainEvent)
339 (cl_event /* event */);
341 HB_OCL_API(cl_int, CL_API_CALL, clReleaseEvent)
342 (cl_event /* event */);
344 HB_OCL_API(cl_int, CL_API_CALL, clSetUserEventStatus)
345 (cl_event /* event */,
346 cl_int /* execution_status */);
348 HB_OCL_API(cl_int, CL_API_CALL, clSetEventCallback)
349 (cl_event /* event */,
350 cl_int /* command_exec_callback_type */,
351 void (CL_CALLBACK * /* pfn_notify */)(cl_event, cl_int, void *),
352 void * /* user_data */);
354 /* Profiling APIs */
355 HB_OCL_API(cl_int, CL_API_CALL, clGetEventProfilingInfo)
356 (cl_event /* event */,
357 cl_profiling_info /* param_name */,
358 size_t /* param_value_size */,
359 void * /* param_value */,
360 size_t * /* param_value_size_ret */);
362 /* Flush and Finish APIs */
363 HB_OCL_API(cl_int, CL_API_CALL, clFlush)
364 (cl_command_queue /* command_queue */);
366 HB_OCL_API(cl_int, CL_API_CALL, clFinish)
367 (cl_command_queue /* command_queue */);
369 /* Enqueued Commands APIs */
370 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueReadBuffer)
371 (cl_command_queue /* command_queue */,
372 cl_mem /* buffer */,
373 cl_bool /* blocking_read */,
374 size_t /* offset */,
375 size_t /* size */,
376 void * /* ptr */,
377 cl_uint /* num_events_in_wait_list */,
378 const cl_event * /* event_wait_list */,
379 cl_event * /* event */);
381 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueReadBufferRect)
382 (cl_command_queue /* command_queue */,
383 cl_mem /* buffer */,
384 cl_bool /* blocking_read */,
385 const size_t * /* buffer_offset */,
386 const size_t * /* host_offset */,
387 const size_t * /* region */,
388 size_t /* buffer_row_pitch */,
389 size_t /* buffer_slice_pitch */,
390 size_t /* host_row_pitch */,
391 size_t /* host_slice_pitch */,
392 void * /* ptr */,
393 cl_uint /* num_events_in_wait_list */,
394 const cl_event * /* event_wait_list */,
395 cl_event * /* event */);
397 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueWriteBuffer)
398 (cl_command_queue /* command_queue */,
399 cl_mem /* buffer */,
400 cl_bool /* blocking_write */,
401 size_t /* offset */,
402 size_t /* size */,
403 const void * /* ptr */,
404 cl_uint /* num_events_in_wait_list */,
405 const cl_event * /* event_wait_list */,
406 cl_event * /* event */);
408 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueWriteBufferRect)
409 (cl_command_queue /* command_queue */,
410 cl_mem /* buffer */,
411 cl_bool /* blocking_write */,
412 const size_t * /* buffer_offset */,
413 const size_t * /* host_offset */,
414 const size_t * /* region */,
415 size_t /* buffer_row_pitch */,
416 size_t /* buffer_slice_pitch */,
417 size_t /* host_row_pitch */,
418 size_t /* host_slice_pitch */,
419 const void * /* ptr */,
420 cl_uint /* num_events_in_wait_list */,
421 const cl_event * /* event_wait_list */,
422 cl_event * /* event */);
424 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueFillBuffer)
425 (cl_command_queue /* command_queue */,
426 cl_mem /* buffer */,
427 const void * /* pattern */,
428 size_t /* pattern_size */,
429 size_t /* offset */,
430 size_t /* size */,
431 cl_uint /* num_events_in_wait_list */,
432 const cl_event * /* event_wait_list */,
433 cl_event * /* event */);
435 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueCopyBuffer)
436 (cl_command_queue /* command_queue */,
437 cl_mem /* src_buffer */,
438 cl_mem /* dst_buffer */,
439 size_t /* src_offset */,
440 size_t /* dst_offset */,
441 size_t /* size */,
442 cl_uint /* num_events_in_wait_list */,
443 const cl_event * /* event_wait_list */,
444 cl_event * /* event */);
446 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueCopyBufferRect)
447 (cl_command_queue /* command_queue */,
448 cl_mem /* src_buffer */,
449 cl_mem /* dst_buffer */,
450 const size_t * /* src_origin */,
451 const size_t * /* dst_origin */,
452 const size_t * /* region */,
453 size_t /* src_row_pitch */,
454 size_t /* src_slice_pitch */,
455 size_t /* dst_row_pitch */,
456 size_t /* dst_slice_pitch */,
457 cl_uint /* num_events_in_wait_list */,
458 const cl_event * /* event_wait_list */,
459 cl_event * /* event */);
461 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueReadImage)
462 (cl_command_queue /* command_queue */,
463 cl_mem /* image */,
464 cl_bool /* blocking_read */,
465 const size_t * /* origin[3] */,
466 const size_t * /* region[3] */,
467 size_t /* row_pitch */,
468 size_t /* slice_pitch */,
469 void * /* ptr */,
470 cl_uint /* num_events_in_wait_list */,
471 const cl_event * /* event_wait_list */,
472 cl_event * /* event */);
474 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueWriteImage)
475 (cl_command_queue /* command_queue */,
476 cl_mem /* image */,
477 cl_bool /* blocking_write */,
478 const size_t * /* origin[3] */,
479 const size_t * /* region[3] */,
480 size_t /* input_row_pitch */,
481 size_t /* input_slice_pitch */,
482 const void * /* ptr */,
483 cl_uint /* num_events_in_wait_list */,
484 const cl_event * /* event_wait_list */,
485 cl_event * /* event */);
487 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueFillImage)
488 (cl_command_queue /* command_queue */,
489 cl_mem /* image */,
490 const void * /* fill_color */,
491 const size_t * /* origin[3] */,
492 const size_t * /* region[3] */,
493 cl_uint /* num_events_in_wait_list */,
494 const cl_event * /* event_wait_list */,
495 cl_event * /* event */);
497 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueCopyImage)
498 (cl_command_queue /* command_queue */,
499 cl_mem /* src_image */,
500 cl_mem /* dst_image */,
501 const size_t * /* src_origin[3] */,
502 const size_t * /* dst_origin[3] */,
503 const size_t * /* region[3] */,
504 cl_uint /* num_events_in_wait_list */,
505 const cl_event * /* event_wait_list */,
506 cl_event * /* event */);
508 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueCopyImageToBuffer)
509 (cl_command_queue /* command_queue */,
510 cl_mem /* src_image */,
511 cl_mem /* dst_buffer */,
512 const size_t * /* src_origin[3] */,
513 const size_t * /* region[3] */,
514 size_t /* dst_offset */,
515 cl_uint /* num_events_in_wait_list */,
516 const cl_event * /* event_wait_list */,
517 cl_event * /* event */);
519 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueCopyBufferToImage)
520 (cl_command_queue /* command_queue */,
521 cl_mem /* src_buffer */,
522 cl_mem /* dst_image */,
523 size_t /* src_offset */,
524 const size_t * /* dst_origin[3] */,
525 const size_t * /* region[3] */,
526 cl_uint /* num_events_in_wait_list */,
527 const cl_event * /* event_wait_list */,
528 cl_event * /* event */);
530 HB_OCL_API(void *, CL_API_CALL, clEnqueueMapBuffer)
531 (cl_command_queue /* command_queue */,
532 cl_mem /* buffer */,
533 cl_bool /* blocking_map */,
534 cl_map_flags /* map_flags */,
535 size_t /* offset */,
536 size_t /* size */,
537 cl_uint /* num_events_in_wait_list */,
538 const cl_event * /* event_wait_list */,
539 cl_event * /* event */,
540 cl_int * /* errcode_ret */);
542 HB_OCL_API(void *, CL_API_CALL, clEnqueueMapImage)
543 (cl_command_queue /* command_queue */,
544 cl_mem /* image */,
545 cl_bool /* blocking_map */,
546 cl_map_flags /* map_flags */,
547 const size_t * /* origin[3] */,
548 const size_t * /* region[3] */,
549 size_t * /* image_row_pitch */,
550 size_t * /* image_slice_pitch */,
551 cl_uint /* num_events_in_wait_list */,
552 const cl_event * /* event_wait_list */,
553 cl_event * /* event */,
554 cl_int * /* errcode_ret */);
556 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueUnmapMemObject)
557 (cl_command_queue /* command_queue */,
558 cl_mem /* memobj */,
559 void * /* mapped_ptr */,
560 cl_uint /* num_events_in_wait_list */,
561 const cl_event * /* event_wait_list */,
562 cl_event * /* event */);
564 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueMigrateMemObjects)
565 (cl_command_queue /* command_queue */,
566 cl_uint /* num_mem_objects */,
567 const cl_mem * /* mem_objects */,
568 cl_mem_migration_flags /* flags */,
569 cl_uint /* num_events_in_wait_list */,
570 const cl_event * /* event_wait_list */,
571 cl_event * /* event */);
573 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueNDRangeKernel)
574 (cl_command_queue /* command_queue */,
575 cl_kernel /* kernel */,
576 cl_uint /* work_dim */,
577 const size_t * /* global_work_offset */,
578 const size_t * /* global_work_size */,
579 const size_t * /* local_work_size */,
580 cl_uint /* num_events_in_wait_list */,
581 const cl_event * /* event_wait_list */,
582 cl_event * /* event */);
584 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueTask)
585 (cl_command_queue /* command_queue */,
586 cl_kernel /* kernel */,
587 cl_uint /* num_events_in_wait_list */,
588 const cl_event * /* event_wait_list */,
589 cl_event * /* event */);
591 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueNativeKernel)
592 (cl_command_queue /* command_queue */,
593 void (CL_CALLBACK * /*user_func*/)(void *),
594 void * /* args */,
595 size_t /* cb_args */,
596 cl_uint /* num_mem_objects */,
597 const cl_mem * /* mem_list */,
598 const void ** /* args_mem_loc */,
599 cl_uint /* num_events_in_wait_list */,
600 const cl_event * /* event_wait_list */,
601 cl_event * /* event */);
603 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueMarkerWithWaitList)
604 (cl_command_queue /* command_queue */,
605 cl_uint /* num_events_in_wait_list */,
606 const cl_event * /* event_wait_list */,
607 cl_event * /* event */);
609 HB_OCL_API(cl_int, CL_API_CALL, clEnqueueBarrierWithWaitList)
610 (cl_command_queue /* command_queue */,
611 cl_uint /* num_events_in_wait_list */,
612 const cl_event * /* event_wait_list */,
613 cl_event * /* event */);
616 /* Extension function access
618 * Returns the extension function address for the given function name,
619 * or NULL if a valid function can not be found. The client must
620 * check to make sure the address is not NULL, before using or
621 * calling the returned function address.
623 HB_OCL_API(void *, CL_API_CALL, clGetExtensionFunctionAddressForPlatform)
624 (cl_platform_id /* platform */,
625 const char * /* func_name */);
627 #ifdef __APPLE__
628 #pragma mark -
629 #endif // __APPLE__
631 typedef struct hb_opencl_library_s
633 void *library;
635 /* Pointers to select OpenCL API functions */
636 HB_OCL_FUNC_DECL(clBuildProgram);
637 HB_OCL_FUNC_DECL(clCreateBuffer);
638 HB_OCL_FUNC_DECL(clCreateCommandQueue);
639 HB_OCL_FUNC_DECL(clCreateContextFromType);
640 HB_OCL_FUNC_DECL(clCreateKernel);
641 HB_OCL_FUNC_DECL(clCreateProgramWithBinary);
642 HB_OCL_FUNC_DECL(clCreateProgramWithSource);
643 HB_OCL_FUNC_DECL(clEnqueueCopyBuffer);
644 HB_OCL_FUNC_DECL(clEnqueueMapBuffer);
645 HB_OCL_FUNC_DECL(clEnqueueNDRangeKernel);
646 HB_OCL_FUNC_DECL(clEnqueueReadBuffer);
647 HB_OCL_FUNC_DECL(clEnqueueUnmapMemObject);
648 HB_OCL_FUNC_DECL(clEnqueueWriteBuffer);
649 HB_OCL_FUNC_DECL(clFlush);
650 HB_OCL_FUNC_DECL(clGetCommandQueueInfo);
651 HB_OCL_FUNC_DECL(clGetContextInfo);
652 HB_OCL_FUNC_DECL(clGetDeviceIDs);
653 HB_OCL_FUNC_DECL(clGetDeviceInfo);
654 HB_OCL_FUNC_DECL(clGetPlatformIDs);
655 HB_OCL_FUNC_DECL(clGetPlatformInfo);
656 HB_OCL_FUNC_DECL(clGetProgramBuildInfo);
657 HB_OCL_FUNC_DECL(clGetProgramInfo);
658 HB_OCL_FUNC_DECL(clReleaseCommandQueue);
659 HB_OCL_FUNC_DECL(clReleaseContext);
660 HB_OCL_FUNC_DECL(clReleaseEvent);
661 HB_OCL_FUNC_DECL(clReleaseKernel);
662 HB_OCL_FUNC_DECL(clReleaseMemObject);
663 HB_OCL_FUNC_DECL(clReleaseProgram);
664 HB_OCL_FUNC_DECL(clSetKernelArg);
665 HB_OCL_FUNC_DECL(clWaitForEvents);
666 } hb_opencl_library_t;
668 hb_opencl_library_t* hb_opencl_library_init();
669 void hb_opencl_library_close(hb_opencl_library_t **_opencl);
672 * Convenience pointer to a single shared OpenCL library wrapper.
674 * It can be initialized and closed via hb_ocl_init/close().
676 extern hb_opencl_library_t *hb_ocl;
677 int hb_ocl_init();
678 void hb_ocl_close();
680 typedef struct hb_opencl_device_s
682 cl_platform_id platform;
683 cl_device_type type;
684 cl_device_id id;
685 char version[128];
686 char driver[128];
687 char vendor[128];
688 char name[128];
689 enum
691 HB_OCL_VENDOR_AMD,
692 HB_OCL_VENDOR_NVIDIA,
693 HB_OCL_VENDOR_INTEL,
694 HB_OCL_VENDOR_OTHER,
695 } ocl_vendor;
696 } hb_opencl_device_t;
698 int hb_opencl_available();
699 void hb_opencl_info_print();
701 /* OpenCL scaling */
702 typedef struct hb_oclscale_s
704 int initialized;
705 // bicubic scale weights
706 cl_mem bicubic_x_weights;
707 cl_mem bicubic_y_weights;
708 cl_float xscale;
709 cl_float yscale;
710 int width;
711 int height;
712 // horizontal scaling and vertical scaling kernel handle
713 cl_kernel m_kernel;
714 int use_ocl_mem; // 0 use host memory. 1 use gpu oclmem
715 } hb_oclscale_t;
717 int hb_ocl_scale(hb_buffer_t *in, hb_buffer_t *out, int *crop,
718 hb_oclscale_t *os);
720 /* Utilities */
721 #define HB_OCL_BUF_CREATE(ocl_lib, out, flags, size) \
723 out = ocl_lib->clCreateBuffer(kenv->context, flags, size, NULL, &status); \
724 if (CL_SUCCESS != status) \
726 return -1; \
730 #define HB_OCL_BUF_FREE(ocl_lib, buf) \
732 if (buf != NULL) \
734 ocl_lib->clReleaseMemObject(buf); \
735 buf = NULL; \
739 #define HB_OCL_CHECK(method, ...) \
741 status = method(__VA_ARGS__); \
742 if (status != CL_SUCCESS) \
744 hb_error("%s:%d (%s) error: %d\n",__FUNCTION__,__LINE__,#method,status);\
745 return status; \
749 #endif//HB_OPENCL_H