AnsweredAssumed Answered

use GPU openCL to convert YUY2 to RGB

Question asked by Weide Ding on Sep 4, 2019
Latest reply on Sep 11, 2019 by Weide Ding

    I am using MX8MQ GPU to convert YUY2 to RGB for 1080P@30fps camera. clEnqueueNDRangeKernel executes 30ms,  but  clEnqueueReadBuffer takes long time > 70ms to finish reading. I think this buffer is from part of LPDDR4, and is controlled by GPU, why does clEnqueueReadBuffer need so long time?  Normally, CPU's memcpy 1080x1920x3bytes, just takes 4ms.


   use sample code from  arch64-mx8m-poky-linux\imx-gpu-sdk\5.3.0-r0\git\DemoApps\OpenCL\SoftISP:


void ConvertToRGBA(const Kernel& kernel, const Buffer& inBuffer, Buffer& outBuffer, const CommandQueue& commandQueue, void* ptr)



      clSetKernelArg(kernel.Get(), 0, sizeof(cl_mem), inBuffer.GetPointer());

      clSetKernelArg(kernel.Get(), 1, sizeof(cl_mem), outBuffer.GetPointer());

      RAPIDOPENCL_CHECK(clEnqueueNDRangeKernel(commandQueue.Get(), kernel.Get(), 2, nullptr, globalWorkSize, localWorkSize, 0, nullptr, &event));

      RAPIDOPENCL_CHECK(clWaitForEvents(1, &event));   //GPU need 30ms



        clEnqueueReadBuffer(commandQueue.Get(), outBuffer.Get(), CL_FALSE, 0, sizeof(cl_char) * imgSize * 4, ptr, 0, nullptr, nullptr));  //read >70ms



Thanks for your atttention!