~hedgepigdaniel/dewobble

95ce7b640d67b93f076bff83699381388c87130f — Daniel Playfair Cal 2 years ago f452558
fix: work around OpenCV bug that releases the OpenCL context
1 files changed, 9 insertions(+), 0 deletions(-)

M src/filter/filter_sync.cpp
M src/filter/filter_sync.cpp => src/filter/filter_sync.cpp +9 -0
@@ 94,6 94,15 @@ void init_opencl_context(cl_context context, cl_device_id device)
    std::cerr << "Initialising OpenCV OpenCL context with platform \""
              << string(platform_name.begin(), platform_name.end()) << "\"\n";

    /**
     * OpenCV's `ocl::OpenCLExecutionContext::create` takes ownership of the
     * device and context, in the sense that when the thread exits it calls
     * clReleaseDevice and clReleaseContext on them. So, counteract this
     * behaviour by incrementing the refcount.
     */
    clRetainContext(context);
    clRetainDevice(device);

    ocl::OpenCLExecutionContext opencv_context =
        ocl::OpenCLExecutionContext::create(
            platform_name.data(), platform, context, device);