I'm creating an OpenFX plugin to do some image processing for a VR system.
As both our existing processing code, and the host the plugin is intended for, are based on OpenCL, the host developers have given me an extension to OFX to share the OpenCL environment.
However - our code uses the C++ API (cl::Context), and the extension they've provided gives me a pointer to a C cl_context.
Is there any way for me to create a cl::Context from a cl_context, without taking ownership of the latter? (and the same for the cl::CommandQueue from cl_command_queue). The API docs online suggest that both the copy constructor and assignment operator take ownership.
Fortunately you can inspect the OpenCL C++ header to see exactly what it does (at the bottom it just makes C API calls), and you can step into the code to verify it. When working with both C and C++ API, you must be careful about the OpenCL object retain/release counts, in particular if the C++ constructor doesn't retain but the destructor does release, then you have a problem (because you'd be releasing the host's context out from under them). However, it is easily fixed because you can just call retain yourself on the object after constructing to balance things out. I've mixed C API and C++ API in OpenCL and it was the retain/release philosophy of the C++ header that got me too, so I feel your pain. Curious, is the OpenFX host Resolve, Vegas, Catalyst, or something else? There's a unified OpenCL extension on the way for OpenFX.