OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.
1663 Discussions

Can't share D3D11 Surface with OpenCL

word_t_
Beginner
259 Views

I am using Intel MediaSDK to decode h265 stream, and do some post processing using OpenCL, then output for rendering. I modified the sample_decode sample to let it decode h265 stream and rendered correctly with P010 format.

For d3d11 surface to OpenCL surface sharing, I queried the device and the extension is there. I was able to run the other sample correctly for the sharing. But with P010 frame format created from d3d11 device, I could not share the frame with OpenCL, when calling ptrToFunction_clCreateFromD3D11Texture2DKHR, it returns an error CL_INVALID_IMAGE_FORMAT_DESCRIPTOR

Is this expected? If yes is there any way to get around it? 

A separate question: is d3d11 surface available for writing? If yes what's the supported format? It looks like to read the surface, only a few format is supported (not P010). 

0 Kudos
1 Reply
Robert_I_Intel
Employee
259 Views

Unfortunately, none of the YUV formats are currently supported for either reading or writing. To get around that you can do a couple of things:

1. Create a temporary OpenCL buffer and copy P010 data there;

2. Write and launch YUV2RGB OpenCL Kernel (it is possible to find samples on the web, or you can roll your own based on http://stackoverflow.com/questions/4979504/fast-rgb-yuv-conversion-in-opencl)

3. Launch your processing kernel (should be (re)written for RGB format)

4. Write and launch RGB2YUV OpenCL Kernel (some examples here http://stackoverflow.com/questions/4979504/fast-rgb-yuv-conversion-in-opencl)

5. Copy the results from your OpenCL buffer into your P010 surface

Would this work: yes. Would the performance suck: probably yes, since you are copying things around, which is not ideal.

Another option is to do YUV2RGB and RGB2YUV on the CPU - you would need to figure out which approach is better.

 

d3d11 surface should be available for writing. Check this example out: https://software.intel.com/en-us/articles/sharing-surfaces-between-opencl-and-directx-11-on-intel-pr... . You can query your device for supported 2D formats, typically various RGBA, BGRA and single channel formats are supported, but supported formats really depend on the generation of your chip, e.g. 5th gen Intel(R) processor supports 55 various formats and 3rd gen chip supports only 47. Most notable additions are sRGBA format and SNORM data type support.

Reply