d3d8: Get rid of the format switching code in d3d8_device_CopyRects().
[wine.git] / dlls / opencl / opencl.c
blobc3d25b59ccbae48c7b4f8e065d1a0e72b246b710
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 #include <CL/cl.h>
36 #elif defined(HAVE_OPENCL_OPENCL_H)
37 #include <OpenCL/opencl.h>
38 #endif
40 /* TODO: Figure out how to provide GL context sharing before enabling OpenGL */
41 #define OPENCL_WITH_GL 0
44 /*---------------------------------------------------------------*/
45 /* Platform API */
47 cl_int WINAPI wine_clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms)
49 cl_int ret;
50 TRACE("(%d, %p, %p)\n", num_entries, platforms, num_platforms);
51 ret = clGetPlatformIDs(num_entries, platforms, num_platforms);
52 TRACE("(%d, %p, %p)=%d\n", num_entries, platforms, num_platforms, ret);
53 return ret;
56 cl_int WINAPI wine_clGetPlatformInfo(cl_platform_id platform, cl_platform_info param_name,
57 SIZE_T param_value_size, void * param_value, size_t * param_value_size_ret)
59 cl_int ret;
60 TRACE("(%p, 0x%x, %ld, %p, %p)\n", platform, param_name, param_value_size, param_value, param_value_size_ret);
62 /* Hide all extensions.
63 * TODO: Add individual extension support as needed.
65 if (param_name == CL_PLATFORM_EXTENSIONS)
67 ret = CL_INVALID_VALUE;
69 if (param_value && param_value_size > 0)
71 char *exts = (char *) param_value;
72 exts[0] = '\0';
73 ret = CL_SUCCESS;
76 if (param_value_size_ret)
78 *param_value_size_ret = 1;
79 ret = CL_SUCCESS;
82 else
84 ret = clGetPlatformInfo(platform, param_name, param_value_size, param_value, param_value_size_ret);
87 TRACE("(%p, 0x%x, %ld, %p, %p)=%d\n", platform, param_name, param_value_size, param_value, param_value_size_ret, ret);
88 return ret;
92 /*---------------------------------------------------------------*/
93 /* Device APIs */
95 cl_int WINAPI wine_clGetDeviceIDs(cl_platform_id platform, cl_device_type device_type,
96 cl_uint num_entries, cl_device_id * devices, cl_uint * num_devices)
98 cl_int ret;
99 TRACE("(%p, 0x%lx, %d, %p, %p)\n", platform, (long unsigned int)device_type, num_entries, devices, num_devices);
100 ret = clGetDeviceIDs(platform, device_type, num_entries, devices, num_devices);
101 TRACE("(%p, 0x%lx, %d, %p, %p)=%d\n", platform, (long unsigned int)device_type, num_entries, devices, num_devices, ret);
102 return ret;
105 cl_int WINAPI wine_clGetDeviceInfo(cl_device_id device, cl_device_info param_name,
106 SIZE_T param_value_size, void * param_value, size_t * param_value_size_ret)
108 cl_int ret;
109 TRACE("(%p, 0x%x, %ld, %p, %p)\n",device, param_name, param_value_size, param_value, param_value_size_ret);
111 /* Hide all extensions.
112 * TODO: Add individual extension support as needed.
114 if (param_name == CL_DEVICE_EXTENSIONS)
116 ret = CL_INVALID_VALUE;
118 if (param_value && param_value_size > 0)
120 char *exts = (char *) param_value;
121 exts[0] = '\0';
122 ret = CL_SUCCESS;
125 if (param_value_size_ret)
127 *param_value_size_ret = 1;
128 ret = CL_SUCCESS;
131 else
133 ret = clGetDeviceInfo(device, param_name, param_value_size, param_value, param_value_size_ret);
136 /* Filter out the CL_EXEC_NATIVE_KERNEL flag */
137 if (param_name == CL_DEVICE_EXECUTION_CAPABILITIES)
139 cl_device_exec_capabilities *caps = (cl_device_exec_capabilities *) param_value;
140 *caps &= ~CL_EXEC_NATIVE_KERNEL;
143 TRACE("(%p, 0x%x, %ld, %p, %p)=%d\n",device, param_name, param_value_size, param_value, param_value_size_ret, ret);
144 return ret;
148 /*---------------------------------------------------------------*/
149 /* Context APIs */
151 typedef struct
153 void WINAPI (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data);
154 void *user_data;
155 } CONTEXT_CALLBACK;
157 static void context_fn_notify(const char *errinfo, const void *private_info, size_t cb, void *user_data)
159 CONTEXT_CALLBACK *ccb;
160 TRACE("(%s, %p, %ld, %p)\n", errinfo, private_info, (SIZE_T)cb, user_data);
161 ccb = (CONTEXT_CALLBACK *) user_data;
162 if(ccb->pfn_notify) ccb->pfn_notify(errinfo, private_info, cb, ccb->user_data);
163 TRACE("Callback COMPLETED\n");
166 cl_context WINAPI wine_clCreateContext(const cl_context_properties * properties, cl_uint num_devices, const cl_device_id * devices,
167 void WINAPI (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data),
168 void * user_data, cl_int * errcode_ret)
170 cl_context ret;
171 CONTEXT_CALLBACK *ccb;
172 TRACE("(%p, %d, %p, %p, %p, %p)\n", properties, num_devices, devices, pfn_notify, user_data, errcode_ret);
173 /* FIXME: The CONTEXT_CALLBACK structure is currently leaked.
174 * Pointers to callback redirectors should be remembered and free()d when the context is destroyed.
175 * The problem is determining when a context is being destroyed. clReleaseContext only decrements
176 * the use count for a context, its destruction can come much later and therefore there is a risk
177 * that the callback could be invoked after the user_data memory has been free()d.
179 ccb = HeapAlloc(GetProcessHeap(), 0, sizeof(CONTEXT_CALLBACK));
180 ccb->pfn_notify = pfn_notify;
181 ccb->user_data = user_data;
182 ret = clCreateContext(properties, num_devices, devices, context_fn_notify, ccb, errcode_ret);
183 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);
184 return ret;
187 cl_context WINAPI wine_clCreateContextFromType(const cl_context_properties * properties, cl_device_type device_type,
188 void WINAPI (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data),
189 void * user_data, cl_int * errcode_ret)
191 cl_context ret;
192 CONTEXT_CALLBACK *ccb;
193 TRACE("(%p, 0x%lx, %p, %p, %p)\n", properties, (long unsigned int)device_type, pfn_notify, user_data, errcode_ret);
194 /* FIXME: The CONTEXT_CALLBACK structure is currently leaked.
195 * Pointers to callback redirectors should be remembered and free()d when the context is destroyed.
196 * The problem is determining when a context is being destroyed. clReleaseContext only decrements
197 * the use count for a context, its destruction can come much later and therefore there is a risk
198 * that the callback could be invoked after the user_data memory has been free()d.
200 ccb = HeapAlloc(GetProcessHeap(), 0, sizeof(CONTEXT_CALLBACK));
201 ccb->pfn_notify = pfn_notify;
202 ccb->user_data = user_data;
203 ret = clCreateContextFromType(properties, device_type, context_fn_notify, ccb, errcode_ret);
204 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);
205 return ret;
208 cl_int WINAPI wine_clRetainContext(cl_context context)
210 cl_int ret;
211 TRACE("(%p)\n", context);
212 ret = clRetainContext(context);
213 TRACE("(%p)=%d\n", context, ret);
214 return ret;
217 cl_int WINAPI wine_clReleaseContext(cl_context context)
219 cl_int ret;
220 TRACE("(%p)\n", context);
221 ret = clReleaseContext(context);
222 TRACE("(%p)=%d\n", context, ret);
223 return ret;
226 cl_int WINAPI wine_clGetContextInfo(cl_context context, cl_context_info param_name,
227 SIZE_T param_value_size, void * param_value, size_t * param_value_size_ret)
229 cl_int ret;
230 TRACE("(%p, 0x%x, %ld, %p, %p)\n", context, param_name, param_value_size, param_value, param_value_size_ret);
231 ret = clGetContextInfo(context, param_name, param_value_size, param_value, param_value_size_ret);
232 TRACE("(%p, 0x%x, %ld, %p, %p)=%d\n", context, param_name, param_value_size, param_value, param_value_size_ret, ret);
233 return ret;
237 /*---------------------------------------------------------------*/
238 /* Command Queue APIs */
240 cl_command_queue WINAPI wine_clCreateCommandQueue(cl_context context, cl_device_id device,
241 cl_command_queue_properties properties, cl_int * errcode_ret)
243 cl_command_queue ret;
244 TRACE("(%p, %p, 0x%lx, %p)\n", context, device, (long unsigned int)properties, errcode_ret);
245 ret = clCreateCommandQueue(context, device, properties, errcode_ret);
246 TRACE("(%p, %p, 0x%lx, %p)=%p\n", context, device, (long unsigned int)properties, errcode_ret, ret);
247 return ret;
250 cl_int WINAPI wine_clRetainCommandQueue(cl_command_queue command_queue)
252 cl_int ret;
253 TRACE("(%p)\n", command_queue);
254 ret = clRetainCommandQueue(command_queue);
255 TRACE("(%p)=%d\n", command_queue, ret);
256 return ret;
259 cl_int WINAPI wine_clReleaseCommandQueue(cl_command_queue command_queue)
261 cl_int ret;
262 TRACE("(%p)\n", command_queue);
263 ret = clReleaseCommandQueue(command_queue);
264 TRACE("(%p)=%d\n", command_queue, ret);
265 return ret;
268 cl_int WINAPI wine_clGetCommandQueueInfo(cl_command_queue command_queue, cl_command_queue_info param_name,
269 SIZE_T param_value_size, void * param_value, size_t * param_value_size_ret)
271 cl_int ret;
272 TRACE("%p, %d, %ld, %p, %p\n", command_queue, param_name, param_value_size, param_value, param_value_size_ret);
273 ret = clGetCommandQueueInfo(command_queue, param_name, param_value_size, param_value, param_value_size_ret);
274 return ret;
277 cl_int WINAPI wine_clSetCommandQueueProperty(cl_command_queue command_queue, cl_command_queue_properties properties, cl_bool enable,
278 cl_command_queue_properties * old_properties)
280 FIXME("(%p, 0x%lx, %d, %p): deprecated\n", command_queue, (long unsigned int)properties, enable, old_properties);
281 return CL_INVALID_QUEUE_PROPERTIES;
285 /*---------------------------------------------------------------*/
286 /* Memory Object APIs */
288 cl_mem WINAPI wine_clCreateBuffer(cl_context context, cl_mem_flags flags, size_t size, void * host_ptr, cl_int * errcode_ret)
290 cl_mem ret;
291 TRACE("\n");
292 ret = clCreateBuffer(context, flags, size, host_ptr, errcode_ret);
293 return ret;
296 cl_mem WINAPI wine_clCreateImage2D(cl_context context, cl_mem_flags flags, cl_image_format * image_format,
297 size_t image_width, size_t image_height, size_t image_row_pitch, void * host_ptr, cl_int * errcode_ret)
299 cl_mem ret;
300 TRACE("\n");
301 ret = clCreateImage2D(context, flags, image_format, image_width, image_height, image_row_pitch, host_ptr, errcode_ret);
302 return ret;
305 cl_mem WINAPI wine_clCreateImage3D(cl_context context, cl_mem_flags flags, cl_image_format * image_format,
306 size_t image_width, size_t image_height, size_t image_depth, size_t image_row_pitch, size_t image_slice_pitch,
307 void * host_ptr, cl_int * errcode_ret)
309 cl_mem ret;
310 TRACE("\n");
311 ret = clCreateImage3D(context, flags, image_format, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch, host_ptr, errcode_ret);
312 return ret;
315 cl_int WINAPI wine_clRetainMemObject(cl_mem memobj)
317 cl_int ret;
318 TRACE("(%p)\n", memobj);
319 ret = clRetainMemObject(memobj);
320 TRACE("(%p)=%d\n", memobj, ret);
321 return ret;
324 cl_int WINAPI wine_clReleaseMemObject(cl_mem memobj)
326 cl_int ret;
327 TRACE("(%p)\n", memobj);
328 ret = clReleaseMemObject(memobj);
329 TRACE("(%p)=%d\n", memobj, ret);
330 return ret;
333 cl_int WINAPI wine_clGetSupportedImageFormats(cl_context context, cl_mem_flags flags, cl_mem_object_type image_type, cl_uint num_entries,
334 cl_image_format * image_formats, cl_uint * num_image_formats)
336 cl_int ret;
337 TRACE("\n");
338 ret = clGetSupportedImageFormats(context, flags, image_type, num_entries, image_formats, num_image_formats);
339 return ret;
342 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)
344 cl_int ret;
345 TRACE("\n");
346 ret = clGetMemObjectInfo(memobj, param_name, param_value_size, param_value, param_value_size_ret);
347 return ret;
350 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)
352 cl_int ret;
353 TRACE("\n");
354 ret = clGetImageInfo(image, param_name, param_value_size, param_value, param_value_size_ret);
355 return ret;
359 /*---------------------------------------------------------------*/
360 /* Sampler APIs */
362 cl_sampler WINAPI wine_clCreateSampler(cl_context context, cl_bool normalized_coords, cl_addressing_mode addressing_mode,
363 cl_filter_mode filter_mode, cl_int * errcode_ret)
365 cl_sampler ret;
366 TRACE("\n");
367 ret = clCreateSampler(context, normalized_coords, addressing_mode, filter_mode, errcode_ret);
368 return ret;
371 cl_int WINAPI wine_clRetainSampler(cl_sampler sampler)
373 cl_int ret;
374 TRACE("\n");
375 ret = clRetainSampler(sampler);
376 return ret;
379 cl_int WINAPI wine_clReleaseSampler(cl_sampler sampler)
381 cl_int ret;
382 TRACE("\n");
383 ret = clReleaseSampler(sampler);
384 return ret;
387 cl_int WINAPI wine_clGetSamplerInfo(cl_sampler sampler, cl_sampler_info param_name, size_t param_value_size,
388 void * param_value, size_t * param_value_size_ret)
390 cl_int ret;
391 TRACE("\n");
392 ret = clGetSamplerInfo(sampler, param_name, param_value_size, param_value, param_value_size_ret);
393 return ret;
397 /*---------------------------------------------------------------*/
398 /* Program Object APIs */
400 cl_program WINAPI wine_clCreateProgramWithSource(cl_context context, cl_uint count, const char ** strings,
401 const size_t * lengths, cl_int * errcode_ret)
403 cl_program ret;
404 TRACE("\n");
405 ret = clCreateProgramWithSource(context, count, strings, lengths, errcode_ret);
406 return ret;
409 cl_program WINAPI wine_clCreateProgramWithBinary(cl_context context, cl_uint num_devices, const cl_device_id * device_list,
410 const size_t * lengths, const unsigned char ** binaries, cl_int * binary_status,
411 cl_int * errcode_ret)
413 cl_program ret;
414 TRACE("\n");
415 ret = clCreateProgramWithBinary(context, num_devices, device_list, lengths, binaries, binary_status, errcode_ret);
416 return ret;
419 cl_int WINAPI wine_clRetainProgram(cl_program program)
421 cl_int ret;
422 TRACE("\n");
423 ret = clRetainProgram(program);
424 return ret;
427 cl_int WINAPI wine_clReleaseProgram(cl_program program)
429 cl_int ret;
430 TRACE("\n");
431 ret = clReleaseProgram(program);
432 return ret;
435 typedef struct
437 void WINAPI (*pfn_notify)(cl_program program, void * user_data);
438 void *user_data;
439 } PROGRAM_CALLBACK;
441 static void program_fn_notify(cl_program program, void * user_data)
443 PROGRAM_CALLBACK *pcb;
444 TRACE("(%p, %p)\n", program, user_data);
445 pcb = (PROGRAM_CALLBACK *) user_data;
446 pcb->pfn_notify(program, pcb->user_data);
447 HeapFree(GetProcessHeap(), 0, pcb);
448 TRACE("Callback COMPLETED\n");
451 cl_int WINAPI wine_clBuildProgram(cl_program program, cl_uint num_devices, const cl_device_id * device_list, const char * options,
452 void WINAPI (*pfn_notify)(cl_program program, void * user_data),
453 void * user_data)
455 cl_int ret;
456 TRACE("\n");
457 if(pfn_notify)
459 /* When pfn_notify is provided, clBuildProgram is asynchronous */
460 PROGRAM_CALLBACK *pcb;
461 pcb = HeapAlloc(GetProcessHeap(), 0, sizeof(PROGRAM_CALLBACK));
462 pcb->pfn_notify = pfn_notify;
463 pcb->user_data = user_data;
464 ret = clBuildProgram(program, num_devices, device_list, options, program_fn_notify, pcb);
466 else
468 /* When pfn_notify is NULL, clBuildProgram is synchronous */
469 ret = clBuildProgram(program, num_devices, device_list, options, NULL, user_data);
471 return ret;
474 cl_int WINAPI wine_clUnloadCompiler(void)
476 cl_int ret;
477 TRACE("()\n");
478 ret = clUnloadCompiler();
479 TRACE("()=%d\n", ret);
480 return ret;
483 cl_int WINAPI wine_clGetProgramInfo(cl_program program, cl_program_info param_name,
484 size_t param_value_size, void * param_value, size_t * param_value_size_ret)
486 cl_int ret;
487 TRACE("\n");
488 ret = clGetProgramInfo(program, param_name, param_value_size, param_value, param_value_size_ret);
489 return ret;
492 cl_int WINAPI wine_clGetProgramBuildInfo(cl_program program, cl_device_id device,
493 cl_program_build_info param_name, size_t param_value_size, void * param_value,
494 size_t * param_value_size_ret)
496 cl_int ret;
497 TRACE("\n");
498 ret = clGetProgramBuildInfo(program, device, param_name, param_value_size, param_value, param_value_size_ret);
499 return ret;
503 /*---------------------------------------------------------------*/
504 /* Kernel Object APIs */
506 cl_kernel WINAPI wine_clCreateKernel(cl_program program, char * kernel_name, cl_int * errcode_ret)
508 cl_kernel ret;
509 TRACE("\n");
510 ret = clCreateKernel(program, kernel_name, errcode_ret);
511 return ret;
514 cl_int WINAPI wine_clCreateKernelsInProgram(cl_program program, cl_uint num_kernels,
515 cl_kernel * kernels, cl_uint * num_kernels_ret)
517 cl_int ret;
518 TRACE("\n");
519 ret = clCreateKernelsInProgram(program, num_kernels, kernels, num_kernels_ret);
520 return ret;
523 cl_int WINAPI wine_clRetainKernel(cl_kernel kernel)
525 cl_int ret;
526 TRACE("\n");
527 ret = clRetainKernel(kernel);
528 return ret;
531 cl_int WINAPI wine_clReleaseKernel(cl_kernel kernel)
533 cl_int ret;
534 TRACE("\n");
535 ret = clReleaseKernel(kernel);
536 return ret;
539 cl_int WINAPI wine_clSetKernelArg(cl_kernel kernel, cl_uint arg_index, size_t arg_size, void * arg_value)
541 cl_int ret;
542 TRACE("\n");
543 ret = clSetKernelArg(kernel, arg_index, arg_size, arg_value);
544 return ret;
547 cl_int WINAPI wine_clGetKernelInfo(cl_kernel kernel, cl_kernel_info param_name,
548 size_t param_value_size, void * param_value, size_t * param_value_size_ret)
550 cl_int ret;
551 TRACE("\n");
552 ret = clGetKernelInfo(kernel, param_name, param_value_size, param_value, param_value_size_ret);
553 return ret;
556 cl_int WINAPI wine_clGetKernelWorkGroupInfo(cl_kernel kernel, cl_device_id device,
557 cl_kernel_work_group_info param_name, size_t param_value_size,
558 void * param_value, size_t * param_value_size_ret)
560 cl_int ret;
561 TRACE("\n");
562 ret = clGetKernelWorkGroupInfo(kernel, device, param_name, param_value_size, param_value, param_value_size_ret);
563 return ret;
567 /*---------------------------------------------------------------*/
568 /* Event Object APIs */
570 cl_int WINAPI wine_clWaitForEvents(cl_uint num_events, cl_event * event_list)
572 cl_int ret;
573 TRACE("\n");
574 ret = clWaitForEvents(num_events, event_list);
575 return ret;
578 cl_int WINAPI wine_clGetEventInfo(cl_event event, cl_event_info param_name, size_t param_value_size,
579 void * param_value, size_t * param_value_size_ret)
581 cl_int ret;
582 TRACE("\n");
583 ret = clGetEventInfo(event, param_name, param_value_size, param_value, param_value_size_ret);
584 return ret;
587 cl_int WINAPI wine_clRetainEvent(cl_event event)
589 cl_int ret;
590 TRACE("\n");
591 ret = clRetainEvent(event);
592 return ret;
595 cl_int WINAPI wine_clReleaseEvent(cl_event event)
597 cl_int ret;
598 TRACE("\n");
599 ret = clReleaseEvent(event);
600 return ret;
604 /*---------------------------------------------------------------*/
605 /* Profiling APIs */
607 cl_int WINAPI wine_clGetEventProfilingInfo(cl_event event, cl_profiling_info param_name, size_t param_value_size,
608 void * param_value, size_t * param_value_size_ret)
610 cl_int ret;
611 TRACE("\n");
612 ret = clGetEventProfilingInfo(event, param_name, param_value_size, param_value, param_value_size_ret);
613 return ret;
617 /*---------------------------------------------------------------*/
618 /* Flush and Finish APIs */
620 cl_int WINAPI wine_clFlush(cl_command_queue command_queue)
622 cl_int ret;
623 TRACE("(%p)\n", command_queue);
624 ret = clFlush(command_queue);
625 TRACE("(%p)=%d\n", command_queue, ret);
626 return ret;
629 cl_int WINAPI wine_clFinish(cl_command_queue command_queue)
631 cl_int ret;
632 TRACE("(%p)\n", command_queue);
633 ret = clFinish(command_queue);
634 TRACE("(%p)=%d\n", command_queue, ret);
635 return ret;
639 /*---------------------------------------------------------------*/
640 /* Enqueued Commands APIs */
642 cl_int WINAPI wine_clEnqueueReadBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read,
643 size_t offset, size_t cb, void * ptr,
644 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
646 cl_int ret;
647 TRACE("\n");
648 ret = clEnqueueReadBuffer(command_queue, buffer, blocking_read, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event);
649 return ret;
652 cl_int WINAPI wine_clEnqueueWriteBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write,
653 size_t offset, size_t cb, const void * ptr,
654 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
656 cl_int ret;
657 TRACE("\n");
658 ret = clEnqueueWriteBuffer(command_queue, buffer, blocking_write, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event);
659 return ret;
662 cl_int WINAPI wine_clEnqueueCopyBuffer(cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer,
663 size_t src_offset, size_t dst_offset, size_t cb,
664 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
666 cl_int ret;
667 TRACE("\n");
668 ret = clEnqueueCopyBuffer(command_queue, src_buffer, dst_buffer, src_offset, dst_offset, cb, num_events_in_wait_list, event_wait_list, event);
669 return ret;
672 cl_int WINAPI wine_clEnqueueReadImage(cl_command_queue command_queue, cl_mem image, cl_bool blocking_read,
673 const size_t * origin, const size_t * region,
674 SIZE_T row_pitch, SIZE_T slice_pitch, void * ptr,
675 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
677 cl_int ret;
678 TRACE("(%p, %p, %d, %p, %p, %ld, %ld, %p, %d, %p, %p)\n", command_queue, image, blocking_read,
679 origin, region, row_pitch, slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event);
680 ret = clEnqueueReadImage(command_queue, image, blocking_read, origin, region, row_pitch, slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event);
681 TRACE("(%p, %p, %d, %p, %p, %ld, %ld, %p, %d, %p, %p)=%d\n", command_queue, image, blocking_read,
682 origin, region, row_pitch, slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event, ret);
683 return ret;
686 cl_int WINAPI wine_clEnqueueWriteImage(cl_command_queue command_queue, cl_mem image, cl_bool blocking_write,
687 const size_t * origin, const size_t * region,
688 size_t input_row_pitch, size_t input_slice_pitch, const void * ptr,
689 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
691 cl_int ret;
692 TRACE("\n");
693 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);
694 return ret;
697 cl_int WINAPI wine_clEnqueueCopyImage(cl_command_queue command_queue, cl_mem src_image, cl_mem dst_image,
698 size_t * src_origin, size_t * dst_origin, size_t * region,
699 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
701 cl_int ret;
702 TRACE("\n");
703 ret = clEnqueueCopyImage(command_queue, src_image, dst_image, src_origin, dst_origin, region, num_events_in_wait_list, event_wait_list, event);
704 return ret;
707 cl_int WINAPI wine_clEnqueueCopyImageToBuffer(cl_command_queue command_queue, cl_mem src_image, cl_mem dst_buffer,
708 size_t * src_origin, size_t * region, size_t dst_offset,
709 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
711 cl_int ret;
712 TRACE("\n");
713 ret = clEnqueueCopyImageToBuffer(command_queue, src_image, dst_buffer, src_origin, region, dst_offset, num_events_in_wait_list, event_wait_list, event);
714 return ret;
717 cl_int WINAPI wine_clEnqueueCopyBufferToImage(cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_image,
718 size_t src_offset, size_t * dst_origin, size_t * region,
719 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
721 cl_int ret;
722 TRACE("\n");
723 ret = clEnqueueCopyBufferToImage(command_queue, src_buffer, dst_image, src_offset, dst_origin, region, num_events_in_wait_list, event_wait_list, event);
724 return ret;
727 void * WINAPI wine_clEnqueueMapBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map,
728 cl_map_flags map_flags, size_t offset, size_t cb,
729 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, cl_int * errcode_ret)
731 void * ret;
732 TRACE("\n");
733 ret = clEnqueueMapBuffer(command_queue, buffer, blocking_map, map_flags, offset, cb, num_events_in_wait_list, event_wait_list, event, errcode_ret);
734 return ret;
737 void * WINAPI wine_clEnqueueMapImage(cl_command_queue command_queue, cl_mem image, cl_bool blocking_map,
738 cl_map_flags map_flags, size_t * origin, size_t * region,
739 size_t * image_row_pitch, size_t * image_slice_pitch,
740 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, cl_int * errcode_ret)
742 void * ret;
743 TRACE("\n");
744 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);
745 return ret;
748 cl_int WINAPI wine_clEnqueueUnmapMemObject(cl_command_queue command_queue, cl_mem memobj, void * mapped_ptr,
749 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
751 cl_int ret;
752 TRACE("\n");
753 ret = clEnqueueUnmapMemObject(command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event);
754 return ret;
757 cl_int WINAPI wine_clEnqueueNDRangeKernel(cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim,
758 size_t * global_work_offset, size_t * global_work_size, size_t * local_work_size,
759 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
761 cl_int ret;
762 TRACE("\n");
763 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);
764 return ret;
767 cl_int WINAPI wine_clEnqueueTask(cl_command_queue command_queue, cl_kernel kernel,
768 cl_uint num_events_in_wait_list, cl_event * event_wait_list, cl_event * event)
770 cl_int ret;
771 TRACE("\n");
772 ret = clEnqueueTask(command_queue, kernel, num_events_in_wait_list, event_wait_list, event);
773 return ret;
776 cl_int WINAPI wine_clEnqueueNativeKernel(cl_command_queue command_queue,
777 void WINAPI (*user_func)(void *args),
778 void * args, size_t cb_args,
779 cl_uint num_mem_objects, const cl_mem * mem_list, const void ** args_mem_loc,
780 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
782 cl_int ret = CL_INVALID_OPERATION;
783 /* FIXME: There appears to be no obvious method for translating the ABI for user_func.
784 * There is no opaque user_data structure passed, that could encapsulate the return address.
785 * The OpenCL specification seems to indicate that args has an implementation specific
786 * structure that cannot be used to stash away a return address for the WINAPI user_func.
788 #if 0
789 ret = clEnqueueNativeKernel(command_queue, user_func, args, cb_args, num_mem_objects, mem_list, args_mem_loc,
790 num_events_in_wait_list, event_wait_list, event);
791 #else
792 FIXME("not supported due to user_func ABI mismatch\n");
793 #endif
794 return ret;
797 cl_int WINAPI wine_clEnqueueMarker(cl_command_queue command_queue, cl_event * event)
799 cl_int ret;
800 TRACE("\n");
801 ret = clEnqueueMarker(command_queue, event);
802 return ret;
805 cl_int WINAPI wine_clEnqueueWaitForEvents(cl_command_queue command_queue, cl_uint num_events, cl_event * event_list)
807 cl_int ret;
808 TRACE("\n");
809 ret = clEnqueueWaitForEvents(command_queue, num_events, event_list);
810 return ret;
813 cl_int WINAPI wine_clEnqueueBarrier(cl_command_queue command_queue)
815 cl_int ret;
816 TRACE("\n");
817 ret = clEnqueueBarrier(command_queue);
818 return ret;
822 /*---------------------------------------------------------------*/
823 /* Extension function access */
825 void * WINAPI wine_clGetExtensionFunctionAddress(const char * func_name)
827 void * ret = 0;
828 TRACE("(%s)\n",func_name);
829 #if 0
830 ret = clGetExtensionFunctionAddress(func_name);
831 #else
832 FIXME("extensions not implemented\n");
833 #endif
834 TRACE("(%s)=%p\n",func_name, ret);
835 return ret;
839 #if OPENCL_WITH_GL
840 /*---------------------------------------------------------------*/
841 /* Khronos-approved (KHR) OpenCL extensions which have OpenGL dependencies. */
843 cl_mem WINAPI wine_clCreateFromGLBuffer(cl_context context, cl_mem_flags flags, cl_GLuint bufobj, int * errcode_ret)
847 cl_mem WINAPI wine_clCreateFromGLTexture2D(cl_context context, cl_mem_flags flags, cl_GLenum target,
848 cl_GLint miplevel, cl_GLuint texture, cl_int * errcode_ret)
852 cl_mem WINAPI wine_clCreateFromGLTexture3D(cl_context context, cl_mem_flags flags, cl_GLenum target,
853 cl_GLint miplevel, cl_GLuint texture, cl_int * errcode_ret)
857 cl_mem WINAPI wine_clCreateFromGLRenderbuffer(cl_context context, cl_mem_flags flags, cl_GLuint renderbuffer, cl_int * errcode_ret)
861 cl_int WINAPI wine_clGetGLObjectInfo(cl_mem memobj, cl_gl_object_type * gl_object_type, cl_GLuint * gl_object_name)
865 cl_int WINAPI wine_clGetGLTextureInfo(cl_mem memobj, cl_gl_texture_info param_name, size_t param_value_size,
866 void * param_value, size_t * param_value_size_ret)
870 cl_int WINAPI wine_clEnqueueAcquireGLObjects(cl_command_queue command_queue, cl_uint num_objects, const cl_mem * mem_objects,
871 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
875 cl_int WINAPI wine_clEnqueueReleaseGLObjects(cl_command_queue command_queue, cl_uint num_objects, const cl_mem * mem_objects,
876 cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event)
881 /*---------------------------------------------------------------*/
882 /* cl_khr_gl_sharing extension */
884 cl_int WINAPI wine_clGetGLContextInfoKHR(const cl_context_properties * properties, cl_gl_context_info param_name,
885 size_t param_value_size, void * param_value, size_t * param_value_size_ret)
889 #endif
892 #if 0
893 /*---------------------------------------------------------------*/
894 /* cl_khr_icd extension */
896 cl_int WINAPI wine_clIcdGetPlatformIDsKHR(cl_uint num_entries, cl_platform_id * platforms, cl_uint * num_platforms)
899 #endif