As I'm exploring some ways to composite (custom overlay) multiple images into one and I found this great article https://towardsdatascience.com/get-started-with-gpu-image-processing-15e34b787480. My only issue is that I need to pass multiple buffers to the kernel as an argument and not one.
So, in python I created a list with multiple buffers
inImgsBuffers = [cl.Image(context, cl.mem_flags.READ_ONLY, cl.ImageFormat(cl.channel_order.RGBA, cl.channel_type.UNORM_INT8), shape=inShape) for inImg in inImgs]
and then tried passing them as the argument
kernel.set_arg(0, inImgsBuffers) # input image buffer
Then, on Kernel I thought to use the image2d_array_t instead of image2d_t
__kernel void morphOpKernel(__read_only image2d_array_t ins, __write_only image2d_t out)
but I'm getting the following error.
pyopencl._cl.LogicError: Kernel.set_arg failed: INVALID_VALUE - invalid kernel argument
Any ideas on what I'm doing wrong?
image2d_array_tis a special OpenCL type. So, it is not possible to create the list ofpyopencl.Imageobjects and pass it to the kernel. Instead of it, you need to create the object ofpyopencl.Imagewith special format that means that it is an array of 2D images: