2021-03-16 04:44:50 +00:00
|
|
|
/*
|
|
|
|
* OpenCL.dll proxy for native OpenCL implementation.
|
|
|
|
*
|
|
|
|
* Copyright 2010 Peter Urbanec
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "opencl_private.h"
|
2021-03-16 04:44:51 +00:00
|
|
|
#include "opencl_types.h"
|
|
|
|
#include "unixlib.h"
|
2022-02-03 21:08:16 +00:00
|
|
|
#include "wine/wgl.h"
|
2021-03-16 04:44:50 +00:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(opencl);
|
|
|
|
|
2021-03-20 20:59:23 +00:00
|
|
|
static cl_int filter_extensions( const char *unix_exts, SIZE_T size, char *win_exts, size_t *ret_size )
|
2021-03-16 04:44:50 +00:00
|
|
|
{
|
2021-03-20 20:59:23 +00:00
|
|
|
char *p = win_exts;
|
|
|
|
const char *ext;
|
|
|
|
SIZE_T win_size;
|
|
|
|
|
|
|
|
TRACE( "got host extension string %s\n", debugstr_a( unix_exts ) );
|
2021-03-16 04:44:50 +00:00
|
|
|
|
2021-03-20 20:59:23 +00:00
|
|
|
ext = unix_exts;
|
|
|
|
win_size = 0;
|
|
|
|
while (*ext)
|
2021-03-16 04:44:50 +00:00
|
|
|
{
|
2021-03-20 20:59:23 +00:00
|
|
|
const char *end = strchr( ext, ' ' );
|
|
|
|
|
|
|
|
if (!end) end = ext + strlen( ext );
|
|
|
|
|
|
|
|
if (extension_is_supported( ext, end - ext ))
|
|
|
|
win_size += strlen( ext ) + 1;
|
2021-03-16 04:44:50 +00:00
|
|
|
|
2021-03-20 20:59:23 +00:00
|
|
|
if (*end == ' ') ++end;
|
|
|
|
ext = end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret_size) *ret_size = win_size;
|
|
|
|
if (!win_exts) return CL_SUCCESS;
|
|
|
|
if (size < win_size) return CL_INVALID_VALUE;
|
|
|
|
|
|
|
|
win_exts[0] = 0;
|
|
|
|
ext = unix_exts;
|
|
|
|
while (*ext)
|
|
|
|
{
|
|
|
|
const char *end = strchr( ext, ' ' );
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
if (!end) end = ext + strlen( ext );
|
|
|
|
len = end - ext;
|
|
|
|
|
|
|
|
if (extension_is_supported( ext, len ))
|
2021-03-16 04:44:50 +00:00
|
|
|
{
|
2021-03-20 20:59:23 +00:00
|
|
|
if (p != win_exts) *p++ = ' ';
|
|
|
|
memcpy( p, ext, len );
|
|
|
|
p += len;
|
2021-03-16 04:44:50 +00:00
|
|
|
}
|
|
|
|
|
2021-03-20 20:59:23 +00:00
|
|
|
if (*end == ' ') ++end;
|
|
|
|
ext = end;
|
|
|
|
}
|
|
|
|
*p = 0;
|
|
|
|
|
|
|
|
TRACE( "returning extension string %s\n", debugstr_a(win_exts) );
|
|
|
|
|
|
|
|
return CL_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
cl_int WINAPI clGetPlatformInfo( cl_platform_id platform, cl_platform_info name,
|
|
|
|
SIZE_T size, void *value, size_t *ret_size )
|
|
|
|
{
|
|
|
|
cl_int ret;
|
|
|
|
|
2022-01-27 16:55:55 +00:00
|
|
|
TRACE( "(%p, %#x, %Id, %p, %p)\n", platform, name, size, value, ret_size );
|
2021-03-20 20:59:23 +00:00
|
|
|
|
|
|
|
if (name == CL_PLATFORM_EXTENSIONS)
|
|
|
|
{
|
|
|
|
size_t unix_size;
|
|
|
|
char *unix_exts;
|
2021-11-23 15:56:43 +00:00
|
|
|
struct clGetPlatformInfo_params params = { platform, name, 0, NULL, &unix_size };
|
2021-03-20 20:59:23 +00:00
|
|
|
|
2021-11-23 15:56:43 +00:00
|
|
|
ret = OPENCL_CALL( clGetPlatformInfo, ¶ms );
|
2021-03-20 20:59:23 +00:00
|
|
|
if (ret != CL_SUCCESS)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (!(unix_exts = malloc( unix_size )))
|
|
|
|
return CL_OUT_OF_HOST_MEMORY;
|
2021-11-23 15:56:43 +00:00
|
|
|
params.param_value_size = unix_size;
|
|
|
|
params.param_value = unix_exts;
|
|
|
|
params.param_value_size_ret = NULL;
|
|
|
|
ret = OPENCL_CALL( clGetPlatformInfo, ¶ms );
|
2021-03-20 20:59:23 +00:00
|
|
|
if (ret != CL_SUCCESS)
|
2021-03-16 04:44:50 +00:00
|
|
|
{
|
2021-03-20 20:59:23 +00:00
|
|
|
free( unix_exts );
|
|
|
|
return ret;
|
2021-03-16 04:44:50 +00:00
|
|
|
}
|
2021-03-20 20:59:23 +00:00
|
|
|
|
|
|
|
ret = filter_extensions( unix_exts, size, value, ret_size );
|
|
|
|
|
|
|
|
free( unix_exts );
|
2021-03-16 04:44:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-23 15:56:43 +00:00
|
|
|
struct clGetPlatformInfo_params params = { platform, name, size, value, ret_size };
|
|
|
|
ret = OPENCL_CALL( clGetPlatformInfo, ¶ms );
|
2021-03-16 04:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-20 20:59:23 +00:00
|
|
|
cl_int WINAPI clGetDeviceInfo( cl_device_id device, cl_device_info name,
|
|
|
|
SIZE_T size, void *value, size_t *ret_size )
|
2021-03-16 04:44:50 +00:00
|
|
|
{
|
|
|
|
cl_int ret;
|
|
|
|
|
2022-01-27 16:55:55 +00:00
|
|
|
TRACE( "(%p, %#x, %Id, %p, %p)\n", device, name, size, value, ret_size );
|
2021-03-20 20:59:23 +00:00
|
|
|
|
|
|
|
if (name == CL_DEVICE_EXTENSIONS)
|
2021-03-16 04:44:50 +00:00
|
|
|
{
|
2021-03-20 20:59:23 +00:00
|
|
|
size_t unix_size;
|
|
|
|
char *unix_exts;
|
2021-11-23 15:56:43 +00:00
|
|
|
struct clGetDeviceInfo_params params = { device, name, 0, NULL, &unix_size };
|
2021-03-16 04:44:50 +00:00
|
|
|
|
2021-11-23 15:56:43 +00:00
|
|
|
ret = OPENCL_CALL( clGetDeviceInfo, ¶ms );
|
2021-03-20 20:59:23 +00:00
|
|
|
if (ret != CL_SUCCESS)
|
|
|
|
return ret;
|
2021-03-16 04:44:50 +00:00
|
|
|
|
2021-03-20 20:59:23 +00:00
|
|
|
if (!(unix_exts = malloc( unix_size )))
|
|
|
|
return CL_OUT_OF_HOST_MEMORY;
|
2021-11-23 15:56:43 +00:00
|
|
|
params.param_value_size = unix_size;
|
|
|
|
params.param_value = unix_exts;
|
|
|
|
params.param_value_size_ret = NULL;
|
|
|
|
ret = OPENCL_CALL( clGetDeviceInfo, ¶ms );
|
2021-03-20 20:59:23 +00:00
|
|
|
if (ret != CL_SUCCESS)
|
2021-03-16 04:44:50 +00:00
|
|
|
{
|
2021-03-20 20:59:23 +00:00
|
|
|
free( unix_exts );
|
|
|
|
return ret;
|
2021-03-16 04:44:50 +00:00
|
|
|
}
|
2021-03-20 20:59:23 +00:00
|
|
|
|
|
|
|
ret = filter_extensions( unix_exts, size, value, ret_size );
|
|
|
|
|
|
|
|
free( unix_exts );
|
2021-03-16 04:44:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-23 15:56:43 +00:00
|
|
|
struct clGetDeviceInfo_params params = { device, name, size, value, ret_size };
|
|
|
|
ret = OPENCL_CALL( clGetDeviceInfo, ¶ms );
|
2021-03-16 04:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Filter out the CL_EXEC_NATIVE_KERNEL flag */
|
2021-03-20 20:59:23 +00:00
|
|
|
if (name == CL_DEVICE_EXECUTION_CAPABILITIES)
|
2021-03-16 04:44:50 +00:00
|
|
|
{
|
2021-03-20 20:59:23 +00:00
|
|
|
cl_device_exec_capabilities *caps = value;
|
2021-03-16 04:44:50 +00:00
|
|
|
*caps &= ~CL_EXEC_NATIVE_KERNEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-16 04:44:52 +00:00
|
|
|
void * WINAPI clGetExtensionFunctionAddress( const char *func_name )
|
2021-03-16 04:44:50 +00:00
|
|
|
{
|
|
|
|
void * ret = 0;
|
|
|
|
TRACE("(%s)\n",func_name);
|
|
|
|
#if 0
|
|
|
|
ret = clGetExtensionFunctionAddress(func_name);
|
|
|
|
#else
|
|
|
|
FIXME("extensions not implemented\n");
|
|
|
|
#endif
|
|
|
|
TRACE("(%s)=%p\n",func_name, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-03-19 04:06:32 +00:00
|
|
|
|
|
|
|
cl_int WINAPI clSetCommandQueueProperty( cl_command_queue command_queue, cl_command_queue_properties properties,
|
|
|
|
cl_bool enable, cl_command_queue_properties *old_properties )
|
|
|
|
{
|
|
|
|
FIXME( "(%p, %s, %u, %p) deprecated\n", command_queue, wine_dbgstr_longlong(properties), enable, old_properties );
|
|
|
|
return CL_INVALID_QUEUE_PROPERTIES;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-20 20:59:25 +00:00
|
|
|
void * WINAPI clGetExtensionFunctionAddressForPlatform( cl_platform_id platform, const char *func_name )
|
|
|
|
{
|
|
|
|
FIXME( "(%p, %s) stub!\n", platform, debugstr_a(func_name) );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-03 21:08:16 +00:00
|
|
|
cl_mem WINAPI clCreateFromGLBuffer( cl_context *context, cl_mem_flags flags, GLuint bufobj, int *errcode_ret )
|
|
|
|
{
|
|
|
|
FIXME( "(%p, %s, %u, %p) stub!\n", context, wine_dbgstr_longlong(flags), bufobj, errcode_ret );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cl_mem WINAPI clCreateFromGLRenderbuffer( cl_context *context,
|
|
|
|
cl_mem_flags flags, GLuint renderbuffer, int *errcode_ret )
|
|
|
|
{
|
|
|
|
FIXME( "(%p, %s, %u, %p) stub!\n", context, wine_dbgstr_longlong(flags), renderbuffer, errcode_ret );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cl_mem WINAPI clCreateFromGLTexture( cl_context *context, cl_mem_flags flags,
|
|
|
|
GLenum target, GLint miplevel, GLuint texture, cl_int *errcode_ret )
|
|
|
|
{
|
|
|
|
FIXME( "(%p, %s, %u, %d, %u, %p) stub!\n",
|
|
|
|
context, wine_dbgstr_longlong(flags), target, miplevel, texture, errcode_ret );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cl_mem WINAPI clCreateFromGLTexture2D( cl_context *context, cl_mem_flags flags,
|
|
|
|
GLenum target, GLint miplevel, GLuint texture, cl_int *errcode_ret )
|
|
|
|
{
|
|
|
|
FIXME( "(%p, %s, %u, %d, %u, %p) stub!\n",
|
|
|
|
context, wine_dbgstr_longlong(flags), target, miplevel, texture, errcode_ret );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cl_mem WINAPI clCreateFromGLTexture3D( cl_context *context, cl_mem_flags flags,
|
|
|
|
GLenum target, GLint miplevel, GLuint texture, cl_int *errcode_ret )
|
|
|
|
{
|
|
|
|
FIXME( "(%p, %s, %u, %d, %u, %p) stub!\n",
|
|
|
|
context, wine_dbgstr_longlong(flags), target, miplevel, texture, errcode_ret );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cl_int WINAPI clEnqueueAcquireGLObjects( cl_command_queue queue, cl_uint num_objects, const cl_mem *mem_objects,
|
|
|
|
cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event )
|
|
|
|
{
|
|
|
|
FIXME( "(%p, %u, %p, %u, %p, %p) stub!\n",
|
|
|
|
queue, num_objects, mem_objects, num_events_in_wait_list, event_wait_list, event );
|
|
|
|
return CL_INVALID_DEVICE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cl_int WINAPI clEnqueueReleaseGLObjects( cl_command_queue queue, cl_uint num_objects, const cl_mem *mem_objects,
|
|
|
|
cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event )
|
|
|
|
{
|
|
|
|
FIXME( "(%p, %u, %p, %u, %p, %p) stub!\n",
|
|
|
|
queue, num_objects, mem_objects, num_events_in_wait_list, event_wait_list, event );
|
|
|
|
return CL_INVALID_DEVICE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cl_int WINAPI clGetGLObjectInfo( cl_mem memobj, cl_gl_object_type *gl_object_type, GLuint *gl_object_name )
|
|
|
|
{
|
|
|
|
FIXME( "(%p, %p, %p) stub!\n", memobj, gl_object_type, gl_object_name );
|
|
|
|
return CL_INVALID_DEVICE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cl_int WINAPI clGetGLTextureInfo( cl_mem memobj, cl_gl_texture_info param_name,
|
|
|
|
size_t param_value_size, void *param_value, size_t param_value_size_ret )
|
|
|
|
{
|
|
|
|
FIXME( "(%p, %#x, %Iu, %p, %Iu) stub!\n",
|
|
|
|
memobj, param_name, param_value_size, param_value, param_value_size_ret );
|
|
|
|
return CL_INVALID_DEVICE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-16 04:44:50 +00:00
|
|
|
BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved )
|
|
|
|
{
|
|
|
|
if (reason == DLL_PROCESS_ATTACH)
|
|
|
|
{
|
|
|
|
DisableThreadLibraryCalls( instance );
|
2022-11-25 09:14:03 +00:00
|
|
|
return !__wine_init_unix_call();
|
2021-03-16 04:44:50 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|