-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
G-API: VPL Source turn on Linux CPU version #21883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
92d56f3
to
80184b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see only two new files were added, assuming extending tests for new backend I'd expect 2-3 more files modified, why it is 35 files long then? :)
modules/gapi/CMakeLists.txt
Outdated
@@ -133,7 +133,7 @@ set(gapi_srcs | |||
src/backends/fluid/gfluidimgproc.cpp | |||
src/backends/fluid/gfluidimgproc_func.dispatch.cpp | |||
src/backends/fluid/gfluidcore.cpp | |||
src/backends/fluid/gfluidcore_func.dispatch.cpp | |||
src/backends/fluid/gfluidcore_func.dispatch.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
if(UNIX) | ||
find_package(PkgConfig) | ||
if(PkgConfig_FOUND) | ||
pkg_check_modules(PKG_LIBVA libva>=1.2 libva-drm>=1.2) | ||
if(PKG_LIBVA_FOUND) | ||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE) | ||
set(THREADS_PREFER_PTHREAD_FLAG TRUE) | ||
find_package(Threads REQUIRED) | ||
else() | ||
message(FATAL_ERROR "libva not found: building HAVE_GAPI_ONEVPL without libVA support is impossible on UNIX systems") | ||
endif() | ||
else() | ||
message(FATAL_ERROR "PkgConfig not found: building HAVE_GAPI_ONEVPL without libVA support is impossible on UNIX systems") | ||
endif() | ||
ocv_target_link_libraries(${the_module} PRIVATE ${PKG_LIBVA_LIBRARIES} ${PKG_THREAD_LIBRARIES}) | ||
endif() | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably this whole thing should be done one-two levels above. Maybe make VA lookup OpenCV-global? cc: @alalek
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it activates in composition with -DWITH_GAPI_ONEVPL and should be removed (or changed) when plugin-based atrchitecture applied. That's because I did not spend much time for working this out. But any other suggestions are appreciated
@@ -16,6 +16,7 @@ | |||
#include <opencv2/gapi/util/optional.hpp> | |||
#include <opencv2/gapi/garg.hpp> | |||
#include <opencv2/gapi/streaming/source.hpp> | |||
#include <opencv2/gapi/gcommon.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really required by this particular header?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'll try to check it
@@ -20,6 +20,7 @@ namespace onevpl { | |||
enum class AccelType: uint8_t { | |||
HOST, | |||
DX11, | |||
VA_API, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or VAAPI? That's how it's called at 01.org - https://01.org/linuxmedia/vaapi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you right, i'll rename it
@@ -155,8 +156,12 @@ VPLCPUAccelerationPolicy::create_surface_pool(size_t pool_size, size_t surface_s | |||
GAPI_LOG_DEBUG(nullptr, "page size: " << page_size_bytes << ", preallocated_raw_bytes: " << preallocated_raw_bytes); | |||
preallocated_pool_memory_ptr = _aligned_malloc(preallocated_raw_bytes, page_size_bytes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering why it wasn't RAII-d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it "semi" RAII-d because it is being wrapped into std::shared_ptr with custom deleter (free/aligned_free) in 174 line below
@@ -173,8 +178,9 @@ VPLCPUAccelerationPolicy::create_surface_pool(size_t pool_size, size_t surface_s | |||
GAPI_LOG_INFO(nullptr, "Released workspace memory: " << ptr); | |||
ptr = nullptr; | |||
#else | |||
GAPI_Assert(false && "Not implemented for systems differ than \"_WIN32\". " | |||
"Please feel free to set it up under OPENCV contribution policy"); | |||
free(ptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..at least this could have been automated then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's deleter definition for RAII-d shared_ptr, which constructed from raw memory pointer
So, RAII was applied in result :)
device_fd(-1) { | ||
#if defined(HAVE_VA) || defined(HAVE_VA_INTEL) | ||
// TODO Move it out in device selector | ||
device_fd = open("/dev/dri/renderD128", O_RDWR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RAII!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will be moved into device selector in next PRs
at current step RAII for device_fd
is VPLVAAPIAcceleration policy by itself
It seems |
|
||
cv::MediaFrame::AdapterPtr VPLVAAPIAccelerationPolicy::create_frame_adapter(pool_key_t, | ||
const FrameConstructorArgs &) { | ||
GAPI_Assert(false && "VPLVAAPIAccelerationPolicy unavailable in current configuration"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it's a good idea, but given the amount of code here, maybe it's worth to put this unsupported asserts in the default implementation of these methods in the base class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe...
But current version gives additional hint about descendant name whithout additional method name() exposing.
Also i do not want to pollute pure interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
// 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about whole comments because it implemented as free-initiative
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see
@alalek Could you merge it please? It seems only minor commets are elapsed |
@alalek @asmorkalov should we merge it? |
63b7f49
to
ffe3297
Compare
@alalek License headers inserted in newly added files, please take a look |
G-API: VPL Source turn on Linux CPU version * Turn on linux compilation * Apply comments * Change new files headline * Add license header
Fix compilation VPL Streaming Source for Linux
Add stub for VAAPI acceleration which uses accel for decode but produces MediaFrame in CPU memory
Fix UT of existing functionalities
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.
Build Configuration