2021-03-16 05:44:50 +01: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 05:44:51 +01:00
|
|
|
#include "opencl_types.h"
|
|
|
|
#include "unixlib.h"
|
2022-02-03 22:08:16 +01:00
|
|
|
#include "wine/wgl.h"
|
2021-03-16 05:44:50 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(opencl);
|
|
|
|
|
2021-11-23 16:56:43 +01:00
|
|
|
unixlib_handle_t opencl_handle = 0;
|
2021-03-16 05:44:50 +01:00
|
|
|
|
2021-03-20 21:59:23 +01:00
|
|
|
static cl_int filter_extensions( const char *unix_exts, SIZE_T size, char *win_exts, size_t *ret_size )
|
2021-03-16 05:44:50 +01:00
|
|
|
{
|
2021-03-20 21:59:23 +01: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 05:44:50 +01:00
|
|
|
|
2021-03-20 21:59:23 +01:00
|
|
|
ext = unix_exts;
|
|
|
|
win_size = 0;
|
|
|
|
while (*ext)
|
2021-03-16 05:44:50 +01:00
|
|
|
{
|
2021-03-20 21:59:23 +01: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 05:44:50 +01:00
|
|
|
|
2021-03-20 21:59:23 +01: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 05:44:50 +01:00
|
|
|
{
|
2021-03-20 21:59:23 +01:00
|
|
|
if (p != win_exts) *p++ = ' ';
|
|
|
|
memcpy( p, ext, len );
|
|
|
|
p += len;
|
2021-03-16 05:44:50 +01:00
|
|
|
}
|
|
|
|
|
2021-03-20 21:59:23 +01: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 17:55:55 +01:00
|
|
|
TRACE( "(%p, %#x, %Id, %p, %p)\n", platform, name, size, value, ret_size );
|
2021-03-20 21:59:23 +01:00
|
|
|
|
|
|
|
if (name == CL_PLATFORM_EXTENSIONS)
|
|
|
|
{
|
|
|
|
size_t unix_size;
|
|
|
|
char *unix_exts;
|
2021-11-23 16:56:43 +01:00
|
|
|
struct clGetPlatformInfo_params params = { platform, name, 0, NULL, &unix_size };
|
2021-03-20 21:59:23 +01:00
|
|
|
|
2021-11-23 16:56:43 +01:00
|
|
|
ret = OPENCL_CALL( clGetPlatformInfo, ¶ms );
|
2021-03-20 21:59:23 +01:00
|
|
|
if (ret != CL_SUCCESS)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (!(unix_exts = malloc( unix_size )))
|
|
|
|
return CL_OUT_OF_HOST_MEMORY;
|
2021-11-23 16:56:43 +01: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 21:59:23 +01:00
|
|
|
if (ret != CL_SUCCESS)
|
2021-03-16 05:44:50 +01:00
|
|
|
{
|
2021-03-20 21:59:23 +01:00
|
|
|
free( unix_exts );
|
|
|
|
return ret;
|
2021-03-16 05:44:50 +01:00
|
|
|
}
|
2021-03-20 21:59:23 +01:00
|
|
|
|
|
|
|
ret = filter_extensions( unix_exts, size, value, ret_size );
|
|
|
|
|
|
|
|
free( unix_exts );
|
2021-03-16 05:44:50 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-23 16:56:43 +01:00
|
|
|
struct clGetPlatformInfo_params params = { platform, name, size, value, ret_size };
|
|
|
|
ret = OPENCL_CALL( clGetPlatformInfo, ¶ms );
|
2021-03-16 05:44:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-20 21:59:23 +01: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 05:44:50 +01:00
|
|
|
{
|
|
|
|
cl_int ret;
|
|
|
|
|
2022-01-27 17:55:55 +01:00
|
|
|
TRACE( "(%p, %#x, %Id, %p, %p)\n", device, name, size, value, ret_size );
|
2021-03-20 21:59:23 +01:00
|
|
|
|
|
|
|
if (name == CL_DEVICE_EXTENSIONS)
|
2021-03-16 05:44:50 +01:00
|
|
|
{
|
2021-03-20 21:59:23 +01:00
|
|
|
size_t unix_size;
|
|
|
|
char *unix_exts;
|
2021-11-23 16:56:43 +01:00
|
|
|
struct clGetDeviceInfo_params params = { device, name, 0, NULL, &unix_size };
|
2021-03-16 05:44:50 +01:00
|
|
|
|
2021-11-23 16:56:43 +01:00
|
|
|
ret = OPENCL_CALL( clGetDeviceInfo, ¶ms );
|
2021-03-20 21:59:23 +01:00
|
|
|
if (ret != CL_SUCCESS)
|
|
|
|
return ret;
|
2021-03-16 05:44:50 +01:00
|
|
|
|
2021-03-20 21:59:23 +01:00
|
|
|
if (!(unix_exts = malloc( unix_size )))
|
|
|
|
return CL_OUT_OF_HOST_MEMORY;
|
2021-11-23 16:56:43 +01: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 21:59:23 +01:00
|
|
|
if (ret != CL_SUCCESS)
|
2021-03-16 05:44:50 +01:00
|
|
|
{
|
2021-03-20 21:59:23 +01:00
|
|
|
free( unix_exts );
|
|
|
|
return ret;
|
2021-03-16 05:44:50 +01:00
|
|
|
}
|
2021-03-20 21:59:23 +01:00
|
|
|
|
|
|
|
ret = filter_extensions( unix_exts, size, value, ret_size );
|
|
|
|
|
|
|
|
free( unix_exts );
|
2021-03-16 05:44:50 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-23 16:56:43 +01:00
|
|
|
struct clGetDeviceInfo_params params = { device, name, size, value, ret_size };
|
|
|
|
ret = OPENCL_CALL( clGetDeviceInfo, ¶ms );
|
2021-03-16 05:44:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Filter out the CL_EXEC_NATIVE_KERNEL flag */
|
2021-03-20 21:59:23 +01:00
|
|
|
if (name == CL_DEVICE_EXECUTION_CAPABILITIES)
|
2021-03-16 05:44:50 +01:00
|
|
|
{
|
2021-03-20 21:59:23 +01:00
|
|
|
cl_device_exec_capabilities *caps = value;
|
2021-03-16 05:44:50 +01:00
|
|
|
*caps &= ~CL_EXEC_NATIVE_KERNEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-16 05:44:52 +01:00
|
|
|
void * WINAPI clGetExtensionFunctionAddress( const char *func_name )
|
2021-03-16 05:44:50 +01: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 05:06:32 +01: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 21:59:25 +01: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 22:08:16 +01: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 05:44:50 +01:00
|
|
|
BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved )
|
|
|
|
{
|
|
|
|
if (reason == DLL_PROCESS_ATTACH)
|
|
|
|
{
|
|
|
|
DisableThreadLibraryCalls( instance );
|
2021-11-23 16:56:43 +01:00
|
|
|
return !NtQueryVirtualMemory( GetCurrentProcess(), instance, MemoryWineUnixFuncs,
|
|
|
|
&opencl_handle, sizeof(opencl_handle), NULL );
|
2021-03-16 05:44:50 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|