gpuContext.cpp 1.28 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
// Copyright (c) 2012-2017 VideoStitch SAS
// Copyright (c) 2018 stitchEm

#include "libvideostitch/context.hpp"

#include "context.hpp"

namespace VideoStitch {
namespace GPU {

namespace Context {

Status compileAllKernels(const bool aheadOfTime, Util::Algorithm::ProgressReporter* pReporter) {
  const auto& potContext = getContext();
  FAIL_RETURN(potContext.status());
  return potContext.value().compileAllPrograms(pReporter, aheadOfTime);
}

/**
 * Compile all the OpenCL programs for the selected device.
 * @param device The device delected
 * @param aheadOfTime if true, only compile the programs that are marked as likelyUsed
 * @param progress if non-null, used as progress indicator.
 */
Status compileAllKernelsOnSelectedDevice(int device, const bool aheadOfTime,
                                         Util::Algorithm::ProgressReporter* pReporter) {
  FAIL_RETURN(VideoStitch::GPU::setDefaultBackendDeviceVS(device));
  FAIL_RETURN(GPU::Context::compileAllKernels(aheadOfTime, pReporter));
  return Status::OK();
}

Status destroy() { return destroyOpenCLContext(); }

Status setDefaultBackendDeviceAndCheck(const int vsDeviceID) {
  FAIL_RETURN(setDefaultBackendDeviceVS(vsDeviceID));
  return getContext().status();
}

}  // namespace Context

}  // namespace GPU
}  // namespace VideoStitch