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"
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
)
34 TRACE( "got host extension string %s\n", debugstr_a( unix_exts
) );
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
;
51 if (ret_size
) *ret_size
= win_size
;
52 if (!win_exts
) return CL_SUCCESS
;
53 if (size
< win_size
) return CL_INVALID_VALUE
;
59 const char *end
= strchr( ext
, ' ' );
62 if (!end
) end
= ext
+ strlen( ext
);
65 if (extension_is_supported( ext
, len
))
67 if (p
!= win_exts
) *p
++ = ' ';
68 memcpy( p
, ext
, len
);
72 if (*end
== ' ') ++end
;
77 TRACE( "returning extension string %s\n", debugstr_a(win_exts
) );
82 cl_int WINAPI
clGetPlatformInfo( cl_platform_id platform
, cl_platform_info name
,
83 SIZE_T size
, void *value
, size_t *ret_size
)
87 TRACE( "(%p, %#x, %Id, %p, %p)\n", platform
, name
, size
, value
, ret_size
);
89 if (name
== CL_PLATFORM_EXTENSIONS
)
93 struct clGetPlatformInfo_params params
= { platform
, name
, 0, NULL
, &unix_size
};
95 ret
= OPENCL_CALL( clGetPlatformInfo
, ¶ms
);
96 if (ret
!= CL_SUCCESS
)
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
, ¶ms
);
105 if (ret
!= CL_SUCCESS
)
111 ret
= filter_extensions( unix_exts
, size
, value
, ret_size
);
117 struct clGetPlatformInfo_params params
= { platform
, name
, size
, value
, ret_size
};
118 ret
= OPENCL_CALL( clGetPlatformInfo
, ¶ms
);
125 cl_int WINAPI
clGetDeviceInfo( cl_device_id device
, cl_device_info name
,
126 SIZE_T size
, void *value
, size_t *ret_size
)
130 TRACE( "(%p, %#x, %Id, %p, %p)\n", device
, name
, size
, value
, ret_size
);
132 if (name
== CL_DEVICE_EXTENSIONS
)
136 struct clGetDeviceInfo_params params
= { device
, name
, 0, NULL
, &unix_size
};
138 ret
= OPENCL_CALL( clGetDeviceInfo
, ¶ms
);
139 if (ret
!= CL_SUCCESS
)
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
, ¶ms
);
148 if (ret
!= CL_SUCCESS
)
154 ret
= filter_extensions( unix_exts
, size
, value
, ret_size
);
160 struct clGetDeviceInfo_params params
= { device
, name
, size
, value
, ret_size
};
161 ret
= OPENCL_CALL( clGetDeviceInfo
, ¶ms
);
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
;
175 void * WINAPI
clGetExtensionFunctionAddress( const char *func_name
)
178 TRACE("(%s)\n",func_name
);
180 ret
= clGetExtensionFunctionAddress(func_name
);
182 FIXME("extensions not implemented\n");
184 TRACE("(%s)=%p\n",func_name
, 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
) );
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
);
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
);
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
);
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
);
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
);
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();