wined3d: Properly compare integers in wined3d_bo_slab_vk_compare().
[wine.git] / dlls / opencl / pe_wrappers.c
blob5fde6a8b8526db830d358730cbe94d5476d41719
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"
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 )
31 char *p = win_exts;
32 const char *ext;
33 SIZE_T win_size;
35 TRACE( "got host extension string %s\n", debugstr_a( unix_exts ) );
37 ext = unix_exts;
38 win_size = 0;
39 while (*ext)
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;
49 ext = 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;
56 win_exts[0] = 0;
57 ext = unix_exts;
58 while (*ext)
60 const char *end = strchr( ext, ' ' );
61 size_t len;
63 if (!end) end = ext + strlen( ext );
64 len = end - ext;
66 if (extension_is_supported( ext, len ))
68 if (p != win_exts) *p++ = ' ';
69 memcpy( p, ext, len );
70 p += len;
73 if (*end == ' ') ++end;
74 ext = end;
76 *p = 0;
78 TRACE( "returning extension string %s\n", debugstr_a(win_exts) );
80 return CL_SUCCESS;
83 cl_int WINAPI clGetPlatformInfo( cl_platform_id platform, cl_platform_info name,
84 SIZE_T size, void *value, size_t *ret_size )
86 cl_int ret;
88 TRACE( "(%p, %#x, %ld, %p, %p)\n", platform, name, size, value, ret_size );
90 if (name == CL_PLATFORM_EXTENSIONS)
92 size_t unix_size;
93 char *unix_exts;
94 struct clGetPlatformInfo_params params = { platform, name, 0, NULL, &unix_size };
96 ret = OPENCL_CALL( clGetPlatformInfo, &params );
97 if (ret != CL_SUCCESS)
98 return ret;
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, &params );
106 if (ret != CL_SUCCESS)
108 free( unix_exts );
109 return ret;
112 ret = filter_extensions( unix_exts, size, value, ret_size );
114 free( unix_exts );
116 else
118 struct clGetPlatformInfo_params params = { platform, name, size, value, ret_size };
119 ret = OPENCL_CALL( clGetPlatformInfo, &params );
122 return ret;
126 cl_int WINAPI clGetDeviceInfo( cl_device_id device, cl_device_info name,
127 SIZE_T size, void *value, size_t *ret_size )
129 cl_int ret;
131 TRACE( "(%p, %#x, %ld, %p, %p)\n", device, name, size, value, ret_size );
133 if (name == CL_DEVICE_EXTENSIONS)
135 size_t unix_size;
136 char *unix_exts;
137 struct clGetDeviceInfo_params params = { device, name, 0, NULL, &unix_size };
139 ret = OPENCL_CALL( clGetDeviceInfo, &params );
140 if (ret != CL_SUCCESS)
141 return ret;
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, &params );
149 if (ret != CL_SUCCESS)
151 free( unix_exts );
152 return ret;
155 ret = filter_extensions( unix_exts, size, value, ret_size );
157 free( unix_exts );
159 else
161 struct clGetDeviceInfo_params params = { device, name, size, value, ret_size };
162 ret = OPENCL_CALL( clGetDeviceInfo, &params );
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;
172 return ret;
176 void * WINAPI clGetExtensionFunctionAddress( const char *func_name )
178 void * ret = 0;
179 TRACE("(%s)\n",func_name);
180 #if 0
181 ret = clGetExtensionFunctionAddress(func_name);
182 #else
183 FIXME("extensions not implemented\n");
184 #endif
185 TRACE("(%s)=%p\n",func_name, ret);
186 return 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) );
201 return NULL;
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 );
213 return TRUE;