MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / Image2D

Method Image2D

include/CL/opencl.hpp:4791–4851  ·  view source on GitHub ↗

! \brief Constructs a 2D Image in a specified context. * * Wraps clCreateImage(). */

Source from the content-addressed store, hash-verified

4789 * Wraps clCreateImage().
4790 */
4791 Image2D(
4792 const Context& context,
4793 cl_mem_flags flags,
4794 ImageFormat format,
4795 size_type width,
4796 size_type height,
4797 size_type row_pitch = 0,
4798 void* host_ptr = nullptr,
4799 cl_int* err = nullptr)
4800 {
4801 cl_int error;
4802 bool useCreateImage;
4803
4804#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
4805 // Run-time decision based on the actual platform
4806 {
4807 cl_uint version = detail::getContextPlatformVersion(context());
4808 useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above
4809 }
4810#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
4811 useCreateImage = true;
4812#else
4813 useCreateImage = false;
4814#endif
4815
4816#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4817 if (useCreateImage)
4818 {
4819 cl_image_desc desc = {};
4820 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4821 desc.image_width = width;
4822 desc.image_height = height;
4823 desc.image_row_pitch = row_pitch;
4824
4825 object_ = ::clCreateImage(
4826 context(),
4827 flags,
4828 &format,
4829 &desc,
4830 host_ptr,
4831 &error);
4832
4833 detail::errHandler(error, __CREATE_IMAGE_ERR);
4834 if (err != nullptr) {
4835 *err = error;
4836 }
4837 }
4838#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
4839#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4840 if (!useCreateImage)
4841 {
4842 object_ = ::clCreateImage2D(
4843 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
4844
4845 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
4846 if (err != nullptr) {
4847 *err = error;
4848 }

Callers

nothing calls this directly

Calls 3

clCreateImageFunction · 0.85
errHandlerFunction · 0.85

Tested by

no test coverage detected