diff --git a/dlls/opencl/make_opencl b/dlls/opencl/make_opencl index c2c4d7f6e63..6d9881c84b3 100755 --- a/dlls/opencl/make_opencl +++ b/dlls/opencl/make_opencl @@ -315,6 +315,17 @@ sub needs_pe_wrapper($) # deprecated and absent from headers "clSetCommandQueueProperty" => 1, + + # needs GL object unwrapping + "clCreateFromGLBuffer" => 1, + "clCreateFromGLRenderbuffer" => 1, + "clCreateFromGLTexture" => 1, + "clCreateFromGLTexture2D" => 1, + "clCreateFromGLTexture3D" => 1, + "clEnqueueAcquireGLObjects" => 1, + "clEnqueueReleaseGLObjects" => 1, + "clGetGLObjectInfo" => 1, + "clGetGLTextureInfo" => 1, ); my $name = shift; @@ -349,6 +360,17 @@ sub needs_unix_function($) "clGetExtensionFunctionAddress" => 1, "clGetExtensionFunctionAddressForPlatform" => 1, "clSetCommandQueueProperty" => 1, + + # not yet implemented + "clCreateFromGLBuffer" => 1, + "clCreateFromGLRenderbuffer" => 1, + "clCreateFromGLTexture" => 1, + "clCreateFromGLTexture2D" => 1, + "clCreateFromGLTexture3D" => 1, + "clEnqueueAcquireGLObjects" => 1, + "clEnqueueReleaseGLObjects" => 1, + "clGetGLObjectInfo" => 1, + "clGetGLTextureInfo" => 1, ); my $name = shift; @@ -373,12 +395,29 @@ my %all_functions; my %all_enums; my %all_types; -sub parse_feature($) +sub parse_feature($$) { - my $feature = shift; + my ($feature, $is_core) = @_; + + my %extra_core_functions = + ( + # these are not core, but exported from the loader anyway + "clCreateFromGLBuffer" => 1, + "clCreateFromGLRenderbuffer" => 1, + "clCreateFromGLTexture" => 1, + "clCreateFromGLTexture2D" => 1, + "clCreateFromGLTexture3D" => 1, + "clEnqueueAcquireGLObjects" => 1, + "clEnqueueReleaseGLObjects" => 1, + "clGetGLObjectInfo" => 1, + "clGetGLTextureInfo" => 1, + ); foreach my $cmd ($feature->findnodes("./require/command")) { + # TODO: store these in a separate list + next unless $is_core or defined $extra_core_functions{$cmd->{name}}; + $core_functions{$cmd->{name}} = $all_functions{$cmd->{name}}; } foreach my $enum ($feature->findnodes("./require/enum")) @@ -454,10 +493,10 @@ sub parse_file($) # generate core functions foreach my $feature ($xml->findnodes("/registry/feature")) { - parse_feature($feature) if defined $core_categories{$feature->{name}}; + parse_feature($feature, 1) if defined $core_categories{$feature->{name}}; } - # generate extension list + # generate extension list and functions foreach my $ext ($xml->findnodes("/registry/extensions/extension")) { # we currently don't support clGetExtensionFunctionAddress, and @@ -465,6 +504,11 @@ sub parse_file($) # we need to generate a table of thunks per platform and retrieve the # platform from the called object $unsupported_extensions{lc($ext->{name})} = 1 if $ext->findnodes("./require/command"); + + # FIXME: Parse all supported extensions. Note that we don't actually + # support KHR_gl_sharing yet, but we need to export the functions anyway + # (some applications expect them to be present). + parse_feature($ext, 0) if lc($ext->{name}) eq "cl_khr_gl_sharing"; } } diff --git a/dlls/opencl/opencl.spec b/dlls/opencl/opencl.spec index 2560e82ad5e..31270c05e19 100644 --- a/dlls/opencl/opencl.spec +++ b/dlls/opencl/opencl.spec @@ -4,6 +4,11 @@ @ stdcall clCreateCommandQueue(ptr ptr int64 ptr) @ stdcall clCreateContext(ptr long ptr ptr ptr ptr) @ stdcall clCreateContextFromType(ptr int64 ptr ptr ptr) +@ stdcall clCreateFromGLBuffer(ptr int64 long ptr) +@ stdcall clCreateFromGLRenderbuffer(ptr int64 long ptr) +@ stdcall clCreateFromGLTexture(ptr int64 long long long ptr) +@ stdcall clCreateFromGLTexture2D(ptr int64 long long long ptr) +@ stdcall clCreateFromGLTexture3D(ptr int64 long long long ptr) @ stdcall clCreateImage(ptr int64 ptr ptr ptr ptr) @ stdcall clCreateImage2D(ptr int64 ptr long long long ptr ptr) @ stdcall clCreateImage3D(ptr int64 ptr long long long long long ptr ptr) @@ -16,6 +21,7 @@ @ stdcall clCreateSubBuffer(ptr int64 long ptr ptr) @ stdcall clCreateSubDevices(ptr ptr long ptr ptr) @ stdcall clCreateUserEvent(ptr ptr) +@ stdcall clEnqueueAcquireGLObjects(ptr long ptr long ptr ptr) @ stdcall clEnqueueBarrier(ptr) @ stdcall clEnqueueBarrierWithWaitList(ptr long ptr ptr) @ stdcall clEnqueueCopyBuffer(ptr ptr ptr long long long long ptr ptr) @@ -35,6 +41,7 @@ @ stdcall clEnqueueReadBuffer(ptr ptr long long long ptr long ptr ptr) @ stdcall clEnqueueReadBufferRect(ptr ptr long ptr ptr ptr long long long long ptr long ptr ptr) @ stdcall clEnqueueReadImage(ptr ptr long ptr ptr long long ptr long ptr ptr) +@ stdcall clEnqueueReleaseGLObjects(ptr long ptr long ptr ptr) @ stdcall clEnqueueTask(ptr ptr long ptr ptr) @ stdcall clEnqueueUnmapMemObject(ptr ptr ptr long ptr ptr) @ stdcall clEnqueueWaitForEvents(ptr long ptr) @@ -51,6 +58,8 @@ @ stdcall clGetEventProfilingInfo(ptr long long ptr ptr) @ stdcall clGetExtensionFunctionAddress(ptr) @ stdcall clGetExtensionFunctionAddressForPlatform(ptr ptr) +@ stdcall clGetGLObjectInfo(ptr ptr ptr) +@ stdcall clGetGLTextureInfo(ptr long long ptr ptr) @ stdcall clGetImageInfo(ptr long long ptr ptr) @ stdcall clGetKernelArgInfo(ptr long long long ptr ptr) @ stdcall clGetKernelInfo(ptr long long ptr ptr) diff --git a/dlls/opencl/opencl_types.h b/dlls/opencl/opencl_types.h index 7acd4a77f76..b116bb55259 100644 --- a/dlls/opencl/opencl_types.h +++ b/dlls/opencl/opencl_types.h @@ -79,6 +79,10 @@ typedef struct _cl_image_desc cl_mem mem_object; }; } cl_image_desc; +typedef cl_uint cl_gl_context_info; +typedef cl_uint cl_gl_object_type; +typedef cl_uint cl_gl_texture_info; +typedef cl_uint cl_gl_platform_info; #define CL_A 0x10B1 #define CL_ADDRESS_CLAMP 0x1132 @@ -95,6 +99,7 @@ typedef struct _cl_image_desc #define CL_BUILD_NONE -1 #define CL_BUILD_PROGRAM_FAILURE -11 #define CL_BUILD_SUCCESS 0 +#define CL_CGL_SHAREGROUP_KHR 0x200C #define CL_CHAR_BIT 8 #define CL_CHAR_MAX CL_SCHAR_MAX #define CL_CHAR_MIN CL_SCHAR_MIN @@ -132,6 +137,7 @@ typedef struct _cl_image_desc #define CL_CONTEXT_PLATFORM 0x1084 #define CL_CONTEXT_PROPERTIES 0x1082 #define CL_CONTEXT_REFERENCE_COUNT 0x1080 +#define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 0x2006 #define CL_DBL_DIG 15 #define CL_DBL_EPSILON 2.220446049250313080847e-16 #define CL_DBL_MANT_DIG 53 @@ -142,6 +148,7 @@ typedef struct _cl_image_desc #define CL_DBL_MIN_10_EXP -307 #define CL_DBL_MIN_EXP -1021 #define CL_DBL_RADIX 2 +#define CL_DEVICES_FOR_GL_CONTEXT_KHR 0x2007 #define CL_DEVICE_ADDRESS_BITS 0x100D #define CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE (1 << 4) #define CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE (1 << 3) @@ -234,6 +241,7 @@ typedef struct _cl_image_desc #define CL_DEVICE_VENDOR_ID 0x1001 #define CL_DEVICE_VERSION 0x102F #define CL_DRIVER_VERSION 0x102D +#define CL_EGL_DISPLAY_KHR 0x2009 #define CL_EVENT_COMMAND_EXECUTION_STATUS 0x11D3 #define CL_EVENT_COMMAND_QUEUE 0x11D0 #define CL_EVENT_COMMAND_TYPE 0x11D1 @@ -265,6 +273,19 @@ typedef struct _cl_image_desc #define CL_FP_ROUND_TO_ZERO (1 << 3) #define CL_FP_SOFT_FLOAT (1 << 6) #define CL_GLOBAL 0x2 +#define CL_GLX_DISPLAY_KHR 0x200A +#define CL_GL_CONTEXT_KHR 0x2008 +#define CL_GL_MIPMAP_LEVEL 0x2005 +#define CL_GL_NUM_SAMPLES 0x2012 +#define CL_GL_OBJECT_BUFFER 0x2000 +#define CL_GL_OBJECT_RENDERBUFFER 0x2003 +#define CL_GL_OBJECT_TEXTURE1D 0x200F +#define CL_GL_OBJECT_TEXTURE1D_ARRAY 0x2010 +#define CL_GL_OBJECT_TEXTURE2D 0x2001 +#define CL_GL_OBJECT_TEXTURE2D_ARRAY 0x200E +#define CL_GL_OBJECT_TEXTURE3D 0x2002 +#define CL_GL_OBJECT_TEXTURE_BUFFER 0x2011 +#define CL_GL_TEXTURE_TARGET 0x2004 #define CL_HALF_FLOAT 0x10DD #define CL_HUGE_VAL ((cl_double) 1e500) #define CL_HUGE_VALF ((cl_float) 1e50) @@ -302,6 +323,7 @@ typedef struct _cl_image_desc #define CL_INVALID_GLOBAL_OFFSET -56 #define CL_INVALID_GLOBAL_WORK_SIZE -63 #define CL_INVALID_GL_OBJECT -60 +#define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000 #define CL_INVALID_HOST_PTR -37 #define CL_INVALID_IMAGE_DESCRIPTOR -65 #define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -39 @@ -474,3 +496,4 @@ typedef struct _cl_image_desc #define CL_UNSIGNED_INT32 0x10DC #define CL_UNSIGNED_INT8 0x10DA #define CL_USHRT_MAX 65535 +#define CL_WGL_HDC_KHR 0x200B diff --git a/dlls/opencl/pe_wrappers.c b/dlls/opencl/pe_wrappers.c index 158f255d4e6..29ae1afaaff 100644 --- a/dlls/opencl/pe_wrappers.c +++ b/dlls/opencl/pe_wrappers.c @@ -21,6 +21,7 @@ #include "opencl_private.h" #include "opencl_types.h" #include "unixlib.h" +#include "wine/wgl.h" WINE_DEFAULT_DEBUG_CHANNEL(opencl); @@ -202,6 +203,82 @@ void * WINAPI clGetExtensionFunctionAddressForPlatform( cl_platform_id platform, } +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; +} + + BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved ) { if (reason == DLL_PROCESS_ATTACH)