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"
25 WINE_DEFAULT_DEBUG_CHANNEL(opencl
);
27 unixlib_handle_t opencl_handle
= 0;
29 static cl_int
filter_extensions( const char *unix_exts
, SIZE_T size
, char *win_exts
, size_t *ret_size
)
35 TRACE( "got host extension string %s\n", debugstr_a( unix_exts
) );
41 const char *end
= strchr( ext
, ' ' );
43 if (!end
) end
= ext
+ strlen( ext
);
45 if (extension_is_supported( ext
, end
- ext
))
46 win_size
+= strlen( ext
) + 1;
48 if (*end
== ' ') ++end
;
52 if (ret_size
) *ret_size
= win_size
;
53 if (!win_exts
) return CL_SUCCESS
;
54 if (size
< win_size
) return CL_INVALID_VALUE
;
60 const char *end
= strchr( ext
, ' ' );
63 if (!end
) end
= ext
+ strlen( ext
);
66 if (extension_is_supported( ext
, len
))
68 if (p
!= win_exts
) *p
++ = ' ';
69 memcpy( p
, ext
, len
);
73 if (*end
== ' ') ++end
;
78 TRACE( "returning extension string %s\n", debugstr_a(win_exts
) );
83 cl_int WINAPI
clGetPlatformInfo( cl_platform_id platform
, cl_platform_info name
,
84 SIZE_T size
, void *value
, size_t *ret_size
)
88 TRACE( "(%p, %#x, %ld, %p, %p)\n", platform
, name
, size
, value
, ret_size
);
90 if (name
== CL_PLATFORM_EXTENSIONS
)
94 struct clGetPlatformInfo_params params
= { platform
, name
, 0, NULL
, &unix_size
};
96 ret
= OPENCL_CALL( clGetPlatformInfo
, ¶ms
);
97 if (ret
!= CL_SUCCESS
)
100 if (!(unix_exts
= malloc( unix_size
)))
101 return CL_OUT_OF_HOST_MEMORY
;
102 params
.param_value_size
= unix_size
;
103 params
.param_value
= unix_exts
;
104 params
.param_value_size_ret
= NULL
;
105 ret
= OPENCL_CALL( clGetPlatformInfo
, ¶ms
);
106 if (ret
!= CL_SUCCESS
)
112 ret
= filter_extensions( unix_exts
, size
, value
, ret_size
);
118 struct clGetPlatformInfo_params params
= { platform
, name
, size
, value
, ret_size
};
119 ret
= OPENCL_CALL( clGetPlatformInfo
, ¶ms
);
126 cl_int WINAPI
clGetDeviceInfo( cl_device_id device
, cl_device_info name
,
127 SIZE_T size
, void *value
, size_t *ret_size
)
131 TRACE( "(%p, %#x, %ld, %p, %p)\n", device
, name
, size
, value
, ret_size
);
133 if (name
== CL_DEVICE_EXTENSIONS
)
137 struct clGetDeviceInfo_params params
= { device
, name
, 0, NULL
, &unix_size
};
139 ret
= OPENCL_CALL( clGetDeviceInfo
, ¶ms
);
140 if (ret
!= CL_SUCCESS
)
143 if (!(unix_exts
= malloc( unix_size
)))
144 return CL_OUT_OF_HOST_MEMORY
;
145 params
.param_value_size
= unix_size
;
146 params
.param_value
= unix_exts
;
147 params
.param_value_size_ret
= NULL
;
148 ret
= OPENCL_CALL( clGetDeviceInfo
, ¶ms
);
149 if (ret
!= CL_SUCCESS
)
155 ret
= filter_extensions( unix_exts
, size
, value
, ret_size
);
161 struct clGetDeviceInfo_params params
= { device
, name
, size
, value
, ret_size
};
162 ret
= OPENCL_CALL( clGetDeviceInfo
, ¶ms
);
165 /* Filter out the CL_EXEC_NATIVE_KERNEL flag */
166 if (name
== CL_DEVICE_EXECUTION_CAPABILITIES
)
168 cl_device_exec_capabilities
*caps
= value
;
169 *caps
&= ~CL_EXEC_NATIVE_KERNEL
;
176 void * WINAPI
clGetExtensionFunctionAddress( const char *func_name
)
179 TRACE("(%s)\n",func_name
);
181 ret
= clGetExtensionFunctionAddress(func_name
);
183 FIXME("extensions not implemented\n");
185 TRACE("(%s)=%p\n",func_name
, ret
);
190 cl_int WINAPI
clSetCommandQueueProperty( cl_command_queue command_queue
, cl_command_queue_properties properties
,
191 cl_bool enable
, cl_command_queue_properties
*old_properties
)
193 FIXME( "(%p, %s, %u, %p) deprecated\n", command_queue
, wine_dbgstr_longlong(properties
), enable
, old_properties
);
194 return CL_INVALID_QUEUE_PROPERTIES
;
198 void * WINAPI
clGetExtensionFunctionAddressForPlatform( cl_platform_id platform
, const char *func_name
)
200 FIXME( "(%p, %s) stub!\n", platform
, debugstr_a(func_name
) );
205 BOOL WINAPI
DllMain( HINSTANCE instance
, DWORD reason
, void *reserved
)
207 if (reason
== DLL_PROCESS_ATTACH
)
209 DisableThreadLibraryCalls( instance
);
210 return !NtQueryVirtualMemory( GetCurrentProcess(), instance
, MemoryWineUnixFuncs
,
211 &opencl_handle
, sizeof(opencl_handle
), NULL
);