! \brief Constructs a 1D Image in a specified context. * * Wraps clCreateImage(). */
| 3895 | * Wraps clCreateImage(). |
| 3896 | */ |
| 3897 | Image2D( |
| 3898 | const Context& context, |
| 3899 | cl_mem_flags flags, |
| 3900 | ImageFormat format, |
| 3901 | ::size_t width, |
| 3902 | ::size_t height, |
| 3903 | ::size_t row_pitch = 0, |
| 3904 | void* host_ptr = NULL, |
| 3905 | cl_int* err = NULL) |
| 3906 | { |
| 3907 | cl_int error; |
| 3908 | bool useCreateImage; |
| 3909 | |
| 3910 | #if defined(CL_VERSION_1_2) && defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) |
| 3911 | // Run-time decision based on the actual platform |
| 3912 | { |
| 3913 | cl_uint version = detail::getContextPlatformVersion(context()); |
| 3914 | useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above |
| 3915 | } |
| 3916 | #elif defined(CL_VERSION_1_2) |
| 3917 | useCreateImage = true; |
| 3918 | #else |
| 3919 | useCreateImage = false; |
| 3920 | #endif |
| 3921 | |
| 3922 | #if defined(CL_VERSION_1_2) |
| 3923 | if (useCreateImage) |
| 3924 | { |
| 3925 | cl_image_desc desc = |
| 3926 | { |
| 3927 | CL_MEM_OBJECT_IMAGE2D, |
| 3928 | width, |
| 3929 | height, |
| 3930 | 0, 0, // depth, array size (unused) |
| 3931 | row_pitch, |
| 3932 | 0, 0, 0, 0 |
| 3933 | }; |
| 3934 | object_ = ::clCreateImage( |
| 3935 | context(), |
| 3936 | flags, |
| 3937 | &format, |
| 3938 | &desc, |
| 3939 | host_ptr, |
| 3940 | &error); |
| 3941 | |
| 3942 | detail::errHandler(error, __CREATE_IMAGE_ERR); |
| 3943 | if (err != NULL) { |
| 3944 | *err = error; |
| 3945 | } |
| 3946 | } |
| 3947 | #endif // #if defined(CL_VERSION_1_2) |
| 3948 | #if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) |
| 3949 | if (!useCreateImage) |
| 3950 | { |
| 3951 | object_ = ::clCreateImage2D( |
| 3952 | context(), flags,&format, width, height, row_pitch, host_ptr, &error); |
| 3953 | |
| 3954 | detail::errHandler(error, __CREATE_IMAGE2D_ERR); |
nothing calls this directly
no test coverage detected