File size: 3,722 Bytes
dffe123 | 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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | // This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Copyright (C) 2021 Intel Corporation
#include <stdexcept>
#include <opencv2/gapi/streaming/onevpl/device_selector_interface.hpp>
#include <opencv2/gapi/own/assert.hpp>
namespace cv {
namespace gapi {
namespace wip {
namespace onevpl {
const char* to_cstring(AccelType type) {
switch(type) {
case AccelType::HOST:
return "HOST";
case AccelType::DX11:
return "DX11";
case AccelType::VAAPI:
return "VAAPI";
default:
GAPI_DbgAssert(false && "Unexpected AccelType");
break;
}
return "UNKNOWN";
}
Device::Device(Ptr device_ptr, const std::string& device_name, AccelType device_type) :
name(device_name),
ptr(device_ptr),
type(device_type) {
}
Device::~Device() {
}
const std::string& Device::get_name() const {
return name;
}
Device::Ptr Device::get_ptr() const {
return ptr;
}
AccelType Device::get_type() const {
return type;
}
Context::Context(Ptr ctx_ptr, AccelType ctx_type) :
ptr(ctx_ptr),
type(ctx_type) {
}
Context::~Context() {
}
Context::Ptr Context::get_ptr() const {
return ptr;
}
AccelType Context::get_type() const {
return type;
}
IDeviceSelector::Score::Score(Type val) :
value(val) {
}
IDeviceSelector::Score::~Score() {
}
IDeviceSelector::Score::operator Type () const {
return value;
}
IDeviceSelector::Score::Type IDeviceSelector::Score::get() const {
return value;
}
IDeviceSelector::~IDeviceSelector() {
}
namespace detail
{
struct DeviceContextCreator : public IDeviceSelector {
DeviceScoreTable select_devices() const override { return {};}
DeviceContexts select_context() override { return {};}
template<typename Entity, typename ...Args>
static Entity create_entity(Args &&...args) {
return IDeviceSelector::create<Entity>(std::forward<Args>(args)...);
}
};
}
Device create_host_device() {
return detail::DeviceContextCreator::create_entity<Device>(nullptr,
"CPU",
AccelType::HOST);
}
Context create_host_context() {
return detail::DeviceContextCreator::create_entity<Context>(nullptr,
AccelType::HOST);
}
Device create_dx11_device(Device::Ptr device_ptr,
const std::string& device_name) {
return detail::DeviceContextCreator::create_entity<Device>(device_ptr,
device_name,
AccelType::DX11);
}
Context create_dx11_context(Context::Ptr ctx_ptr) {
return detail::DeviceContextCreator::create_entity<Context>(ctx_ptr,
AccelType::DX11);
}
Device create_vaapi_device(Device::Ptr device_ptr,
const std::string& device_name) {
return detail::DeviceContextCreator::create_entity<Device>(device_ptr,
device_name,
AccelType::VAAPI);
}
Context create_vaapi_context(Context::Ptr ctx_ptr) {
return detail::DeviceContextCreator::create_entity<Context>(ctx_ptr,
AccelType::VAAPI);
}
} // namespace onevpl
} // namespace wip
} // namespace gapi
} // namespace cv
|