kernel32: Get rid of the last parameter to PROFILE_CopyEntry().
[wine.git] / dlls / opencl / opencl.c
blob06b8d78a4073cd19ee3ad83422c56d0e2b113ab2
1 /*
2 * OpenCL.dll proxy for native OpenCL implementation.
4 * Copyright 2010 Peter Urbanec
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
28 #include "wine/debug.h"
29 #include "wine/library.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(opencl);
33 #define CL_SILENCE_DEPRECATION
34 #if defined(HAVE_CL_CL_H)
35 #define CL_USE_DEPRECATED_OPENCL_1_1_APIS
36 #define CL_USE_DEPRECATED_OPENCL_1_2_APIS
37 #define CL_USE_DEPRECATED_OPENCL_2_0_APIS
38 #define CL_TARGET_OPENCL_VERSION 220
39 #include <CL/cl.h>
40 #elif defined(HAVE_OPENCL_OPENCL_H)
41 #include <OpenCL/opencl.h>
42 #endif
44 /* TODO: Figure out how to provide GL context sharing before enabling OpenGL */
45 #define OPENCL_WITH_GL 0
48 /*---------------------------------------------------------------*/
49 /* Platform API */
51 cl_int WINAPI wine_clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms)
53 cl_int ret;
54 TRACE("(%d, %p, %p)\n", num_entries, platforms, num_platforms);
55 ret = clGetPlatformIDs(num_entries, platforms, num_platforms);
56 TRACE("(%d, %p, %p)=%d\n", num_entries, platforms, num_platforms, ret);
57 return ret;
60 cl_int WINAPI wine_clGetPlatformInfo(cl_platform_id platform, cl_platform_info param_name,
61 SIZE_T param_value_size, void * param_value, size_t * param_value_size_ret)
63 cl_int ret;
64 TRACE("(%p, 0x%x, %ld, %p, %p)\n", platform, param_name, param_value_size, param_value, param_value_size_ret);
66 /* Hide all extensions.
67 * TODO: Add individual extension support as needed.
69 if (param_name == CL_PLATFORM_EXTENSIONS)
71 ret = CL_INVALID_VALUE;
73 if (param_value && param_value_size > 0)
75 char *exts = (char *) param_value;
76 exts[0] = '\0';
77 ret = CL_SUCCESS;
80 if (param_value_size_ret)
82 *param_value_size_ret = 1;
83 ret = CL_SUCCESS;
86 else
88 ret = clGetPlatformInfo(platform, param_name, param_value_size, param_value, param_value_size_ret);
91 TRACE("(%p, 0x%x, %ld, %p, %p)=%d\n", platform, param_name, param_value_size, param_value, param_value_size_ret, ret);
92 return ret;
96 /*---------------------------------------------------------------*/
97 /* Device APIs */
99 cl_int WINAPI wine_clGetDeviceIDs(cl_platform_id platform, cl_device_type device_type,
100 cl_uint num_entries, cl_device_id * devices, cl_uint * num_devices)
102 cl_int ret;
103 TRACE("(%p, 0x%lx, %d, %p, %p)\n", platform, (long unsigned int)device_type, num_entries, devices, num_devices);
104 ret = clGetDeviceIDs(platform, device_type, num_entries, devices, num_devices);
105 TRACE("(%p, 0x%lx, %d, %p, %p)=%d\n", platform, (long unsigned int)device_type, num_entries, devices, num_devices, ret);
106 return ret;
109 cl_int WINAPI wine_clGetDeviceInfo(cl_device_id device, cl_device_info param_name,
110 SIZE_T param_value_size, void * param_value, size_t * param_value_size_ret)
112 cl_int ret;
113 TRACE("(%p, 0x%x, %ld, %p, %p)\n",device, param_name, param_value_size, param_value, param_value_size_ret);
115 /* Hide all extensions.
116 * TODO: Add individual extension support as needed.
118 if (param_name == CL_DEVICE_EXTENSIONS)
120 ret = CL_INVALID_VALUE;
122 if (param_value && param_value_size > 0)
124 char *exts = (char *) param_value;
125 exts[0] = '\0';
126 ret = CL_SUCCESS;
129 if (param_value_size_ret)
131 *param_value_size_ret = 1;
132 ret = CL_SUCCESS;
135 else
137 ret = clGetDeviceInfo(device, param_name, param_value_size, param_value, param_value_size_ret);
140 /* Filter out the CL_EXEC_NATIVE_KERNEL flag */
141 if (param_name == CL_DEVICE_EXECUTION_CAPABILITIES)
143 cl_device_exec_capabilities *caps = (cl_device_exec_capabilities *) param_value;
144 *caps &= ~CL_EXEC_NATIVE_KERNEL;
147 TRACE("(%p, 0x%x, %ld, %p, %p)=%d\n",device, param_name, param_value_size, param_value, param_value_size_ret, ret);
148 return ret;
152 /*---------------------------------------------------------------*/
153 /* Context APIs */
155 typedef struct
157 void WINAPI (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data);
158 void *user_data;
159 } CONTEXT_CALLBACK;
161 static void context_fn_notify(const char *errinfo, const void *private_info, size_t cb, void *user_data)
163 CONTEXT_CALLBACK *ccb;
164 TRACE("(%s, %p, %ld, %p)\n", errinfo, private_info, (SIZE_T)cb, user_data);
165 ccb = (CONTEXT_CALLBACK *) user_data;
166 if(ccb->pfn_notify) ccb->pfn_notify(errinfo, private_info, cb, ccb->user_data);
167 TRACE("Callback COMPLETED\n");
170 cl_context WINAPI wine_clCreateContext(const cl_context_properties * properties, cl_uint num_devices, const cl_device_id * devices,
171 void WINAPI (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data),
172 void * user_data, cl_int * errcode_ret)
174 cl_context ret;
175 CONTEXT_CALLBACK *ccb;
176 TRACE("(%p, %d, %p, %p, %p, %p)\n", properties, num_devices, devices, pfn_notify, user_data, errcode_ret);
177 /* FIXME: The CONTEXT_CALLBACK structure is currently leaked.
178 * Pointers to callback redirectors should be remembered and free()d when the context is destroyed.
179 * The problem is determining when a context is being destroyed. clReleaseContext only decrements
180 * the use count for a context, its destruction can come much later and therefore there is a risk
181 * that the callback could be invoked after the user_data memory has been free()d.
183 ccb = HeapAlloc(GetProcessHeap(), 0, sizeof(CONTEXT_CALLBACK));
184 ccb->pfn_notify = pfn_notify;
185 ccb->user_data = user_data;
186 ret = clCreateContext(properties, num_devices, devices, context_fn_notify, ccb, errcode_ret);
187 TRACE("(%p, %d, %p, %p, %p, %p (%d)))=%p\n", properties, num_devices, devices, &pfn_notify, user_data, errcode_ret, errcode_ret ? *errcode_ret : 0, ret);
188 return ret;
191 cl_context WINAPI wine_clCreateContextFromType(const cl_context_properties * properties, cl_device_type device_type,
192 void WINAPI (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data),
193 void * user_data, cl_int * errcode_ret)
195 cl_context ret;
196 CONTEXT_CALLBACK *ccb;
197 TRACE("(%p, 0x%lx, %p, %p, %p)\n", properties, (long unsigned int)device_type, pfn_notify, user_data, errcode_ret);
198 /* FIXME: The CONTEXT_CALLBACK structure is currently leaked.
199 * Pointers to callback redirectors should be remembered and free()d when the context is destroyed.
200 * The problem is determining when a context is being destroyed. clReleaseContext only decrements
201 * the use count for a context, its destruction can come much later and therefore there is a risk
202 * that the callback could be invoked after the user_data memory has been free()d.
204 ccb = HeapAlloc(GetProcessHeap(), 0, sizeof(CONTEXT_CALLBACK));
205 ccb->pfn_notify = pfn_notify;
206 ccb->user_data = user_data;
207 ret = clCreateContextFromType(properties, device_type, context_fn_notify, ccb, errcode_ret);
208 TRACE("(%p, 0x%lx, %p, %p, %p (%d)))=%p\n", properties, (long unsigned int)device_type, pfn_notify, user_data, errcode_ret, errcode_ret ? *errcode_ret : 0, ret);
209 return ret;
212 cl_int WINAPI wine_clRetainContext(cl_context context)
214 cl_int ret;
215 TRACE("(%p)\n", context);
216 ret = clRetainContext(context);
217 TRACE("(%p)=%d\n", context, ret);
218 return ret;
221 cl_int WINAPI wine_clReleaseContext(cl_context context)
223 cl_int ret;
224 TRACE("(%p)\n", context);
225 ret = clReleaseContext(context);
226 TRACE("(%p)=%d\n", context, ret);
227 return ret;
230 cl_int WINAPI wine_clGetContextInfo(cl_context context, cl_context_info param_name,
231 SIZE_T param_value_size, void * param_value, size_t * param_value_size_ret)
233 cl_int ret;
234 TRACE("(%p, 0x%x, %ld, %p, %p)\n", context, param_name, param_value_size, param_value, param_value_size_ret);
235 ret = clGetContextInfo(context, param_name, param_value_size, param_value, param_value_size_ret);
236 TRACE("(%p, 0x%x, %ld, %p, %p)=%d\n", context, param_name, param_value_size, param_value, param_value_size_ret, ret);
237 return ret;
241 /*---------------------------------------------------------------*/
242 /* Command Queue APIs */
244 cl_command_queue WINAPI wine_clCreateCommandQueue(cl_context context, cl_device_id device,
245 cl_command_queue_properties properties, cl_int * errcode_ret)
247 cl_command_queue ret;
248 TRACE("(%p, %p, 0x%lx, %p)\n", context, device, (long unsigned int)properties, errcode_ret);
249 ret = clCreateCommandQueue(context, device, properties, errcode_ret);
250 TRACE("(%p, %p, 0x%lx, %p)=%p\n", context, device, (long unsigned int)properties, errcode_ret, ret);
251 return ret;
254 cl_int WINAPI wine_clRetainCommandQueue(cl_command_queue command_queue)
256 cl_int ret;
257 TRACE("(%p)\n", command_queue);
258 ret = clRetainCommandQueue(command_queue);
259 TRACE("(%p)=%d\n", command_queue, ret);
260 return ret;
263 cl_int WINAPI wine_clReleaseCommandQueue(cl_command_queue command_queue)
265 cl_int ret;
266 TRACE("(%p)\n", command_queue);
267 ret = clReleaseCommandQueue(command_queue);
268 TRACE("(%p)=%d\n", command_queue, ret);
269 return ret;
272 cl_int WINAPI wine_clGetCommandQueueInfo(cl_command_queue command_queue, cl_command_queue_info param_name,
273 SIZE_T param_value_size, void * param_value, size_t * param_value_size_ret)
275 cl_int ret;
276 TRACE("%p, %d, %ld, %p, %p\n", command_queue, param_name, param_value_size, param_value, param_value_size_ret);
277 ret = clGetCommandQueueInfo(command_queue, param_name, param_value_size, param_value, param_value_size_ret);
278 return ret;
281 cl_int WINAPI wine_clSetCommandQueueProperty(cl_command_queue command_queue, cl_command_queue_properties properties, cl_bool enable,
282 cl_command_queue_properties * old_properties)
284 FIXME("(%p, 0x%lx, %d, %p): deprecated\n", command_queue, (long unsigned int)properties, enable, old_properties);
285 return CL_INVALID_QUEUE_PROPERTIES;
289 /*---------------------------------------------------------------*/
290 /* Memory Object APIs */
292 cl_mem WINAPI wine_clCreateBuffer(cl_context context, cl_mem_flags flags, size_t size, void * host_ptr, cl_int * errcode_ret)
294 cl_mem ret;
295 TRACE("\n");
296 ret = clCreateBuffer(context, flags, size, host_ptr, errcode_ret);
297 return ret;
300 cl_mem WINAPI wine_clCreateImage2D(cl_context context, cl_mem_flags flags, cl_image_format * image_format,
301 size_t image_width, size_t image_height, size_t image_row_pitch, void * host_ptr, cl_int * errcode_ret)
303 cl_mem ret;
304 TRACE("\n");
305 ret = clCreateImage2D(context, flags, image_format, image_width, image_height, image_row_pitch, host_ptr, errcode_ret);
306 return ret;
309 cl_mem WINAPI wine_clCreateImage3D(cl_context context, cl_mem_flags flags, cl_image_format * image_format,
310 size_t image_width, size_t image_height, size_t image_depth, size_t image_row_pitch, size_t image_slice_pitch,
311 void * host_ptr, cl_int * errcode_ret)
313 cl_mem ret;
314 TRACE("\n");
315 ret = clCreateImage3D(context, flags, image_format, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch, host_ptr, errcode_ret);
316 return ret;
319 cl_int WINAPI wine_clRetainMemObject(cl_mem memobj)
321 cl_int ret;
322 TRACE("(%p)\n", memobj);
323 ret = clRetainMemObject(memobj);
324 TRACE("(%p)=%d\n", memobj, ret);
325 return ret;
328 cl_int WINAPI wine_clReleaseMemObject(cl_mem memobj)
330 cl_int ret;
331 TRACE("(%p)\n", memobj);
332 ret = clReleaseMemObject(memobj);
333 TRACE("(%p)=%d\n", memobj, ret);
334 return ret;
337 cl_int WINAPI wine_clGetSupportedImageFormats(cl_context context, cl_mem_flags flags, cl_mem_object_type image_type, cl_uint num_entries,
338 cl_image_format * image_formats, cl_uint * num_image_formats)
340 cl_int ret;
341 TRACE("\n");
342 ret = clGetSupportedImageFormats(context, flags, image_type, num_entries, image_formats, num_image_formats);
343 return ret;
346 cl_int WINAPI wine_clGetMemObjectInfo(cl_mem memobj, cl_mem_info param_name, size_t param_value_size, void * param_value, size_t * param_value_size_ret)
348 cl_int ret;
349 TRACE("\n");
350 ret = clGetMemObjectInfo(memobj, param_name, param_value_size, param_value, param_value_size_ret);
351 return ret;
354 cl_int WINAPI wine_clGetImageInfo(cl_mem image, cl_image_info param_name, size_t param_value_size, void * param_value, size_t * param_value_size_ret)
356 cl_int ret;
357 TRACE("\n");
358 ret = clGetImageInfo(image, param_name, param_value_size, param_value, param_value_size_ret);
359 return ret;
363 /*---------------------------------------------------------------*/
364 /* Sampler APIs */
366 cl_sampler WINAPI wine_clCreateSampler(cl_context context, cl_bool normalized_coords, cl_addressing_mode addressing_mode,
367 cl_filter_mode filter_mode, cl_int * errcode_ret)
369 cl_sampler ret;
370 TRACE("\n");
371 ret = clCreateSampler(context, normalized_coords, addressing_mode, filter_mode, errcode_ret);
372 return ret;
375 cl_int WINAPI wine_clRetainSampler(cl_sampler sampler)
377 cl_int ret;
378 TRACE("\n");
379 ret = clRetainSampler(sampler);
380 return ret;
383 cl_int WINAPI wine_clReleaseSampler(cl_sampler sampler)
385 cl_int ret;
386 TRACE("\n");
387 ret = clReleaseSampler(sampler);
388 return ret;
391 cl_int WINAPI wine_clGetSamplerInfo(cl_sampler sampler, cl_sampler_info param_name, size_t param_value_size,
392 void * param_value, size_t * param_value_size_ret)
394 cl_int ret;
395 TRACE("\n");
396 ret = clGetSamplerInfo(sampler, param_name, param_value_size, param_value, param_value_size_ret);
397 return ret;
401 /*---------------------------------------------------------------*/
402 /* Program Object APIs */
404 cl_program WINAPI wine_clCreateProgramWithSource(cl_context context, cl_uint count, const char ** strings,
405 const size_t * lengths, cl_int * errcode_ret)
407 cl_program ret;
408 TRACE("\n");
409 ret = clCreateProgramWithSource(context, count, strings, lengths, errcode_ret);
410 return ret;
413 cl_program WINAPI wine_clCreateProgramWithBinary(cl_context context, cl_uint num_devices, const cl_device_id * device_list,
414 const size_t * lengths, const unsigned char ** binaries, cl_int * binary_status,
415 cl_int * errcode_ret)
417 cl_program ret;
418 TRACE("\n");
419 ret = clCreateProgramWithBinary(context, num_devices, device_list, lengths, binaries, binary_status, errcode_ret);
420 return ret;
423 cl_int WINAPI wine_clRetainProgram(cl_program program)
425 cl_int ret;
426 TRACE("\n");
427 ret = clRetainProgram(program);
428 return ret;
431 cl_int WINAPI wine_clReleaseProgram(cl_program program)
433 cl_int ret;
434 TRACE("\n");
435 ret = clReleaseProgram(program);
436 return ret;
439 typedef struct
441 void WINAPI (*pfn_notify)(cl_program program, void * user_data);
442 void *user_data;
443 } PROGRAM_CALLBACK;
445 static void program_fn_notify(cl_program program, void * user_data)
447 PROGRAM_CALLBACK *pcb;
448 TRACE("(%p, %p)\n", program, user_data);
449 pcb = (PROGRAM_CALLBACK *) user_data;
450 pcb->pfn_notify(program, pcb->user_data);
451 HeapFree(GetProcessHeap(), 0, pcb);
452 TRACE("Callback COMPLETED\n");
455 cl_int WINAPI wine_clBuildProgram(cl_program program, cl_uint num_devices, const cl_device_id * device_list, const char * options,
456 void WINAPI (*pfn_notify)(cl_program program, void * user_data),
457 void * user_data)
459 cl_int ret;
460 TRACE("\n");
461 if(pfn_notify)
463 /* When pfn_notify is provided, clBuildProgram is asynchronous */
464 PROGRAM_CALLBACK *pcb;
465 pcb = HeapAlloc(GetProcessHeap(), 0, sizeof(PROGRAM_CALLBACK));
466 pcb->pfn_notify = pfn_notify;
467 pcb->user_data = user_data;
468 ret = clBuildProgram(program, num_devices, device_list, options, program_fn_notify, pcb);
470 else
472 /* When pfn_notify is NULL, clBuildProgram is synchronous */
473 ret = clBuildProgram(program, num_devices, device_list, options, NULL, user_data);
475 return ret;
478 cl_int WINAPI wine_clUnloadCompiler(void)
480 cl_int ret;
481 TRACE("()\n");
482 ret = clUnloadCompiler();
483 TRACE("()=%d\n", ret);
484 return ret;
487 cl_int WINAPI wine_clGetProgramInfo(cl_program program, cl_program_info param_name,
488 size_t param_value_size, void * param_value, size_t * param_value_size_ret)
490 cl_int ret;
491 TRACE("\n");
492 ret = clGetProgramInfo(program, param_name, param_value_size, param_value, param_value_size_ret);
493 return ret;
496 cl_int WINAPI wine_clGetProgramBuildInfo(cl_program program, cl_device_id device,
497 cl_program_build_info param_name, size_t param_value_size, void * param_value,
498 size_t * param_value_size_ret)
500 cl_int ret;
501 TRACE("\n");
502 ret = clGetProgramBuildInfo(program, device, param_name, param_value_size, param_value, param_value_size_ret);
503 return ret;
507 /*---------------------------------------------------------------*/
508 /* Kernel Object APIs */
510 cl_kernel WINAPI wine_clCreateKernel(cl_program program, char * kernel_name, cl_int * errcode_ret)
512 cl_kernel ret;
513 TRACE("\n");
514 ret = clCreateKernel(program, kernel_name, errcode_ret);
515 return ret;
518 cl_int WINAPI wine_clCreateKernelsInProgram(cl_program program, cl_uint num_kernels,
519 cl_kernel * kernels, cl_uint * num_kernels_ret)
521 cl_int ret;
522 TRACE("\n");
523 ret = clCreateKernelsInProgram(program, num_kernels, kernels, num_kernels_ret);
524 return ret;
527 cl_int WINAPI wine_clRetainKernel(cl_kernel kernel)
529 cl_int ret;
530 TRACE("\n");
531 ret = clRetainKernel(kernel);
532 return ret;
535 cl_int WINAPI wine_clReleaseKernel(cl_kernel kernel)
537 cl_int ret;
538 TRACE("\n");
539 ret = clReleaseKernel(kernel);
540 return ret;
543 cl_int WINAPI wine_clSetKernelArg(cl_kernel kernel, cl_uint arg_index, size_t arg_size, void * arg_value)
545 cl_int ret;
546 TRACE("\n");
547 ret = clSetKernelArg(kernel, arg_index, arg_size, arg_value);
548 return ret;
551 cl_int WINAPI wine_clGetKernelInfo(cl_kernel kernel, cl_kernel_info param_name,
552 size_t param_value_size, void * param_value, size_t * param_value_size_ret)
554 cl_int ret;
555 TRACE("\n");
556 ret = clGetKernelInfo(kernel, param_name, param_value_size, param_value, param_value_size_ret);
557 return ret;
560 cl_int WINAPI wine_clGetKernelWorkGroupInfo(cl_kernel kernel, cl_device_id device,
561 cl_kernel_work_group_info param_name, size_t param_value_size,
562 void * param_value, size_t * param_value_size_ret)
564 cl_int ret;
565 TRACE("\n");
566 ret = clGetKernelWorkGroupInfo(kernel, device, param_name, param_value_size, param_value, param_value_size_ret);
567 return ret;
571 /*---------------------------------------------------------------*/
572 /* Event Object APIs */
574 cl_int WINAPI wine_clWaitForEvents(cl_uint num_events, cl_event * event_list)
576 cl_int ret;
577 TRACE("\n");
578 ret = clWaitForEvents(num_events, event_list);
579 return ret;
582 cl_int WINAPI wine_clGetEventInfo(cl_event event, cl_event_info param_name, size_t param_value_size,
583 void * param_value, size_t * param_value_size_ret)
585 cl_int ret;
586 TRACE("\n");
587 ret = clGetEventInfo(event, param_name, param_value_size, param_value, param_value_size_ret);
588 return ret;
591 cl_int WINAPI wine_clRetainEvent(cl_event event)
593 cl_int ret;
594 TRACE("\n");
595 ret = clRetainEvent(event);
596 return ret;
599 cl_int WINAPI wine_clReleaseEvent(cl_event event)
601 cl_int ret;
602 TRACE("\n");
603 ret = clReleaseEvent(event);
604 return ret;
608 /*---------------------------------------------------------------*/
609 /* Profiling APIs */
611 cl_int WINAPI wine_clGetEventProfilingInfo(cl_event event, cl_profiling_info param_name, size_t param_value_size,
612 void * param_value, size_t * param_value_size_ret)
614 cl_int ret;
615 TRACE("\n");
616 ret = clGetEventProfilingInfo(event, param_name, param_value_size, param_value, param_value_size_ret);
617 return ret;
621 /*---------------------------------------------------------------*/
622 /* Flush and Finish APIs */
624 cl_int WINAPI wine_clFlush(cl_command_queue command_queue)
626 cl_int ret;
627 TRACE("(%p)\n", command_queue);
628 ret = clFlush(command_queue);
629 TRACE("(%p)=%d\n", command_queue, ret);
630 return ret;
633 cl_int WINAPI wine_clFinish(cl_command_queue command_queue)
635 cl_int ret;
636 TRACE("(%p)\n", command_queue);
637 ret = clFinish(command_queue);
638 TRACE("(%p)=%d\n", command_queue, ret);
639 return ret;
643 /*---------------------------------------------------------------*/
644 /* Enqueued Commands APIs */
646 cl_int WINAPI wine_clEnqueueReadBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read,
647 size_t offset, size_t cb, void * ptr,
648 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
650 cl_int ret;
651 TRACE("\n");
652 ret = clEnqueueReadBuffer(command_queue, buffer, blocking_read, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event);
653 return ret;
656 cl_int WINAPI wine_clEnqueueWriteBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write,
657 size_t offset, size_t cb, const void * ptr,
658 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
660 cl_int ret;
661 TRACE("\n");
662 ret = clEnqueueWriteBuffer(command_queue, buffer, blocking_write, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event);
663 return ret;
666 cl_int WINAPI wine_clEnqueueCopyBuffer(cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer,
667 size_t src_offset, size_t dst_offset, size_t cb,
668 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
670 cl_int ret;
671 TRACE("\n");
672 ret = clEnqueueCopyBuffer(command_queue, src_buffer, dst_buffer, src_offset, dst_offset, cb, num_events_in_wait_list, event_wait_list, event);
673 return ret;
676 cl_int WINAPI wine_clEnqueueReadImage(cl_command_queue command_queue, cl_mem image, cl_bool blocking_read,
677 const size_t * origin, const size_t * region,
678 SIZE_T row_pitch, SIZE_T slice_pitch, void * ptr,
679 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
681 cl_int ret;
682 TRACE("(%p, %p, %d, %p, %p, %ld, %ld, %p, %d, %p, %p)\n", command_queue, image, blocking_read,
683 origin, region, row_pitch, slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event);
684 ret = clEnqueueReadImage(command_queue, image, blocking_read, origin, region, row_pitch, slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event);
685 TRACE("(%p, %p, %d, %p, %p, %ld, %ld, %p, %d, %p, %p)=%d\n", command_queue, image, blocking_read,
686 origin, region, row_pitch, slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event, ret);
687 return ret;
690 cl_int WINAPI wine_clEnqueueWriteImage(cl_command_queue command_queue, cl_mem image, cl_bool blocking_write,
691 const size_t * origin, const size_t * region,
692 size_t input_row_pitch, size_t input_slice_pitch, const void * ptr,
693 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
695 cl_int ret;
696 TRACE("\n");
697 ret = clEnqueueWriteImage(command_queue, image, blocking_write, origin, region, input_row_pitch, input_slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event);
698 return ret;
701 cl_int WINAPI wine_clEnqueueCopyImage(cl_command_queue command_queue, cl_mem src_image, cl_mem dst_image,
702 size_t * src_origin, size_t * dst_origin, size_t * region,
703 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
705 cl_int ret;
706 TRACE("\n");
707 ret = clEnqueueCopyImage(command_queue, src_image, dst_image, src_origin, dst_origin, region, num_events_in_wait_list, event_wait_list, event);
708 return ret;
711 cl_int WINAPI wine_clEnqueueCopyImageToBuffer(cl_command_queue command_queue, cl_mem src_image, cl_mem dst_buffer,
712 size_t * src_origin, size_t * region, size_t dst_offset,
713 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
715 cl_int ret;
716 TRACE("\n");
717 ret = clEnqueueCopyImageToBuffer(command_queue, src_image, dst_buffer, src_origin, region, dst_offset, num_events_in_wait_list, event_wait_list, event);
718 return ret;
721 cl_int WINAPI wine_clEnqueueCopyBufferToImage(cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_image,
722 size_t src_offset, size_t * dst_origin, size_t * region,
723 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
725 cl_int ret;
726 TRACE("\n");
727 ret = clEnqueueCopyBufferToImage(command_queue, src_buffer, dst_image, src_offset, dst_origin, region, num_events_in_wait_list, event_wait_list, event);
728 return ret;
731 void * WINAPI wine_clEnqueueMapBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map,
732 cl_map_flags map_flags, size_t offset, size_t cb,
733 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, cl_int * errcode_ret)
735 void * ret;
736 TRACE("\n");
737 ret = clEnqueueMapBuffer(command_queue, buffer, blocking_map, map_flags, offset, cb, num_events_in_wait_list, event_wait_list, event, errcode_ret);
738 return ret;
741 void * WINAPI wine_clEnqueueMapImage(cl_command_queue command_queue, cl_mem image, cl_bool blocking_map,
742 cl_map_flags map_flags, size_t * origin, size_t * region,
743 size_t * image_row_pitch, size_t * image_slice_pitch,
744 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, cl_int * errcode_ret)
746 void * ret;
747 TRACE("\n");
748 ret = clEnqueueMapImage(command_queue, image, blocking_map, map_flags, origin, region, image_row_pitch, image_slice_pitch, num_events_in_wait_list, event_wait_list, event, errcode_ret);
749 return ret;
752 cl_int WINAPI wine_clEnqueueUnmapMemObject(cl_command_queue command_queue, cl_mem memobj, void * mapped_ptr,
753 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
755 cl_int ret;
756 TRACE("\n");
757 ret = clEnqueueUnmapMemObject(command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event);
758 return ret;
761 cl_int WINAPI wine_clEnqueueNDRangeKernel(cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim,
762 size_t * global_work_offset, size_t * global_work_size, size_t * local_work_size,
763 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
765 cl_int ret;
766 TRACE("\n");
767 ret = clEnqueueNDRangeKernel(command_queue, kernel, work_dim, global_work_offset, global_work_size, local_work_size, num_events_in_wait_list, event_wait_list, event);
768 return ret;
771 cl_int WINAPI wine_clEnqueueTask(cl_command_queue command_queue, cl_kernel kernel,
772 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
774 cl_int ret;
775 TRACE("\n");
776 ret = clEnqueueTask(command_queue, kernel, num_events_in_wait_list, event_wait_list, event);
777 return ret;
780 cl_int WINAPI wine_clEnqueueNativeKernel(cl_command_queue command_queue,
781 void WINAPI (*user_func)(void *args),
782 void * args, size_t cb_args,
783 cl_uint num_mem_objects, const cl_mem * mem_list, const void ** args_mem_loc,
784 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
786 cl_int ret = CL_INVALID_OPERATION;
787 /* FIXME: There appears to be no obvious method for translating the ABI for user_func.
788 * There is no opaque user_data structure passed, that could encapsulate the return address.
789 * The OpenCL specification seems to indicate that args has an implementation specific
790 * structure that cannot be used to stash away a return address for the WINAPI user_func.
792 #if 0
793 ret = clEnqueueNativeKernel(command_queue, user_func, args, cb_args, num_mem_objects, mem_list, args_mem_loc,
794 num_events_in_wait_list, event_wait_list, event);
795 #else
796 FIXME("not supported due to user_func ABI mismatch\n");
797 #endif
798 return ret;
801 cl_int WINAPI wine_clEnqueueMarker(cl_command_queue command_queue, cl_event * event)
803 cl_int ret;
804 TRACE("\n");
805 ret = clEnqueueMarker(command_queue, event);
806 return ret;
809 cl_int WINAPI wine_clEnqueueWaitForEvents(cl_command_queue command_queue, cl_uint num_events, cl_event * event_list)
811 cl_int ret;
812 TRACE("\n");
813 ret = clEnqueueWaitForEvents(command_queue, num_events, event_list);
814 return ret;
817 cl_int WINAPI wine_clEnqueueBarrier(cl_command_queue command_queue)
819 cl_int ret;
820 TRACE("\n");
821 ret = clEnqueueBarrier(command_queue);
822 return ret;
826 /*---------------------------------------------------------------*/
827 /* Extension function access */
829 void * WINAPI wine_clGetExtensionFunctionAddress(const char * func_name)
831 void * ret = 0;
832 TRACE("(%s)\n",func_name);
833 #if 0
834 ret = clGetExtensionFunctionAddress(func_name);
835 #else
836 FIXME("extensions not implemented\n");
837 #endif
838 TRACE("(%s)=%p\n",func_name, ret);
839 return ret;
843 #if OPENCL_WITH_GL
844 /*---------------------------------------------------------------*/
845 /* Khronos-approved (KHR) OpenCL extensions which have OpenGL dependencies. */
847 cl_mem WINAPI wine_clCreateFromGLBuffer(cl_context context, cl_mem_flags flags, cl_GLuint bufobj, int * errcode_ret)
851 cl_mem WINAPI wine_clCreateFromGLTexture2D(cl_context context, cl_mem_flags flags, cl_GLenum target,
852 cl_GLint miplevel, cl_GLuint texture, cl_int * errcode_ret)
856 cl_mem WINAPI wine_clCreateFromGLTexture3D(cl_context context, cl_mem_flags flags, cl_GLenum target,
857 cl_GLint miplevel, cl_GLuint texture, cl_int * errcode_ret)
861 cl_mem WINAPI wine_clCreateFromGLRenderbuffer(cl_context context, cl_mem_flags flags, cl_GLuint renderbuffer, cl_int * errcode_ret)
865 cl_int WINAPI wine_clGetGLObjectInfo(cl_mem memobj, cl_gl_object_type * gl_object_type, cl_GLuint * gl_object_name)
869 cl_int WINAPI wine_clGetGLTextureInfo(cl_mem memobj, cl_gl_texture_info param_name, size_t param_value_size,
870 void * param_value, size_t * param_value_size_ret)
874 cl_int WINAPI wine_clEnqueueAcquireGLObjects(cl_command_queue command_queue, cl_uint num_objects, const cl_mem * mem_objects,
875 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
879 cl_int WINAPI wine_clEnqueueReleaseGLObjects(cl_command_queue command_queue, cl_uint num_objects, const cl_mem * mem_objects,
880 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
885 /*---------------------------------------------------------------*/
886 /* cl_khr_gl_sharing extension */
888 cl_int WINAPI wine_clGetGLContextInfoKHR(const cl_context_properties * properties, cl_gl_context_info param_name,
889 size_t param_value_size, void * param_value, size_t * param_value_size_ret)
893 #endif
896 #if 0
897 /*---------------------------------------------------------------*/
898 /* cl_khr_icd extension */
900 cl_int WINAPI wine_clIcdGetPlatformIDsKHR(cl_uint num_entries, cl_platform_id * platforms, cl_uint * num_platforms)
903 #endif