shell32/tests: Use GetShortPathNameA() directly in tests.
[wine.git] / dlls / opencl / opencl.c
blob7e680ba057f3eea76c2a116202313d01ce62c16f
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 #if defined(HAVE_CL_CL_H)
34 #define CL_USE_DEPRECATED_OPENCL_1_1_APIS
35 #define CL_USE_DEPRECATED_OPENCL_1_2_APIS
36 #define CL_USE_DEPRECATED_OPENCL_2_0_APIS
37 #define CL_TARGET_OPENCL_VERSION 220
38 #include <CL/cl.h>
39 #elif defined(HAVE_OPENCL_OPENCL_H)
40 #include <OpenCL/opencl.h>
41 #endif
43 /* TODO: Figure out how to provide GL context sharing before enabling OpenGL */
44 #define OPENCL_WITH_GL 0
47 /*---------------------------------------------------------------*/
48 /* Platform API */
50 cl_int WINAPI wine_clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms)
52 cl_int ret;
53 TRACE("(%d, %p, %p)\n", num_entries, platforms, num_platforms);
54 ret = clGetPlatformIDs(num_entries, platforms, num_platforms);
55 TRACE("(%d, %p, %p)=%d\n", num_entries, platforms, num_platforms, ret);
56 return ret;
59 cl_int WINAPI wine_clGetPlatformInfo(cl_platform_id platform, cl_platform_info param_name,
60 SIZE_T param_value_size, void * param_value, size_t * param_value_size_ret)
62 cl_int ret;
63 TRACE("(%p, 0x%x, %ld, %p, %p)\n", platform, param_name, param_value_size, param_value, param_value_size_ret);
65 /* Hide all extensions.
66 * TODO: Add individual extension support as needed.
68 if (param_name == CL_PLATFORM_EXTENSIONS)
70 ret = CL_INVALID_VALUE;
72 if (param_value && param_value_size > 0)
74 char *exts = (char *) param_value;
75 exts[0] = '\0';
76 ret = CL_SUCCESS;
79 if (param_value_size_ret)
81 *param_value_size_ret = 1;
82 ret = CL_SUCCESS;
85 else
87 ret = clGetPlatformInfo(platform, param_name, param_value_size, param_value, param_value_size_ret);
90 TRACE("(%p, 0x%x, %ld, %p, %p)=%d\n", platform, param_name, param_value_size, param_value, param_value_size_ret, ret);
91 return ret;
95 /*---------------------------------------------------------------*/
96 /* Device APIs */
98 cl_int WINAPI wine_clGetDeviceIDs(cl_platform_id platform, cl_device_type device_type,
99 cl_uint num_entries, cl_device_id * devices, cl_uint * num_devices)
101 cl_int ret;
102 TRACE("(%p, 0x%lx, %d, %p, %p)\n", platform, (long unsigned int)device_type, num_entries, devices, num_devices);
103 ret = clGetDeviceIDs(platform, device_type, num_entries, devices, num_devices);
104 TRACE("(%p, 0x%lx, %d, %p, %p)=%d\n", platform, (long unsigned int)device_type, num_entries, devices, num_devices, ret);
105 return ret;
108 cl_int WINAPI wine_clGetDeviceInfo(cl_device_id device, cl_device_info param_name,
109 SIZE_T param_value_size, void * param_value, size_t * param_value_size_ret)
111 cl_int ret;
112 TRACE("(%p, 0x%x, %ld, %p, %p)\n",device, param_name, param_value_size, param_value, param_value_size_ret);
114 /* Hide all extensions.
115 * TODO: Add individual extension support as needed.
117 if (param_name == CL_DEVICE_EXTENSIONS)
119 ret = CL_INVALID_VALUE;
121 if (param_value && param_value_size > 0)
123 char *exts = (char *) param_value;
124 exts[0] = '\0';
125 ret = CL_SUCCESS;
128 if (param_value_size_ret)
130 *param_value_size_ret = 1;
131 ret = CL_SUCCESS;
134 else
136 ret = clGetDeviceInfo(device, param_name, param_value_size, param_value, param_value_size_ret);
139 /* Filter out the CL_EXEC_NATIVE_KERNEL flag */
140 if (param_name == CL_DEVICE_EXECUTION_CAPABILITIES)
142 cl_device_exec_capabilities *caps = (cl_device_exec_capabilities *) param_value;
143 *caps &= ~CL_EXEC_NATIVE_KERNEL;
146 TRACE("(%p, 0x%x, %ld, %p, %p)=%d\n",device, param_name, param_value_size, param_value, param_value_size_ret, ret);
147 return ret;
151 /*---------------------------------------------------------------*/
152 /* Context APIs */
154 typedef struct
156 void WINAPI (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data);
157 void *user_data;
158 } CONTEXT_CALLBACK;
160 static void context_fn_notify(const char *errinfo, const void *private_info, size_t cb, void *user_data)
162 CONTEXT_CALLBACK *ccb;
163 TRACE("(%s, %p, %ld, %p)\n", errinfo, private_info, (SIZE_T)cb, user_data);
164 ccb = (CONTEXT_CALLBACK *) user_data;
165 if(ccb->pfn_notify) ccb->pfn_notify(errinfo, private_info, cb, ccb->user_data);
166 TRACE("Callback COMPLETED\n");
169 cl_context WINAPI wine_clCreateContext(const cl_context_properties * properties, cl_uint num_devices, const cl_device_id * devices,
170 void WINAPI (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data),
171 void * user_data, cl_int * errcode_ret)
173 cl_context ret;
174 CONTEXT_CALLBACK *ccb;
175 TRACE("(%p, %d, %p, %p, %p, %p)\n", properties, num_devices, devices, pfn_notify, user_data, errcode_ret);
176 /* FIXME: The CONTEXT_CALLBACK structure is currently leaked.
177 * Pointers to callback redirectors should be remembered and free()d when the context is destroyed.
178 * The problem is determining when a context is being destroyed. clReleaseContext only decrements
179 * the use count for a context, its destruction can come much later and therefore there is a risk
180 * that the callback could be invoked after the user_data memory has been free()d.
182 ccb = HeapAlloc(GetProcessHeap(), 0, sizeof(CONTEXT_CALLBACK));
183 ccb->pfn_notify = pfn_notify;
184 ccb->user_data = user_data;
185 ret = clCreateContext(properties, num_devices, devices, context_fn_notify, ccb, errcode_ret);
186 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);
187 return ret;
190 cl_context WINAPI wine_clCreateContextFromType(const cl_context_properties * properties, cl_device_type device_type,
191 void WINAPI (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data),
192 void * user_data, cl_int * errcode_ret)
194 cl_context ret;
195 CONTEXT_CALLBACK *ccb;
196 TRACE("(%p, 0x%lx, %p, %p, %p)\n", properties, (long unsigned int)device_type, pfn_notify, user_data, errcode_ret);
197 /* FIXME: The CONTEXT_CALLBACK structure is currently leaked.
198 * Pointers to callback redirectors should be remembered and free()d when the context is destroyed.
199 * The problem is determining when a context is being destroyed. clReleaseContext only decrements
200 * the use count for a context, its destruction can come much later and therefore there is a risk
201 * that the callback could be invoked after the user_data memory has been free()d.
203 ccb = HeapAlloc(GetProcessHeap(), 0, sizeof(CONTEXT_CALLBACK));
204 ccb->pfn_notify = pfn_notify;
205 ccb->user_data = user_data;
206 ret = clCreateContextFromType(properties, device_type, context_fn_notify, ccb, errcode_ret);
207 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);
208 return ret;
211 cl_int WINAPI wine_clRetainContext(cl_context context)
213 cl_int ret;
214 TRACE("(%p)\n", context);
215 ret = clRetainContext(context);
216 TRACE("(%p)=%d\n", context, ret);
217 return ret;
220 cl_int WINAPI wine_clReleaseContext(cl_context context)
222 cl_int ret;
223 TRACE("(%p)\n", context);
224 ret = clReleaseContext(context);
225 TRACE("(%p)=%d\n", context, ret);
226 return ret;
229 cl_int WINAPI wine_clGetContextInfo(cl_context context, cl_context_info param_name,
230 SIZE_T param_value_size, void * param_value, size_t * param_value_size_ret)
232 cl_int ret;
233 TRACE("(%p, 0x%x, %ld, %p, %p)\n", context, param_name, param_value_size, param_value, param_value_size_ret);
234 ret = clGetContextInfo(context, param_name, param_value_size, param_value, param_value_size_ret);
235 TRACE("(%p, 0x%x, %ld, %p, %p)=%d\n", context, param_name, param_value_size, param_value, param_value_size_ret, ret);
236 return ret;
240 /*---------------------------------------------------------------*/
241 /* Command Queue APIs */
243 cl_command_queue WINAPI wine_clCreateCommandQueue(cl_context context, cl_device_id device,
244 cl_command_queue_properties properties, cl_int * errcode_ret)
246 cl_command_queue ret;
247 TRACE("(%p, %p, 0x%lx, %p)\n", context, device, (long unsigned int)properties, errcode_ret);
248 ret = clCreateCommandQueue(context, device, properties, errcode_ret);
249 TRACE("(%p, %p, 0x%lx, %p)=%p\n", context, device, (long unsigned int)properties, errcode_ret, ret);
250 return ret;
253 cl_int WINAPI wine_clRetainCommandQueue(cl_command_queue command_queue)
255 cl_int ret;
256 TRACE("(%p)\n", command_queue);
257 ret = clRetainCommandQueue(command_queue);
258 TRACE("(%p)=%d\n", command_queue, ret);
259 return ret;
262 cl_int WINAPI wine_clReleaseCommandQueue(cl_command_queue command_queue)
264 cl_int ret;
265 TRACE("(%p)\n", command_queue);
266 ret = clReleaseCommandQueue(command_queue);
267 TRACE("(%p)=%d\n", command_queue, ret);
268 return ret;
271 cl_int WINAPI wine_clGetCommandQueueInfo(cl_command_queue command_queue, cl_command_queue_info param_name,
272 SIZE_T param_value_size, void * param_value, size_t * param_value_size_ret)
274 cl_int ret;
275 TRACE("%p, %d, %ld, %p, %p\n", command_queue, param_name, param_value_size, param_value, param_value_size_ret);
276 ret = clGetCommandQueueInfo(command_queue, param_name, param_value_size, param_value, param_value_size_ret);
277 return ret;
280 cl_int WINAPI wine_clSetCommandQueueProperty(cl_command_queue command_queue, cl_command_queue_properties properties, cl_bool enable,
281 cl_command_queue_properties * old_properties)
283 FIXME("(%p, 0x%lx, %d, %p): deprecated\n", command_queue, (long unsigned int)properties, enable, old_properties);
284 return CL_INVALID_QUEUE_PROPERTIES;
288 /*---------------------------------------------------------------*/
289 /* Memory Object APIs */
291 cl_mem WINAPI wine_clCreateBuffer(cl_context context, cl_mem_flags flags, size_t size, void * host_ptr, cl_int * errcode_ret)
293 cl_mem ret;
294 TRACE("\n");
295 ret = clCreateBuffer(context, flags, size, host_ptr, errcode_ret);
296 return ret;
299 cl_mem WINAPI wine_clCreateImage2D(cl_context context, cl_mem_flags flags, cl_image_format * image_format,
300 size_t image_width, size_t image_height, size_t image_row_pitch, void * host_ptr, cl_int * errcode_ret)
302 cl_mem ret;
303 TRACE("\n");
304 ret = clCreateImage2D(context, flags, image_format, image_width, image_height, image_row_pitch, host_ptr, errcode_ret);
305 return ret;
308 cl_mem WINAPI wine_clCreateImage3D(cl_context context, cl_mem_flags flags, cl_image_format * image_format,
309 size_t image_width, size_t image_height, size_t image_depth, size_t image_row_pitch, size_t image_slice_pitch,
310 void * host_ptr, cl_int * errcode_ret)
312 cl_mem ret;
313 TRACE("\n");
314 ret = clCreateImage3D(context, flags, image_format, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch, host_ptr, errcode_ret);
315 return ret;
318 cl_int WINAPI wine_clRetainMemObject(cl_mem memobj)
320 cl_int ret;
321 TRACE("(%p)\n", memobj);
322 ret = clRetainMemObject(memobj);
323 TRACE("(%p)=%d\n", memobj, ret);
324 return ret;
327 cl_int WINAPI wine_clReleaseMemObject(cl_mem memobj)
329 cl_int ret;
330 TRACE("(%p)\n", memobj);
331 ret = clReleaseMemObject(memobj);
332 TRACE("(%p)=%d\n", memobj, ret);
333 return ret;
336 cl_int WINAPI wine_clGetSupportedImageFormats(cl_context context, cl_mem_flags flags, cl_mem_object_type image_type, cl_uint num_entries,
337 cl_image_format * image_formats, cl_uint * num_image_formats)
339 cl_int ret;
340 TRACE("\n");
341 ret = clGetSupportedImageFormats(context, flags, image_type, num_entries, image_formats, num_image_formats);
342 return ret;
345 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)
347 cl_int ret;
348 TRACE("\n");
349 ret = clGetMemObjectInfo(memobj, param_name, param_value_size, param_value, param_value_size_ret);
350 return ret;
353 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)
355 cl_int ret;
356 TRACE("\n");
357 ret = clGetImageInfo(image, param_name, param_value_size, param_value, param_value_size_ret);
358 return ret;
362 /*---------------------------------------------------------------*/
363 /* Sampler APIs */
365 cl_sampler WINAPI wine_clCreateSampler(cl_context context, cl_bool normalized_coords, cl_addressing_mode addressing_mode,
366 cl_filter_mode filter_mode, cl_int * errcode_ret)
368 cl_sampler ret;
369 TRACE("\n");
370 ret = clCreateSampler(context, normalized_coords, addressing_mode, filter_mode, errcode_ret);
371 return ret;
374 cl_int WINAPI wine_clRetainSampler(cl_sampler sampler)
376 cl_int ret;
377 TRACE("\n");
378 ret = clRetainSampler(sampler);
379 return ret;
382 cl_int WINAPI wine_clReleaseSampler(cl_sampler sampler)
384 cl_int ret;
385 TRACE("\n");
386 ret = clReleaseSampler(sampler);
387 return ret;
390 cl_int WINAPI wine_clGetSamplerInfo(cl_sampler sampler, cl_sampler_info param_name, size_t param_value_size,
391 void * param_value, size_t * param_value_size_ret)
393 cl_int ret;
394 TRACE("\n");
395 ret = clGetSamplerInfo(sampler, param_name, param_value_size, param_value, param_value_size_ret);
396 return ret;
400 /*---------------------------------------------------------------*/
401 /* Program Object APIs */
403 cl_program WINAPI wine_clCreateProgramWithSource(cl_context context, cl_uint count, const char ** strings,
404 const size_t * lengths, cl_int * errcode_ret)
406 cl_program ret;
407 TRACE("\n");
408 ret = clCreateProgramWithSource(context, count, strings, lengths, errcode_ret);
409 return ret;
412 cl_program WINAPI wine_clCreateProgramWithBinary(cl_context context, cl_uint num_devices, const cl_device_id * device_list,
413 const size_t * lengths, const unsigned char ** binaries, cl_int * binary_status,
414 cl_int * errcode_ret)
416 cl_program ret;
417 TRACE("\n");
418 ret = clCreateProgramWithBinary(context, num_devices, device_list, lengths, binaries, binary_status, errcode_ret);
419 return ret;
422 cl_int WINAPI wine_clRetainProgram(cl_program program)
424 cl_int ret;
425 TRACE("\n");
426 ret = clRetainProgram(program);
427 return ret;
430 cl_int WINAPI wine_clReleaseProgram(cl_program program)
432 cl_int ret;
433 TRACE("\n");
434 ret = clReleaseProgram(program);
435 return ret;
438 typedef struct
440 void WINAPI (*pfn_notify)(cl_program program, void * user_data);
441 void *user_data;
442 } PROGRAM_CALLBACK;
444 static void program_fn_notify(cl_program program, void * user_data)
446 PROGRAM_CALLBACK *pcb;
447 TRACE("(%p, %p)\n", program, user_data);
448 pcb = (PROGRAM_CALLBACK *) user_data;
449 pcb->pfn_notify(program, pcb->user_data);
450 HeapFree(GetProcessHeap(), 0, pcb);
451 TRACE("Callback COMPLETED\n");
454 cl_int WINAPI wine_clBuildProgram(cl_program program, cl_uint num_devices, const cl_device_id * device_list, const char * options,
455 void WINAPI (*pfn_notify)(cl_program program, void * user_data),
456 void * user_data)
458 cl_int ret;
459 TRACE("\n");
460 if(pfn_notify)
462 /* When pfn_notify is provided, clBuildProgram is asynchronous */
463 PROGRAM_CALLBACK *pcb;
464 pcb = HeapAlloc(GetProcessHeap(), 0, sizeof(PROGRAM_CALLBACK));
465 pcb->pfn_notify = pfn_notify;
466 pcb->user_data = user_data;
467 ret = clBuildProgram(program, num_devices, device_list, options, program_fn_notify, pcb);
469 else
471 /* When pfn_notify is NULL, clBuildProgram is synchronous */
472 ret = clBuildProgram(program, num_devices, device_list, options, NULL, user_data);
474 return ret;
477 cl_int WINAPI wine_clUnloadCompiler(void)
479 cl_int ret;
480 TRACE("()\n");
481 ret = clUnloadCompiler();
482 TRACE("()=%d\n", ret);
483 return ret;
486 cl_int WINAPI wine_clGetProgramInfo(cl_program program, cl_program_info param_name,
487 size_t param_value_size, void * param_value, size_t * param_value_size_ret)
489 cl_int ret;
490 TRACE("\n");
491 ret = clGetProgramInfo(program, param_name, param_value_size, param_value, param_value_size_ret);
492 return ret;
495 cl_int WINAPI wine_clGetProgramBuildInfo(cl_program program, cl_device_id device,
496 cl_program_build_info param_name, size_t param_value_size, void * param_value,
497 size_t * param_value_size_ret)
499 cl_int ret;
500 TRACE("\n");
501 ret = clGetProgramBuildInfo(program, device, param_name, param_value_size, param_value, param_value_size_ret);
502 return ret;
506 /*---------------------------------------------------------------*/
507 /* Kernel Object APIs */
509 cl_kernel WINAPI wine_clCreateKernel(cl_program program, char * kernel_name, cl_int * errcode_ret)
511 cl_kernel ret;
512 TRACE("\n");
513 ret = clCreateKernel(program, kernel_name, errcode_ret);
514 return ret;
517 cl_int WINAPI wine_clCreateKernelsInProgram(cl_program program, cl_uint num_kernels,
518 cl_kernel * kernels, cl_uint * num_kernels_ret)
520 cl_int ret;
521 TRACE("\n");
522 ret = clCreateKernelsInProgram(program, num_kernels, kernels, num_kernels_ret);
523 return ret;
526 cl_int WINAPI wine_clRetainKernel(cl_kernel kernel)
528 cl_int ret;
529 TRACE("\n");
530 ret = clRetainKernel(kernel);
531 return ret;
534 cl_int WINAPI wine_clReleaseKernel(cl_kernel kernel)
536 cl_int ret;
537 TRACE("\n");
538 ret = clReleaseKernel(kernel);
539 return ret;
542 cl_int WINAPI wine_clSetKernelArg(cl_kernel kernel, cl_uint arg_index, size_t arg_size, void * arg_value)
544 cl_int ret;
545 TRACE("\n");
546 ret = clSetKernelArg(kernel, arg_index, arg_size, arg_value);
547 return ret;
550 cl_int WINAPI wine_clGetKernelInfo(cl_kernel kernel, cl_kernel_info param_name,
551 size_t param_value_size, void * param_value, size_t * param_value_size_ret)
553 cl_int ret;
554 TRACE("\n");
555 ret = clGetKernelInfo(kernel, param_name, param_value_size, param_value, param_value_size_ret);
556 return ret;
559 cl_int WINAPI wine_clGetKernelWorkGroupInfo(cl_kernel kernel, cl_device_id device,
560 cl_kernel_work_group_info param_name, size_t param_value_size,
561 void * param_value, size_t * param_value_size_ret)
563 cl_int ret;
564 TRACE("\n");
565 ret = clGetKernelWorkGroupInfo(kernel, device, param_name, param_value_size, param_value, param_value_size_ret);
566 return ret;
570 /*---------------------------------------------------------------*/
571 /* Event Object APIs */
573 cl_int WINAPI wine_clWaitForEvents(cl_uint num_events, cl_event * event_list)
575 cl_int ret;
576 TRACE("\n");
577 ret = clWaitForEvents(num_events, event_list);
578 return ret;
581 cl_int WINAPI wine_clGetEventInfo(cl_event event, cl_event_info param_name, size_t param_value_size,
582 void * param_value, size_t * param_value_size_ret)
584 cl_int ret;
585 TRACE("\n");
586 ret = clGetEventInfo(event, param_name, param_value_size, param_value, param_value_size_ret);
587 return ret;
590 cl_int WINAPI wine_clRetainEvent(cl_event event)
592 cl_int ret;
593 TRACE("\n");
594 ret = clRetainEvent(event);
595 return ret;
598 cl_int WINAPI wine_clReleaseEvent(cl_event event)
600 cl_int ret;
601 TRACE("\n");
602 ret = clReleaseEvent(event);
603 return ret;
607 /*---------------------------------------------------------------*/
608 /* Profiling APIs */
610 cl_int WINAPI wine_clGetEventProfilingInfo(cl_event event, cl_profiling_info param_name, size_t param_value_size,
611 void * param_value, size_t * param_value_size_ret)
613 cl_int ret;
614 TRACE("\n");
615 ret = clGetEventProfilingInfo(event, param_name, param_value_size, param_value, param_value_size_ret);
616 return ret;
620 /*---------------------------------------------------------------*/
621 /* Flush and Finish APIs */
623 cl_int WINAPI wine_clFlush(cl_command_queue command_queue)
625 cl_int ret;
626 TRACE("(%p)\n", command_queue);
627 ret = clFlush(command_queue);
628 TRACE("(%p)=%d\n", command_queue, ret);
629 return ret;
632 cl_int WINAPI wine_clFinish(cl_command_queue command_queue)
634 cl_int ret;
635 TRACE("(%p)\n", command_queue);
636 ret = clFinish(command_queue);
637 TRACE("(%p)=%d\n", command_queue, ret);
638 return ret;
642 /*---------------------------------------------------------------*/
643 /* Enqueued Commands APIs */
645 cl_int WINAPI wine_clEnqueueReadBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read,
646 size_t offset, size_t cb, void * ptr,
647 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
649 cl_int ret;
650 TRACE("\n");
651 ret = clEnqueueReadBuffer(command_queue, buffer, blocking_read, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event);
652 return ret;
655 cl_int WINAPI wine_clEnqueueWriteBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write,
656 size_t offset, size_t cb, const void * ptr,
657 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
659 cl_int ret;
660 TRACE("\n");
661 ret = clEnqueueWriteBuffer(command_queue, buffer, blocking_write, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event);
662 return ret;
665 cl_int WINAPI wine_clEnqueueCopyBuffer(cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer,
666 size_t src_offset, size_t dst_offset, size_t cb,
667 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
669 cl_int ret;
670 TRACE("\n");
671 ret = clEnqueueCopyBuffer(command_queue, src_buffer, dst_buffer, src_offset, dst_offset, cb, num_events_in_wait_list, event_wait_list, event);
672 return ret;
675 cl_int WINAPI wine_clEnqueueReadImage(cl_command_queue command_queue, cl_mem image, cl_bool blocking_read,
676 const size_t * origin, const size_t * region,
677 SIZE_T row_pitch, SIZE_T slice_pitch, void * ptr,
678 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
680 cl_int ret;
681 TRACE("(%p, %p, %d, %p, %p, %ld, %ld, %p, %d, %p, %p)\n", command_queue, image, blocking_read,
682 origin, region, row_pitch, slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event);
683 ret = clEnqueueReadImage(command_queue, image, blocking_read, origin, region, row_pitch, slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event);
684 TRACE("(%p, %p, %d, %p, %p, %ld, %ld, %p, %d, %p, %p)=%d\n", command_queue, image, blocking_read,
685 origin, region, row_pitch, slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event, ret);
686 return ret;
689 cl_int WINAPI wine_clEnqueueWriteImage(cl_command_queue command_queue, cl_mem image, cl_bool blocking_write,
690 const size_t * origin, const size_t * region,
691 size_t input_row_pitch, size_t input_slice_pitch, const void * ptr,
692 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
694 cl_int ret;
695 TRACE("\n");
696 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);
697 return ret;
700 cl_int WINAPI wine_clEnqueueCopyImage(cl_command_queue command_queue, cl_mem src_image, cl_mem dst_image,
701 size_t * src_origin, size_t * dst_origin, size_t * region,
702 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
704 cl_int ret;
705 TRACE("\n");
706 ret = clEnqueueCopyImage(command_queue, src_image, dst_image, src_origin, dst_origin, region, num_events_in_wait_list, event_wait_list, event);
707 return ret;
710 cl_int WINAPI wine_clEnqueueCopyImageToBuffer(cl_command_queue command_queue, cl_mem src_image, cl_mem dst_buffer,
711 size_t * src_origin, size_t * region, size_t dst_offset,
712 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
714 cl_int ret;
715 TRACE("\n");
716 ret = clEnqueueCopyImageToBuffer(command_queue, src_image, dst_buffer, src_origin, region, dst_offset, num_events_in_wait_list, event_wait_list, event);
717 return ret;
720 cl_int WINAPI wine_clEnqueueCopyBufferToImage(cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_image,
721 size_t src_offset, size_t * dst_origin, size_t * region,
722 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
724 cl_int ret;
725 TRACE("\n");
726 ret = clEnqueueCopyBufferToImage(command_queue, src_buffer, dst_image, src_offset, dst_origin, region, num_events_in_wait_list, event_wait_list, event);
727 return ret;
730 void * WINAPI wine_clEnqueueMapBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map,
731 cl_map_flags map_flags, size_t offset, size_t cb,
732 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, cl_int * errcode_ret)
734 void * ret;
735 TRACE("\n");
736 ret = clEnqueueMapBuffer(command_queue, buffer, blocking_map, map_flags, offset, cb, num_events_in_wait_list, event_wait_list, event, errcode_ret);
737 return ret;
740 void * WINAPI wine_clEnqueueMapImage(cl_command_queue command_queue, cl_mem image, cl_bool blocking_map,
741 cl_map_flags map_flags, size_t * origin, size_t * region,
742 size_t * image_row_pitch, size_t * image_slice_pitch,
743 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, cl_int * errcode_ret)
745 void * ret;
746 TRACE("\n");
747 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);
748 return ret;
751 cl_int WINAPI wine_clEnqueueUnmapMemObject(cl_command_queue command_queue, cl_mem memobj, void * mapped_ptr,
752 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
754 cl_int ret;
755 TRACE("\n");
756 ret = clEnqueueUnmapMemObject(command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event);
757 return ret;
760 cl_int WINAPI wine_clEnqueueNDRangeKernel(cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim,
761 size_t * global_work_offset, size_t * global_work_size, size_t * local_work_size,
762 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
764 cl_int ret;
765 TRACE("\n");
766 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);
767 return ret;
770 cl_int WINAPI wine_clEnqueueTask(cl_command_queue command_queue, cl_kernel kernel,
771 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
773 cl_int ret;
774 TRACE("\n");
775 ret = clEnqueueTask(command_queue, kernel, num_events_in_wait_list, event_wait_list, event);
776 return ret;
779 cl_int WINAPI wine_clEnqueueNativeKernel(cl_command_queue command_queue,
780 void WINAPI (*user_func)(void *args),
781 void * args, size_t cb_args,
782 cl_uint num_mem_objects, const cl_mem * mem_list, const void ** args_mem_loc,
783 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
785 cl_int ret = CL_INVALID_OPERATION;
786 /* FIXME: There appears to be no obvious method for translating the ABI for user_func.
787 * There is no opaque user_data structure passed, that could encapsulate the return address.
788 * The OpenCL specification seems to indicate that args has an implementation specific
789 * structure that cannot be used to stash away a return address for the WINAPI user_func.
791 #if 0
792 ret = clEnqueueNativeKernel(command_queue, user_func, args, cb_args, num_mem_objects, mem_list, args_mem_loc,
793 num_events_in_wait_list, event_wait_list, event);
794 #else
795 FIXME("not supported due to user_func ABI mismatch\n");
796 #endif
797 return ret;
800 cl_int WINAPI wine_clEnqueueMarker(cl_command_queue command_queue, cl_event * event)
802 cl_int ret;
803 TRACE("\n");
804 ret = clEnqueueMarker(command_queue, event);
805 return ret;
808 cl_int WINAPI wine_clEnqueueWaitForEvents(cl_command_queue command_queue, cl_uint num_events, cl_event * event_list)
810 cl_int ret;
811 TRACE("\n");
812 ret = clEnqueueWaitForEvents(command_queue, num_events, event_list);
813 return ret;
816 cl_int WINAPI wine_clEnqueueBarrier(cl_command_queue command_queue)
818 cl_int ret;
819 TRACE("\n");
820 ret = clEnqueueBarrier(command_queue);
821 return ret;
825 /*---------------------------------------------------------------*/
826 /* Extension function access */
828 void * WINAPI wine_clGetExtensionFunctionAddress(const char * func_name)
830 void * ret = 0;
831 TRACE("(%s)\n",func_name);
832 #if 0
833 ret = clGetExtensionFunctionAddress(func_name);
834 #else
835 FIXME("extensions not implemented\n");
836 #endif
837 TRACE("(%s)=%p\n",func_name, ret);
838 return ret;
842 #if OPENCL_WITH_GL
843 /*---------------------------------------------------------------*/
844 /* Khronos-approved (KHR) OpenCL extensions which have OpenGL dependencies. */
846 cl_mem WINAPI wine_clCreateFromGLBuffer(cl_context context, cl_mem_flags flags, cl_GLuint bufobj, int * errcode_ret)
850 cl_mem WINAPI wine_clCreateFromGLTexture2D(cl_context context, cl_mem_flags flags, cl_GLenum target,
851 cl_GLint miplevel, cl_GLuint texture, cl_int * errcode_ret)
855 cl_mem WINAPI wine_clCreateFromGLTexture3D(cl_context context, cl_mem_flags flags, cl_GLenum target,
856 cl_GLint miplevel, cl_GLuint texture, cl_int * errcode_ret)
860 cl_mem WINAPI wine_clCreateFromGLRenderbuffer(cl_context context, cl_mem_flags flags, cl_GLuint renderbuffer, cl_int * errcode_ret)
864 cl_int WINAPI wine_clGetGLObjectInfo(cl_mem memobj, cl_gl_object_type * gl_object_type, cl_GLuint * gl_object_name)
868 cl_int WINAPI wine_clGetGLTextureInfo(cl_mem memobj, cl_gl_texture_info param_name, size_t param_value_size,
869 void * param_value, size_t * param_value_size_ret)
873 cl_int WINAPI wine_clEnqueueAcquireGLObjects(cl_command_queue command_queue, cl_uint num_objects, const cl_mem * mem_objects,
874 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
878 cl_int WINAPI wine_clEnqueueReleaseGLObjects(cl_command_queue command_queue, cl_uint num_objects, const cl_mem * mem_objects,
879 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
884 /*---------------------------------------------------------------*/
885 /* cl_khr_gl_sharing extension */
887 cl_int WINAPI wine_clGetGLContextInfoKHR(const cl_context_properties * properties, cl_gl_context_info param_name,
888 size_t param_value_size, void * param_value, size_t * param_value_size_ret)
892 #endif
895 #if 0
896 /*---------------------------------------------------------------*/
897 /* cl_khr_icd extension */
899 cl_int WINAPI wine_clIcdGetPlatformIDsKHR(cl_uint num_entries, cl_platform_id * platforms, cl_uint * num_platforms)
902 #endif