mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge pull request #13008 from dbudniko:dbudniko/gpu_opencl_backend
G-API GPU-OpenCL backend (#13008) * gpu/ocl backend core * accuracy tests added and adjusted + license headers * GPU perf. tests added; almost all adjusted to pass * all tests adjusted and passed - ready for pull request * missing license headers * fix warning (workaround RGB2Gray) * fix c++ magic * precompiled header * white spaces * try to fix warning and blur test * try to fix Blur perf tests * more alignments with the latest cpu backend * more gapi tests refactoring + 1 more UB issue fix + more informative tolerance exceed reports * white space fix * try workaround for SumTest * GAPI_EXPORTS instead CV_EXPORTS
This commit is contained in:
committed by
Alexander Alekhin
parent
ebc8015638
commit
5087ff0814
@@ -83,20 +83,41 @@ namespace magazine {
|
||||
|
||||
// FIXME implement the below functions with visit()?
|
||||
|
||||
void bindInArg(Mag& mag, const RcDesc &rc, const GRunArg &arg)
|
||||
void bindInArg(Mag& mag, const RcDesc &rc, const GRunArg &arg, bool is_umat)
|
||||
{
|
||||
switch (rc.shape)
|
||||
{
|
||||
case GShape::GMAT:
|
||||
{
|
||||
auto& mag_mat = mag.template slot<cv::gapi::own::Mat>()[rc.id];
|
||||
switch (arg.index())
|
||||
{
|
||||
case GRunArg::index_of<cv::gapi::own::Mat>() : mag_mat = util::get<cv::gapi::own::Mat>(arg); break;
|
||||
case GRunArg::index_of<cv::gapi::own::Mat>() :
|
||||
if (is_umat)
|
||||
{
|
||||
auto& mag_umat = mag.template slot<cv::UMat>()[rc.id];
|
||||
mag_umat = to_ocv(util::get<cv::gapi::own::Mat>(arg)).getUMat(ACCESS_READ);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& mag_mat = mag.template slot<cv::gapi::own::Mat>()[rc.id];
|
||||
mag_mat = util::get<cv::gapi::own::Mat>(arg);
|
||||
}
|
||||
break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::Mat>() : mag_mat = to_own(util::get<cv::Mat>(arg)); break;
|
||||
case GRunArg::index_of<cv::Mat>() :
|
||||
if (is_umat)
|
||||
{
|
||||
auto& mag_umat = mag.template slot<cv::UMat>()[rc.id];
|
||||
mag_umat = (util::get<cv::UMat>(arg));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& mag_mat = mag.template slot<cv::gapi::own::Mat>()[rc.id];
|
||||
mag_mat = to_own(util::get<cv::Mat>(arg));
|
||||
}
|
||||
break;
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -125,20 +146,41 @@ void bindInArg(Mag& mag, const RcDesc &rc, const GRunArg &arg)
|
||||
}
|
||||
}
|
||||
|
||||
void bindOutArg(Mag& mag, const RcDesc &rc, const GRunArgP &arg)
|
||||
void bindOutArg(Mag& mag, const RcDesc &rc, const GRunArgP &arg, bool is_umat)
|
||||
{
|
||||
switch (rc.shape)
|
||||
{
|
||||
case GShape::GMAT:
|
||||
{
|
||||
auto& mag_mat = mag.template slot<cv::gapi::own::Mat>()[rc.id];
|
||||
switch (arg.index())
|
||||
{
|
||||
case GRunArgP::index_of<cv::gapi::own::Mat*>() : mag_mat = * util::get<cv::gapi::own::Mat*>(arg); break;
|
||||
case GRunArgP::index_of<cv::gapi::own::Mat*>() :
|
||||
if (is_umat)
|
||||
{
|
||||
auto& mag_umat = mag.template slot<cv::UMat>()[rc.id];
|
||||
mag_umat = to_ocv(*(util::get<cv::gapi::own::Mat*>(arg))).getUMat(ACCESS_RW);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& mag_mat = mag.template slot<cv::gapi::own::Mat>()[rc.id];
|
||||
mag_mat = *util::get<cv::gapi::own::Mat*>(arg);
|
||||
}
|
||||
break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::Mat*>() : mag_mat = to_own(* util::get<cv::Mat*>(arg)); break;
|
||||
case GRunArgP::index_of<cv::Mat*>() :
|
||||
if (is_umat)
|
||||
{
|
||||
auto& mag_umat = mag.template slot<cv::UMat>()[rc.id];
|
||||
mag_umat = (*util::get<cv::UMat*>(arg));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& mag_mat = mag.template slot<cv::gapi::own::Mat>()[rc.id];
|
||||
mag_mat = to_own(*util::get<cv::Mat*>(arg));
|
||||
}
|
||||
break;
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -208,11 +250,15 @@ cv::GRunArg getArg(const Mag& mag, const RcDesc &ref)
|
||||
}
|
||||
}
|
||||
|
||||
cv::GRunArgP getObjPtr(Mag& mag, const RcDesc &rc)
|
||||
cv::GRunArgP getObjPtr(Mag& mag, const RcDesc &rc, bool is_umat)
|
||||
{
|
||||
switch (rc.shape)
|
||||
{
|
||||
case GShape::GMAT: return GRunArgP(&mag.template slot<cv::gapi::own::Mat>() [rc.id]);
|
||||
case GShape::GMAT:
|
||||
if (is_umat)
|
||||
return GRunArgP(&mag.template slot<cv::UMat>()[rc.id]);
|
||||
else
|
||||
return GRunArgP(&mag.template slot<cv::gapi::own::Mat>()[rc.id]);
|
||||
case GShape::GSCALAR: return GRunArgP(&mag.template slot<cv::gapi::own::Scalar>()[rc.id]);
|
||||
// Note: .at() is intentional for GArray as object MUST be already there
|
||||
// (and constructer by either bindIn/Out or resetInternal)
|
||||
@@ -230,7 +276,7 @@ cv::GRunArgP getObjPtr(Mag& mag, const RcDesc &rc)
|
||||
}
|
||||
}
|
||||
|
||||
void writeBack(const Mag& mag, const RcDesc &rc, GRunArgP &g_arg)
|
||||
void writeBack(const Mag& mag, const RcDesc &rc, GRunArgP &g_arg, bool is_umat)
|
||||
{
|
||||
switch (rc.shape)
|
||||
{
|
||||
@@ -248,12 +294,20 @@ void writeBack(const Mag& mag, const RcDesc &rc, GRunArgP &g_arg)
|
||||
case GRunArgP::index_of<cv::gapi::own::Mat*>() : out_arg_data = util::get<cv::gapi::own::Mat*>(g_arg)->data; break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::Mat*>() : out_arg_data = util::get<cv::Mat*>(g_arg)->data; break;
|
||||
case GRunArgP::index_of<cv::UMat*>() : out_arg_data = (util::get<cv::UMat*>(g_arg))->getMat(ACCESS_RW).data; break;
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
}
|
||||
|
||||
auto& in_mag = mag.template slot<cv::gapi::own::Mat>().at(rc.id);
|
||||
GAPI_Assert((out_arg_data == in_mag.data) && " data for output parameters was reallocated ?");
|
||||
if (is_umat)
|
||||
{
|
||||
auto& in_mag = mag.template slot<cv::UMat>().at(rc.id);
|
||||
GAPI_Assert((out_arg_data == (in_mag.getMat(ACCESS_RW).data)) && " data for output parameters was reallocated ?");
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& in_mag = mag.template slot<cv::gapi::own::Mat>().at(rc.id);
|
||||
GAPI_Assert((out_arg_data == in_mag.data) && " data for output parameters was reallocated ?");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user