chromium-browser-stable-sla.../enable-vaapi-on-linux.diff
2021-05-27 21:01:28 +03:00

144 lines
6.3 KiB
Diff

From 53b93dfe87fd10cced5d2a2a63072dfc7a2af6e4 Mon Sep 17 00:00:00 2001
From: Daniel Charles <daniel.charles@intel.com>
Date: Fri, 28 Jul 2017 16:31:47 -0700
Subject: [PATCH] Enable VAVDA, VAVEA and VAJDA on linux with VAAPI only
This patch contains all the changes necessary to use VA-API along with
vaapi-driver to run all media use cases supported with hardware acceleration.
It is intended to remain as experimental accessible from chrome://flags on linux.
It requires libva/intel-vaapi-driver to be installed on the system path where
chrome is executed. Other drivers could be tested if available. Flags are
kept independent for linux, where this feature has to be enabled before
actually using it. This should not change how other OSes use the flags
already, the new flags will show at the buttom on the section of unavailable
experiments
The changes cover a range of compiler pre-processor flags to enable the stack.
It moves the presandbox operations to the vaapi_wrapper class as the hook function
is available there. vaInit will open driver on the correct installed folder.
chrome flags consolidtation into only two flags for linux. Mjpeg and accelerated
video are used. The other flags are kept for ChromeOS and other OSes.
Developer testing was made on skylake hardware, ChromeOS and Ubuntu.
BUG=NONE
TEST="subjective testing with VAVDA,VAVEA and VAJDA, autotest for encoder"
TEST="and decoder hardware accelerated"
TEST="have libva/intel-vaapi-driver installed and not installed in the system"
TEST="repeat on different hardware families"
R=posciak@chromium.org
R=kcwu@chromium.org
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ifbbf5c9e5221a8b5733fc6d4d0cf984a1f103171
Signed-off-by: Daniel Charles <daniel.charles@intel.com>
---
Index: dev/content/gpu/BUILD.gn
===================================================================
--- dev.orig/content/gpu/BUILD.gn
+++ dev/content/gpu/BUILD.gn
@@ -6,6 +6,7 @@ import("//build/config/chromeos/ui_mode.
import("//build/config/ui.gni")
import("//gpu/vulkan/features.gni")
import("//media/media_options.gni")
+import("//media/gpu/args.gni")
# See //content/BUILD.gn for how this works.
group("gpu") {
@@ -140,4 +141,8 @@ target(link_target_type, "gpu_sources")
(!is_chromecast || is_cast_desktop_build)) {
configs += [ "//build/config/linux/dri" ]
}
+
+ if (is_linux && use_vaapi) {
+ public_configs = [ "//build/config/linux/libva" ]
+ }
}
Index: dev/media/gpu/gpu_video_decode_accelerator_factory.cc
===================================================================
--- dev.orig/media/gpu/gpu_video_decode_accelerator_factory.cc
+++ dev/media/gpu/gpu_video_decode_accelerator_factory.cc
@@ -164,6 +164,8 @@ GpuVideoDecodeAcceleratorFactory::Create
vda = (this->*create_vda_function)(workarounds, gpu_preferences, media_log);
if (vda && vda->Initialize(config, client))
return vda;
+ else
+ LOG(ERROR) << "Initialization of one or more VDAs failed.";
}
return nullptr;
@@ -222,6 +224,7 @@ GpuVideoDecodeAcceleratorFactory::Create
const gpu::GpuDriverBugWorkarounds& workarounds,
const gpu::GpuPreferences& gpu_preferences,
MediaLog* media_log) const {
+ LOG(WARNING) << "Initializing VAAPI VDA.";
std::unique_ptr<VideoDecodeAccelerator> decoder;
decoder.reset(new VaapiVideoDecodeAccelerator(gl_client_.make_context_current,
gl_client_.bind_image));
Index: dev/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
===================================================================
--- dev.orig/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
+++ dev/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
@@ -384,6 +384,7 @@ bool GpuVideoDecodeAccelerator::Initiali
LOG(ERROR) << "Failed creating the VDA factory";
return false;
}
+ LOG(WARNING) << "Created the VDA factory";
const gpu::GpuDriverBugWorkarounds& gpu_workarounds =
stub_->channel()->gpu_channel_manager()->gpu_driver_bug_workarounds();
@@ -404,6 +405,7 @@ bool GpuVideoDecodeAccelerator::Initiali
<< (config.is_encrypted() ? " with encryption" : "");
return false;
}
+ LOG(WARNING) << "Created VDA";
// Attempt to set up performing decoding tasks on IO thread, if supported by
// the VDA.
Index: dev/media/gpu/vaapi/vaapi_wrapper.cc
===================================================================
--- dev.orig/media/gpu/vaapi/vaapi_wrapper.cc
+++ dev/media/gpu/vaapi/vaapi_wrapper.cc
@@ -526,6 +526,11 @@ void VADisplayState::PreSandboxInitializ
base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE);
if (drm_file.IsValid())
VADisplayState::Get()->SetDrmFd(drm_file.GetPlatformFile());
+
+ const char kNvidiaPath[] = "/dev/dri/nvidiactl";
+ base::File nvidia_file = base::File(
+ base::FilePath::FromUTF8Unsafe(kNvidiaPath),
+ base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE);
}
VADisplayState::VADisplayState()
@@ -632,10 +637,6 @@ bool VADisplayState::InitializeVaDriver_
}
bool VADisplayState::InitializeOnce() {
- static_assert(
- VA_MAJOR_VERSION >= 2 || (VA_MAJOR_VERSION == 1 && VA_MINOR_VERSION >= 1),
- "Requires VA-API >= 1.1.0");
-
// Set VA logging level, unless already set.
constexpr char libva_log_level_env[] = "LIBVA_MESSAGING_LEVEL";
std::unique_ptr<base::Environment> env(base::Environment::Create());
@@ -656,7 +657,6 @@ bool VADisplayState::InitializeOnce() {
// https://github.com/intel/media-driver/issues/818
if (!env->HasVar(libva_driver_impl_env))
env->SetVar(libva_driver_impl_env, "i965");
-
// Re-initialize with the new driver.
va_display_ = nullptr;
va_initialized_ = false;
@@ -864,7 +864,7 @@ bool AreAttribsSupported(const base::Loc
if (attribs[i].type != required_attribs[i].type ||
(attribs[i].value & required_attribs[i].value) !=
required_attribs[i].value) {
- DVLOG(1) << "Unsupported value " << required_attribs[i].value << " for "
+ VLOG(1) << "Unsupported value " << required_attribs[i].value << " for "
<< vaConfigAttribTypeStr(required_attribs[i].type);
return false;
}