Hi Team,
We are trying to use CLK_FILTER_LINEAR flag in sampler with read_imagef but it's returning either 0 or garbage value.
OpenCL Version 1.2 & Hardware imx8
Below is the code snippet for the reference...
(Source code)
cl_image_format format;
format.image_channel_order = CL_R; //Note: Our Image is having only one channel.
format.image_channel_data_type = CL_FLOAT;
size_t width = imageWidth;
size_t height = imageHeight;
image = clCreateImage2D(context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, &format, width, height, 0, imageHost, &err); //Note: imageHost is a float pointer.
(Kernel)
__constant sampler_t search_sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_LINEAR;
__kernel void readImage(__read_only image2d_t img)
{
float4 value = read_imagef(img, search_sampler, (float2)(coord.x, coord.y));
printf("Values are %f %f %f %f \n", value.x, value.y, value.z, value.w);
}
It would be very helpful if you can provide us the same kinda code snippet on how to use CLK_FILTER_LINEAR. And we would love if that code gives the actual value of the coord in image instead of normalized.
Note:
If we use CLK_FILTER_NEAREST with channel data type uint8 and read_imageui, it works perfectly.