Hi all, I have question regarding the read/write of image2d_t pixels and hope someone can post a solution.
I am using MediaSDK to decompress images. After decompression the picture (NV12) resides in an IDirect3DSurface9.
With
cl_mem memY = clCreateFromDX9MediaSurfaceKHR(context, CL_MEM_READ_ONLY, CL_ADAPTER_D3D9EX_KHR, &surfaceIn, 0, &err);
and
clEnqueueAcquireDX9MediaSurfacesKHR(queue, 1, memY, 0, 0, 0));
I got a cl_mem handle(which is image2d_t type) and can be passed to my kernel
clSetKernelArg(m_kernel, 1, sizeof(cl_mem), (void*)&memY); // srcImg
Now it's possible to use it in my kernel
__kernel void Dummy(__read_only image2d_t srcY)
{
...
uint16 pix;
for (int i=0; i<16; i++)
{
float4 val= read_imagef(srcY, CLK_FILTER_NEAREST, sCoord);
pix[0]= convert_uint(val.x*255); // val.x is y value
}
...
This works pretty fine, but the performance of read_imagef (single pixel access) is very low.
As explained in the Sobel tutorial (https://software.intel.com/en-us/videos/optimizing-simple-opencl-kernels...), I would like to access the pixels in the form of uchar* like:
__global uchar* pSrcImage;
uint16 pix = convert_uint16(vload16(0, pSrcImage));
to read 16 pixel (256 bit) in a single memory access from the Y plane of the NV12 surface. This is possible, when I create a cl_mem with clCreateBuffer(), but I did not find a way to get access to the image2d_t data. The only way (I found) to read the pixels from image2d_t is with read_imagef() which is very slow.
My questions are:
How can I read the pixels of an image2d_t with vload() ?
or
Can I convert the DirectX surface to a cl_mem which is a "flat" buffer, and not a image2d_t?
Thanks for any help