-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathenable-vaapi-on-linux.diff
142 lines (127 loc) · 6.12 KB
/
enable-vaapi-on-linux.diff
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
139
140
141
142
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
@@ -7,6 +7,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") {
@@ -143,4 +144,8 @@ target(link_target_type, "gpu_sources")
!is_castos) {
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
@@ -163,6 +163,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;
@@ -233,6 +235,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 VTVideoDecodeAccelerator(gl_client_, workarounds, media_log));
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
@@ -462,6 +462,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();
@@ -482,6 +483,7 @@ bool GpuVideoDecodeAccelerator::Initiali
<< (config.is_encrypted() ? " with encryption" : "");
return false;
}
+ LOG(WARNING) << "Created VDA";
decoder_client_.Bind(std::move(client), io_task_runner_);
Index: dev/media/gpu/vaapi/vaapi_wrapper.cc
===================================================================
--- dev.orig/media/gpu/vaapi/vaapi_wrapper.cc
+++ dev/media/gpu/vaapi/vaapi_wrapper.cc
@@ -1009,7 +1009,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;
}
@@ -1561,6 +1561,13 @@ void VADisplayStateSingleton::PreSandbox
base::AutoLock lock(va_display_state.lock_);
constexpr char kRenderNodeFilePattern[] = "/dev/dri/renderD%d";
+ const char kNvidiaPath[] = "/dev/dri/nvidiactl";
+
+ // TODO: Is this still needed?
+ base::File nvidia_file = base::File(
+ base::FilePath::FromUTF8Unsafe(kNvidiaPath),
+ base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE);
+
// This loop ends on either the first card that does not exist or the first
// render node that is not vgem.
for (int i = 128;; i++) {
@@ -3246,13 +3253,7 @@ void VaapiWrapper::PreSandboxInitializat
static bool result = InitializeStubs(paths);
if (!result) {
static const char kErrorMsg[] = "Failed to initialize VAAPI libs";
-#if BUILDFLAG(IS_CHROMEOS)
- // When Chrome runs on Linux with target_os="chromeos", do not log error
- // message without VAAPI libraries.
- LOG_IF(ERROR, base::SysInfo::IsRunningOnChromeOS()) << kErrorMsg;
-#else
- DVLOG(1) << kErrorMsg;
-#endif
+ LOG(ERROR) << kErrorMsg;
}
// VASupportedProfiles::Get creates VADisplayStateSingleton and in so doing