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 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
)
36 TRACE( "got host extension string %s\n", debugstr_a( unix_exts
) );
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
;
53 if (ret_size
) *ret_size
= win_size
;
54 if (!win_exts
) return CL_SUCCESS
;
55 if (size
< win_size
) return CL_INVALID_VALUE
;
61 const char *end
= strchr( ext
, ' ' );
64 if (!end
) end
= ext
+ strlen( ext
);
67 if (extension_is_supported( ext
, len
))
69 if (p
!= win_exts
) *p
++ = ' ';
70 memcpy( p
, ext
, len
);
74 if (*end
== ' ') ++end
;
79 TRACE( "returning extension string %s\n", debugstr_a(win_exts
) );
84 cl_int WINAPI
clGetPlatformInfo( cl_platform_id platform
, cl_platform_info name
,
85 SIZE_T size
, void *value
, size_t *ret_size
)
89 TRACE( "(%p, %#x, %Id, %p, %p)\n", platform
, name
, size
, value
, ret_size
);
91 if (name
== CL_PLATFORM_EXTENSIONS
)
95 struct clGetPlatformInfo_params params
= { platform
, name
, 0, NULL
, &unix_size
};
97 ret
= OPENCL_CALL( clGetPlatformInfo
, ¶ms
);
98 if (ret
!= CL_SUCCESS
)
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
, ¶ms
);
107 if (ret
!= CL_SUCCESS
)
113 ret
= filter_extensions( unix_exts
, size
, value
, ret_size
);
119 struct clGetPlatformInfo_params params
= { platform
, name
, size
, value
, ret_size
};
120 ret
= OPENCL_CALL( clGetPlatformInfo
, ¶ms
);
127 cl_int WINAPI
clGetDeviceInfo( cl_device_id device
, cl_device_info name
,
128 SIZE_T size
, void *value
, size_t *ret_size
)
132 TRACE( "(%p, %#x, %Id, %p, %p)\n", device
, name
, size
, value
, ret_size
);
134 if (name
== CL_DEVICE_EXTENSIONS
)
138 struct clGetDeviceInfo_params params
= { device
, name
, 0, NULL
, &unix_size
};
140 ret
= OPENCL_CALL( clGetDeviceInfo
, ¶ms
);
141 if (ret
!= CL_SUCCESS
)
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
, ¶ms
);
150 if (ret
!= CL_SUCCESS
)
156 ret
= filter_extensions( unix_exts
, size
, value
, ret_size
);
162 struct clGetDeviceInfo_params params
= { device
, name
, size
, value
, ret_size
};
163 ret
= OPENCL_CALL( clGetDeviceInfo
, ¶ms
);
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
;
177 void * WINAPI
clGetExtensionFunctionAddress( const char *func_name
)
180 TRACE("(%s)\n",func_name
);
182 ret
= clGetExtensionFunctionAddress(func_name
);
184 FIXME("extensions not implemented\n");
186 TRACE("(%s)=%p\n",func_name
, 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
) );
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
);
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
);
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
);
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
);
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
);
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
);