diff --git a/include/CL/opencl.hpp b/include/CL/opencl.hpp index ba4edafb..3179afac 100644 --- a/include/CL/opencl.hpp +++ b/include/CL/opencl.hpp @@ -2882,12 +2882,9 @@ class Platform : public detail::Wrapper */ cl_int getDevices( cl_device_type type, - vector* devices) const + vector& devices) const { cl_uint n = 0; - if( devices == nullptr ) { - return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR); - } cl_int err = CL_(clGetDeviceIDs)(object_, type, 0, nullptr, &n); if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) { return detail::errHandler(err, __GET_DEVICE_IDS_ERR); @@ -2905,18 +2902,31 @@ class Platform : public detail::Wrapper // with safe construction // We must retain things we obtain from the API to avoid releasing // API-owned objects. - if (devices) { - devices->resize(ids.size()); + devices.resize(ids.size()); - // Assign to param, constructing with retain behaviour - // to correctly capture each underlying CL object - for (size_type i = 0; i < ids.size(); i++) { - (*devices)[i] = Device(ids[i], true); - } + // Assign to param, constructing with retain behaviour + // to correctly capture each underlying CL object + for (size_type i = 0; i < ids.size(); i++) { + devices[i] = Device(ids[i], true); } return CL_SUCCESS; } + /*! \brief Gets a list of devices for this platform. + * + * Pointer overload for backwards compatibility. + */ + cl_int getDevices( + cl_device_type type, + vector* devices) const + { + if( devices == nullptr ) { + return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR); + } + + return getDevices(type, *devices); + } + #if defined(CL_HPP_USE_DX_INTEROP) /*! \brief Get the list of available D3D10 devices. * @@ -2945,7 +2955,7 @@ class Platform : public detail::Wrapper cl_d3d10_device_source_khr d3d_device_source, void * d3d_object, cl_d3d10_device_set_khr d3d_device_set, - vector* devices) const + vector& devices) const { typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)( cl_platform_id platform, @@ -2956,10 +2966,6 @@ class Platform : public detail::Wrapper cl_device_id * devices, cl_uint* num_devices); - if( devices == nullptr ) { - return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR); - } - static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = nullptr; #if CL_HPP_TARGET_OPENCL_VERSION >= 120 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR); @@ -2998,17 +3004,32 @@ class Platform : public detail::Wrapper // with safe construction // We must retain things we obtain from the API to avoid releasing // API-owned objects. - if (devices) { - devices->resize(ids.size()); + devices.resize(ids.size()); - // Assign to param, constructing with retain behaviour - // to correctly capture each underlying CL object - for (size_type i = 0; i < ids.size(); i++) { - (*devices)[i] = Device(ids[i], true); - } + // Assign to param, constructing with retain behaviour + // to correctly capture each underlying CL object + for (size_type i = 0; i < ids.size(); i++) { + devices[i] = Device(ids[i], true); } return CL_SUCCESS; } + + /*! \brief Get the list of available D3D10 devices. + * + * Pointer overload for backwards compatibility. + */ + cl_int getDevices( + cl_d3d10_device_source_khr d3d_device_source, + void * d3d_object, + cl_d3d10_device_set_khr d3d_device_set, + vector* devices) const + { + if( devices == nullptr ) { + return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR); + } + + return getDevices(d3d_device_source, d3d_object, d3d_device_set, *devices); + } #endif /*! \brief Gets a list of available platforms. @@ -3016,14 +3037,10 @@ class Platform : public detail::Wrapper * Wraps clGetPlatformIDs(). */ static cl_int get( - vector* platforms) + vector& platforms) { cl_uint n = 0; - if( platforms == nullptr ) { - return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR); - } - cl_int err = CL_(clGetPlatformIDs)(0, nullptr, &n); if (err != CL_SUCCESS) { return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); @@ -3035,17 +3052,29 @@ class Platform : public detail::Wrapper return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); } - if (platforms) { - platforms->resize(ids.size()); + platforms.resize(ids.size()); - // Platforms don't reference count - for (size_type i = 0; i < ids.size(); i++) { - (*platforms)[i] = Platform(ids[i]); - } + // Platforms don't reference count + for (size_type i = 0; i < ids.size(); i++) { + platforms[i] = Platform(ids[i]); } return CL_SUCCESS; } + /*! \brief Gets a list of available platforms. + * + * Pointer overload for backwards compatibility. + */ + static cl_int get( + vector* platforms) + { + if( platforms == nullptr ) { + return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR); + } + + return get(*platforms); + } + /*! \brief Gets the first available platform. * * Wraps clGetPlatformIDs(), returning the first result. @@ -3572,13 +3601,9 @@ class Context cl_int getSupportedImageFormats( cl_mem_flags flags, cl_mem_object_type type, - vector* formats) const + vector& formats) const { cl_uint numEntries; - - if (!formats) { - return CL_SUCCESS; - } cl_int err = CL_(clGetSupportedImageFormats)( object_, @@ -3604,16 +3629,31 @@ class Context return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR); } - formats->assign(value.begin(), value.end()); + formats.assign(value.begin(), value.end()); } else { // If no values are being returned, ensure an empty vector comes back - formats->clear(); + formats.clear(); } return CL_SUCCESS; } + /*! \brief Gets a list of supported image formats. + * + * Pointer overload for backwards compatibility. + */ + cl_int getSupportedImageFormats( + cl_mem_flags flags, + cl_mem_object_type type, + vector* formats) const + { + if (!formats) { + return CL_SUCCESS; + } + return getSupportedImageFormats(flags, type, *formats); + } + #if defined(cl_ext_image_requirements_info) template cl_int getImageRequirementsInfoExt(cl_image_requirements_info_ext name,