#else
#include <dlfcn.h> //dlopen, dlsym, dlclose
#if SYS_MACOSX
-#define ocl_open dlopen( "libOpenCL.dylib", RTLD_NOW )
+#define ocl_open dlopen( "/System/Library/Frameworks/OpenCL.framework/OpenCL", RTLD_NOW )
#else
#define ocl_open dlopen( "libOpenCL.so", RTLD_NOW )
#endif
/* Try to load the cached compiled program binary, verify the device context is
* still valid before reuse */
-static cl_program x264_opencl_cache_load( x264_t *h, char *devname, char *devvendor, char *driverversion )
+static cl_program x264_opencl_cache_load( x264_t *h, char *dev_name, char *dev_vendor, char *driver_version )
{
/* try to load cached program binary */
FILE *fp = fopen( h->param.psz_clbin_file, "rb" );
}\
} while( 0 )
- CHECK_STRING( devname );
- CHECK_STRING( devvendor );
- CHECK_STRING( driverversion );
+ CHECK_STRING( dev_name );
+ CHECK_STRING( dev_vendor );
+ CHECK_STRING( driver_version );
CHECK_STRING( x264_opencl_source_hash );
#undef CHECK_STRING
/* Save the compiled program binary to a file for later reuse. Device context
* is also saved in the cache file so we do not reuse stale binaries */
-static void x264_opencl_cache_save( x264_t *h, cl_program program, char *devname, char *devvendor, char *driverversion )
+static void x264_opencl_cache_save( x264_t *h, cl_program program, char *dev_name, char *dev_vendor, char *driver_version )
{
FILE *fp = fopen( h->param.psz_clbin_file, "wb" );
if( !fp )
status = ocl->clGetProgramInfo( program, CL_PROGRAM_BINARIES, sizeof(uint8_t *), &binary, NULL );
if( status == CL_SUCCESS )
{
- fputs( devname, fp );
+ fputs( dev_name, fp );
fputc( '\n', fp );
- fputs( devvendor, fp );
+ fputs( dev_vendor, fp );
fputc( '\n', fp );
- fputs( driverversion, fp );
+ fputs( driver_version, fp );
fputc( '\n', fp );
fputs( x264_opencl_source_hash, fp );
fputc( '\n', fp );
cl_program program;
cl_int status;
- char devname[64];
- char devvendor[64];
- char driverversion[64];
- status = ocl->clGetDeviceInfo( h->opencl.device, CL_DEVICE_NAME, sizeof(devname), devname, NULL );
- status |= ocl->clGetDeviceInfo( h->opencl.device, CL_DEVICE_VENDOR, sizeof(devvendor), devvendor, NULL );
- status |= ocl->clGetDeviceInfo( h->opencl.device, CL_DRIVER_VERSION, sizeof(driverversion), driverversion, NULL );
+ char dev_name[64];
+ char dev_vendor[64];
+ char driver_version[64];
+ status = ocl->clGetDeviceInfo( h->opencl.device, CL_DEVICE_NAME, sizeof(dev_name), dev_name, NULL );
+ status |= ocl->clGetDeviceInfo( h->opencl.device, CL_DEVICE_VENDOR, sizeof(dev_vendor), dev_vendor, NULL );
+ status |= ocl->clGetDeviceInfo( h->opencl.device, CL_DRIVER_VERSION, sizeof(driver_version), driver_version, NULL );
if( status != CL_SUCCESS )
return NULL;
// Most AMD GPUs have vector registers
- int vectorize = !strcmp( devvendor, "Advanced Micro Devices, Inc." );
+ int vectorize = !strcmp( dev_vendor, "Advanced Micro Devices, Inc." );
h->opencl.b_device_AMD_SI = 0;
if( vectorize )
}
}
- x264_log( h, X264_LOG_INFO, "OpenCL acceleration enabled with %s %s %s\n", devvendor, devname, h->opencl.b_device_AMD_SI ? "(SI)" : "" );
+ x264_log( h, X264_LOG_INFO, "OpenCL acceleration enabled with %s %s %s\n", dev_vendor, dev_name, h->opencl.b_device_AMD_SI ? "(SI)" : "" );
- program = x264_opencl_cache_load( h, devname, devvendor, driverversion );
+ program = x264_opencl_cache_load( h, dev_name, dev_vendor, driver_version );
if( !program )
{
/* clCreateProgramWithSource() requires a pointer variable, you cannot just use &x264_opencl_source */
status = ocl->clBuildProgram( program, 1, &h->opencl.device, buildopts, NULL, NULL );
if( status == CL_SUCCESS )
{
- x264_opencl_cache_save( h, program, devname, devvendor, driverversion );
+ x264_opencl_cache_save( h, program, dev_name, dev_vendor, driver_version );
return program;
}
return -1;
}
-static void x264_opencl_error_notify( const char *errinfo, const void *private_info, size_t cb, void *user_data )
+static void CL_CALLBACK x264_opencl_error_notify( const char *errinfo, const void *private_info, size_t cb, void *user_data )
{
/* Any error notification can be assumed to be fatal to the OpenCL context.
* We need to stop using it immediately to prevent further damage. */
x264_free( imageType );
if( !b_has_r || !b_has_rgba )
{
- char devname[64];
- status = ocl->clGetDeviceInfo( h->opencl.device, CL_DEVICE_NAME, sizeof(devname), devname, NULL );
+ char dev_name[64];
+ status = ocl->clGetDeviceInfo( h->opencl.device, CL_DEVICE_NAME, sizeof(dev_name), dev_name, NULL );
if( status == CL_SUCCESS )
{
/* emit warning if we are discarding the user's explicit choice */
int level = h->param.opencl_device_id ? X264_LOG_WARNING : X264_LOG_DEBUG;
- x264_log( h, level, "OpenCL: %s does not support required image formats\n", devname);
+ x264_log( h, level, "OpenCL: %s does not support required image formats\n", dev_name);
}
ocl->clReleaseContext( context );
continue;
#ifdef __APPLE__
#define CL_EXTENSION_WEAK_LINK __attribute__((weak_import))
- #define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
- #define CL_EXT_SUFFIX__VERSION_1_0 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
- #define CL_API_SUFFIX__VERSION_1_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
- #define GCL_API_SUFFIX__VERSION_1_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
- #define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
- #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7
-
+ #ifndef UNAVAILABLE_ATTRIBUTE
+ #define UNAVAILABLE_ATTRIBUTE
+ #endif
+ #ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+ #define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+ #define CL_EXT_SUFFIX__VERSION_1_0 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+ #else
+ #define CL_API_SUFFIX__VERSION_1_0 UNAVAILABLE_ATTRIBUTE
+ #define CL_EXT_SUFFIX__VERSION_1_0 CL_EXTENSION_WEAK_LINK UNAVAILABLE_ATTRIBUTE
+ #endif
+ #ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define CL_API_SUFFIX__VERSION_1_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define GCL_API_SUFFIX__VERSION_1_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7
+ #else
+ #define CL_API_SUFFIX__VERSION_1_1 UNAVAILABLE_ATTRIBUTE
+ #define GCL_API_SUFFIX__VERSION_1_1 UNAVAILABLE_ATTRIBUTE
+ #define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK UNAVAILABLE_ATTRIBUTE
+ #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATE CL_EXT_SUFFIX__VERSION_1_0
+ #endif
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
#define CL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
#define GCL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8
#else
- #warning This path should never happen outside of internal operating system development. AvailabilityMacros do not function correctly here!
- #define CL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
- #define GCL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
- #define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
- #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define CL_API_SUFFIX__VERSION_1_2 UNAVAILABLE_ATTRIBUTE
+ #define GCL_API_SUFFIX__VERSION_1_2 UNAVAILABLE_ATTRIBUTE
+ #define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK UNAVAILABLE_ATTRIBUTE
+ #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+ #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXT_SUFFIX__VERSION_1_1
#endif
#else
#define CL_EXTENSION_WEAK_LINK