comctl32/tests: Flush events before testing edit control IME messages.
[wine.git] / dlls / opencl / pe_wrappers.c
blob29ae1afaafffcad2c0aac352d597f8b5f750a15b
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 "opencl_private.h"
22 #include "opencl_types.h"
23 #include "unixlib.h"
24 #include "wine/wgl.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(opencl);
28 unixlib_handle_t opencl_handle = 0;
30 static cl_int filter_extensions( const char *unix_exts, SIZE_T size, char *win_exts, size_t *ret_size )
32 char *p = win_exts;
33 const char *ext;
34 SIZE_T win_size;
36 TRACE( "got host extension string %s\n", debugstr_a( unix_exts ) );
38 ext = unix_exts;
39 win_size = 0;
40 while (*ext)
42 const char *end = strchr( ext, ' ' );
44 if (!end) end = ext + strlen( ext );
46 if (extension_is_supported( ext, end - ext ))
47 win_size += strlen( ext ) + 1;
49 if (*end == ' ') ++end;
50 ext = end;
53 if (ret_size) *ret_size = win_size;
54 if (!win_exts) return CL_SUCCESS;
55 if (size < win_size) return CL_INVALID_VALUE;
57 win_exts[0] = 0;
58 ext = unix_exts;
59 while (*ext)
61 const char *end = strchr( ext, ' ' );
62 size_t len;
64 if (!end) end = ext + strlen( ext );
65 len = end - ext;
67 if (extension_is_supported( ext, len ))
69 if (p != win_exts) *p++ = ' ';
70 memcpy( p, ext, len );
71 p += len;
74 if (*end == ' ') ++end;
75 ext = end;
77 *p = 0;
79 TRACE( "returning extension string %s\n", debugstr_a(win_exts) );
81 return CL_SUCCESS;
84 cl_int WINAPI clGetPlatformInfo( cl_platform_id platform, cl_platform_info name,
85 SIZE_T size, void *value, size_t *ret_size )
87 cl_int ret;
89 TRACE( "(%p, %#x, %Id, %p, %p)\n", platform, name, size, value, ret_size );
91 if (name == CL_PLATFORM_EXTENSIONS)
93 size_t unix_size;
94 char *unix_exts;
95 struct clGetPlatformInfo_params params = { platform, name, 0, NULL, &unix_size };
97 ret = OPENCL_CALL( clGetPlatformInfo, &params );
98 if (ret != CL_SUCCESS)
99 return ret;
101 if (!(unix_exts = malloc( unix_size )))
102 return CL_OUT_OF_HOST_MEMORY;
103 params.param_value_size = unix_size;
104 params.param_value = unix_exts;
105 params.param_value_size_ret = NULL;
106 ret = OPENCL_CALL( clGetPlatformInfo, &params );
107 if (ret != CL_SUCCESS)
109 free( unix_exts );
110 return ret;
113 ret = filter_extensions( unix_exts, size, value, ret_size );
115 free( unix_exts );
117 else
119 struct clGetPlatformInfo_params params = { platform, name, size, value, ret_size };
120 ret = OPENCL_CALL( clGetPlatformInfo, &params );
123 return ret;
127 cl_int WINAPI clGetDeviceInfo( cl_device_id device, cl_device_info name,
128 SIZE_T size, void *value, size_t *ret_size )
130 cl_int ret;
132 TRACE( "(%p, %#x, %Id, %p, %p)\n", device, name, size, value, ret_size );
134 if (name == CL_DEVICE_EXTENSIONS)
136 size_t unix_size;
137 char *unix_exts;
138 struct clGetDeviceInfo_params params = { device, name, 0, NULL, &unix_size };
140 ret = OPENCL_CALL( clGetDeviceInfo, &params );
141 if (ret != CL_SUCCESS)
142 return ret;
144 if (!(unix_exts = malloc( unix_size )))
145 return CL_OUT_OF_HOST_MEMORY;
146 params.param_value_size = unix_size;
147 params.param_value = unix_exts;
148 params.param_value_size_ret = NULL;
149 ret = OPENCL_CALL( clGetDeviceInfo, &params );
150 if (ret != CL_SUCCESS)
152 free( unix_exts );
153 return ret;
156 ret = filter_extensions( unix_exts, size, value, ret_size );
158 free( unix_exts );
160 else
162 struct clGetDeviceInfo_params params = { device, name, size, value, ret_size };
163 ret = OPENCL_CALL( clGetDeviceInfo, &params );
166 /* Filter out the CL_EXEC_NATIVE_KERNEL flag */
167 if (name == CL_DEVICE_EXECUTION_CAPABILITIES)
169 cl_device_exec_capabilities *caps = value;
170 *caps &= ~CL_EXEC_NATIVE_KERNEL;
173 return ret;
177 void * WINAPI clGetExtensionFunctionAddress( const char *func_name )
179 void * ret = 0;
180 TRACE("(%s)\n",func_name);
181 #if 0
182 ret = clGetExtensionFunctionAddress(func_name);
183 #else
184 FIXME("extensions not implemented\n");
185 #endif
186 TRACE("(%s)=%p\n",func_name, ret);
187 return ret;
191 cl_int WINAPI clSetCommandQueueProperty( cl_command_queue command_queue, cl_command_queue_properties properties,
192 cl_bool enable, cl_command_queue_properties *old_properties )
194 FIXME( "(%p, %s, %u, %p) deprecated\n", command_queue, wine_dbgstr_longlong(properties), enable, old_properties );
195 return CL_INVALID_QUEUE_PROPERTIES;
199 void * WINAPI clGetExtensionFunctionAddressForPlatform( cl_platform_id platform, const char *func_name )
201 FIXME( "(%p, %s) stub!\n", platform, debugstr_a(func_name) );
202 return NULL;
206 cl_mem WINAPI clCreateFromGLBuffer( cl_context *context, cl_mem_flags flags, GLuint bufobj, int *errcode_ret )
208 FIXME( "(%p, %s, %u, %p) stub!\n", context, wine_dbgstr_longlong(flags), bufobj, errcode_ret );
209 return NULL;
213 cl_mem WINAPI clCreateFromGLRenderbuffer( cl_context *context,
214 cl_mem_flags flags, GLuint renderbuffer, int *errcode_ret )
216 FIXME( "(%p, %s, %u, %p) stub!\n", context, wine_dbgstr_longlong(flags), renderbuffer, errcode_ret );
217 return NULL;
221 cl_mem WINAPI clCreateFromGLTexture( cl_context *context, cl_mem_flags flags,
222 GLenum target, GLint miplevel, GLuint texture, cl_int *errcode_ret )
224 FIXME( "(%p, %s, %u, %d, %u, %p) stub!\n",
225 context, wine_dbgstr_longlong(flags), target, miplevel, texture, errcode_ret );
226 return NULL;
230 cl_mem WINAPI clCreateFromGLTexture2D( cl_context *context, cl_mem_flags flags,
231 GLenum target, GLint miplevel, GLuint texture, cl_int *errcode_ret )
233 FIXME( "(%p, %s, %u, %d, %u, %p) stub!\n",
234 context, wine_dbgstr_longlong(flags), target, miplevel, texture, errcode_ret );
235 return NULL;
239 cl_mem WINAPI clCreateFromGLTexture3D( cl_context *context, cl_mem_flags flags,
240 GLenum target, GLint miplevel, GLuint texture, cl_int *errcode_ret )
242 FIXME( "(%p, %s, %u, %d, %u, %p) stub!\n",
243 context, wine_dbgstr_longlong(flags), target, miplevel, texture, errcode_ret );
244 return NULL;
248 cl_int WINAPI clEnqueueAcquireGLObjects( cl_command_queue queue, cl_uint num_objects, const cl_mem *mem_objects,
249 cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event )
251 FIXME( "(%p, %u, %p, %u, %p, %p) stub!\n",
252 queue, num_objects, mem_objects, num_events_in_wait_list, event_wait_list, event );
253 return CL_INVALID_DEVICE;
257 cl_int WINAPI clEnqueueReleaseGLObjects( cl_command_queue queue, cl_uint num_objects, const cl_mem *mem_objects,
258 cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event )
260 FIXME( "(%p, %u, %p, %u, %p, %p) stub!\n",
261 queue, num_objects, mem_objects, num_events_in_wait_list, event_wait_list, event );
262 return CL_INVALID_DEVICE;
266 cl_int WINAPI clGetGLObjectInfo( cl_mem memobj, cl_gl_object_type *gl_object_type, GLuint *gl_object_name )
268 FIXME( "(%p, %p, %p) stub!\n", memobj, gl_object_type, gl_object_name );
269 return CL_INVALID_DEVICE;
273 cl_int WINAPI clGetGLTextureInfo( cl_mem memobj, cl_gl_texture_info param_name,
274 size_t param_value_size, void *param_value, size_t param_value_size_ret )
276 FIXME( "(%p, %#x, %Iu, %p, %Iu) stub!\n",
277 memobj, param_name, param_value_size, param_value, param_value_size_ret );
278 return CL_INVALID_DEVICE;
282 BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved )
284 if (reason == DLL_PROCESS_ATTACH)
286 DisableThreadLibraryCalls( instance );
287 return !NtQueryVirtualMemory( GetCurrentProcess(), instance, MemoryWineUnixFuncs,
288 &opencl_handle, sizeof(opencl_handle), NULL );
290 return TRUE;