winealsa: Use dedicated macros to call interface functions.
[wine.git] / dlls / opencl / pe_wrappers.c
blob3b6846009c133b33bc2de702d78d5397dff2ef02
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 static cl_int filter_extensions( const char *unix_exts, SIZE_T size, char *win_exts, size_t *ret_size )
30 char *p = win_exts;
31 const char *ext;
32 SIZE_T win_size;
34 TRACE( "got host extension string %s\n", debugstr_a( unix_exts ) );
36 ext = unix_exts;
37 win_size = 0;
38 while (*ext)
40 const char *end = strchr( ext, ' ' );
42 if (!end) end = ext + strlen( ext );
44 if (extension_is_supported( ext, end - ext ))
45 win_size += strlen( ext ) + 1;
47 if (*end == ' ') ++end;
48 ext = end;
51 if (ret_size) *ret_size = win_size;
52 if (!win_exts) return CL_SUCCESS;
53 if (size < win_size) return CL_INVALID_VALUE;
55 win_exts[0] = 0;
56 ext = unix_exts;
57 while (*ext)
59 const char *end = strchr( ext, ' ' );
60 size_t len;
62 if (!end) end = ext + strlen( ext );
63 len = end - ext;
65 if (extension_is_supported( ext, len ))
67 if (p != win_exts) *p++ = ' ';
68 memcpy( p, ext, len );
69 p += len;
72 if (*end == ' ') ++end;
73 ext = end;
75 *p = 0;
77 TRACE( "returning extension string %s\n", debugstr_a(win_exts) );
79 return CL_SUCCESS;
82 cl_int WINAPI clGetPlatformInfo( cl_platform_id platform, cl_platform_info name,
83 SIZE_T size, void *value, size_t *ret_size )
85 cl_int ret;
87 TRACE( "(%p, %#x, %Id, %p, %p)\n", platform, name, size, value, ret_size );
89 if (name == CL_PLATFORM_EXTENSIONS)
91 size_t unix_size;
92 char *unix_exts;
93 struct clGetPlatformInfo_params params = { platform, name, 0, NULL, &unix_size };
95 ret = OPENCL_CALL( clGetPlatformInfo, &params );
96 if (ret != CL_SUCCESS)
97 return ret;
99 if (!(unix_exts = malloc( unix_size )))
100 return CL_OUT_OF_HOST_MEMORY;
101 params.param_value_size = unix_size;
102 params.param_value = unix_exts;
103 params.param_value_size_ret = NULL;
104 ret = OPENCL_CALL( clGetPlatformInfo, &params );
105 if (ret != CL_SUCCESS)
107 free( unix_exts );
108 return ret;
111 ret = filter_extensions( unix_exts, size, value, ret_size );
113 free( unix_exts );
115 else
117 struct clGetPlatformInfo_params params = { platform, name, size, value, ret_size };
118 ret = OPENCL_CALL( clGetPlatformInfo, &params );
121 return ret;
125 cl_int WINAPI clGetDeviceInfo( cl_device_id device, cl_device_info name,
126 SIZE_T size, void *value, size_t *ret_size )
128 cl_int ret;
130 TRACE( "(%p, %#x, %Id, %p, %p)\n", device, name, size, value, ret_size );
132 if (name == CL_DEVICE_EXTENSIONS)
134 size_t unix_size;
135 char *unix_exts;
136 struct clGetDeviceInfo_params params = { device, name, 0, NULL, &unix_size };
138 ret = OPENCL_CALL( clGetDeviceInfo, &params );
139 if (ret != CL_SUCCESS)
140 return ret;
142 if (!(unix_exts = malloc( unix_size )))
143 return CL_OUT_OF_HOST_MEMORY;
144 params.param_value_size = unix_size;
145 params.param_value = unix_exts;
146 params.param_value_size_ret = NULL;
147 ret = OPENCL_CALL( clGetDeviceInfo, &params );
148 if (ret != CL_SUCCESS)
150 free( unix_exts );
151 return ret;
154 ret = filter_extensions( unix_exts, size, value, ret_size );
156 free( unix_exts );
158 else
160 struct clGetDeviceInfo_params params = { device, name, size, value, ret_size };
161 ret = OPENCL_CALL( clGetDeviceInfo, &params );
164 /* Filter out the CL_EXEC_NATIVE_KERNEL flag */
165 if (name == CL_DEVICE_EXECUTION_CAPABILITIES)
167 cl_device_exec_capabilities *caps = value;
168 *caps &= ~CL_EXEC_NATIVE_KERNEL;
171 return ret;
175 void * WINAPI clGetExtensionFunctionAddress( const char *func_name )
177 void * ret = 0;
178 TRACE("(%s)\n",func_name);
179 #if 0
180 ret = clGetExtensionFunctionAddress(func_name);
181 #else
182 FIXME("extensions not implemented\n");
183 #endif
184 TRACE("(%s)=%p\n",func_name, ret);
185 return ret;
189 cl_int WINAPI clSetCommandQueueProperty( cl_command_queue command_queue, cl_command_queue_properties properties,
190 cl_bool enable, cl_command_queue_properties *old_properties )
192 FIXME( "(%p, %s, %u, %p) deprecated\n", command_queue, wine_dbgstr_longlong(properties), enable, old_properties );
193 return CL_INVALID_QUEUE_PROPERTIES;
197 void * WINAPI clGetExtensionFunctionAddressForPlatform( cl_platform_id platform, const char *func_name )
199 FIXME( "(%p, %s) stub!\n", platform, debugstr_a(func_name) );
200 return NULL;
204 cl_mem WINAPI clCreateFromGLBuffer( cl_context *context, cl_mem_flags flags, GLuint bufobj, int *errcode_ret )
206 FIXME( "(%p, %s, %u, %p) stub!\n", context, wine_dbgstr_longlong(flags), bufobj, errcode_ret );
207 return NULL;
211 cl_mem WINAPI clCreateFromGLRenderbuffer( cl_context *context,
212 cl_mem_flags flags, GLuint renderbuffer, int *errcode_ret )
214 FIXME( "(%p, %s, %u, %p) stub!\n", context, wine_dbgstr_longlong(flags), renderbuffer, errcode_ret );
215 return NULL;
219 cl_mem WINAPI clCreateFromGLTexture( cl_context *context, cl_mem_flags flags,
220 GLenum target, GLint miplevel, GLuint texture, cl_int *errcode_ret )
222 FIXME( "(%p, %s, %u, %d, %u, %p) stub!\n",
223 context, wine_dbgstr_longlong(flags), target, miplevel, texture, errcode_ret );
224 return NULL;
228 cl_mem WINAPI clCreateFromGLTexture2D( cl_context *context, cl_mem_flags flags,
229 GLenum target, GLint miplevel, GLuint texture, cl_int *errcode_ret )
231 FIXME( "(%p, %s, %u, %d, %u, %p) stub!\n",
232 context, wine_dbgstr_longlong(flags), target, miplevel, texture, errcode_ret );
233 return NULL;
237 cl_mem WINAPI clCreateFromGLTexture3D( cl_context *context, cl_mem_flags flags,
238 GLenum target, GLint miplevel, GLuint texture, cl_int *errcode_ret )
240 FIXME( "(%p, %s, %u, %d, %u, %p) stub!\n",
241 context, wine_dbgstr_longlong(flags), target, miplevel, texture, errcode_ret );
242 return NULL;
246 cl_int WINAPI clEnqueueAcquireGLObjects( cl_command_queue queue, cl_uint num_objects, const cl_mem *mem_objects,
247 cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event )
249 FIXME( "(%p, %u, %p, %u, %p, %p) stub!\n",
250 queue, num_objects, mem_objects, num_events_in_wait_list, event_wait_list, event );
251 return CL_INVALID_DEVICE;
255 cl_int WINAPI clEnqueueReleaseGLObjects( cl_command_queue queue, cl_uint num_objects, const cl_mem *mem_objects,
256 cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event )
258 FIXME( "(%p, %u, %p, %u, %p, %p) stub!\n",
259 queue, num_objects, mem_objects, num_events_in_wait_list, event_wait_list, event );
260 return CL_INVALID_DEVICE;
264 cl_int WINAPI clGetGLObjectInfo( cl_mem memobj, cl_gl_object_type *gl_object_type, GLuint *gl_object_name )
266 FIXME( "(%p, %p, %p) stub!\n", memobj, gl_object_type, gl_object_name );
267 return CL_INVALID_DEVICE;
271 cl_int WINAPI clGetGLTextureInfo( cl_mem memobj, cl_gl_texture_info param_name,
272 size_t param_value_size, void *param_value, size_t param_value_size_ret )
274 FIXME( "(%p, %#x, %Iu, %p, %Iu) stub!\n",
275 memobj, param_name, param_value_size, param_value, param_value_size_ret );
276 return CL_INVALID_DEVICE;
280 BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved )
282 if (reason == DLL_PROCESS_ATTACH)
284 DisableThreadLibraryCalls( instance );
285 return !__wine_init_unix_call();
287 return TRUE;