-
Notifications
You must be signed in to change notification settings - Fork 0
/
enable_vaapi_on_linux_2.diff
863 lines (806 loc) · 35.4 KB
/
enable_vaapi_on_linux_2.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
From 53b93dfe87fd10cced5d2a2a63072dfc7a2af6e4 Mon Sep 17 00:00:00 2001
From: Daniel Charles <[email protected]>
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"
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 <[email protected]>
---
Index: beta/AUTHORS
===================================================================
--- beta.orig/AUTHORS
+++ beta/AUTHORS
@@ -161,6 +161,7 @@ Dan McCombs <[email protected]>
Daniel Bevenius <[email protected]>
Daniel Bomar <[email protected]>
Daniel Carvalho Liedke <[email protected]>
+Daniel Charles <[email protected]>
Daniel Imms <[email protected]>
Daniel Johnson <[email protected]>
Daniel Lockyer <[email protected]>
Index: beta/chrome/browser/about_flags.cc
===================================================================
--- beta.orig/chrome/browser/about_flags.cc
+++ beta/chrome/browser/about_flags.cc
@@ -1239,12 +1239,14 @@ const FeatureEntry kFeatureEntries[] = {
flag_descriptions::kUiPartialSwapDescription, kOsAll,
SINGLE_DISABLE_VALUE_TYPE(switches::kUIDisablePartialSwap)},
#if BUILDFLAG(ENABLE_WEBRTC)
+#if !defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
{"disable-webrtc-hw-decoding", flag_descriptions::kWebrtcHwDecodingName,
flag_descriptions::kWebrtcHwDecodingDescription, kOsAndroid | kOsCrOS,
SINGLE_DISABLE_VALUE_TYPE(switches::kDisableWebRtcHWDecoding)},
{"disable-webrtc-hw-encoding", flag_descriptions::kWebrtcHwEncodingName,
flag_descriptions::kWebrtcHwEncodingDescription, kOsAndroid | kOsCrOS,
SINGLE_DISABLE_VALUE_TYPE(switches::kDisableWebRtcHWEncoding)},
+#endif
{"enable-webrtc-hw-h264-encoding",
flag_descriptions::kWebrtcHwH264EncodingName,
flag_descriptions::kWebrtcHwH264EncodingDescription, kOsAndroid | kOsCrOS,
@@ -1559,6 +1561,13 @@ const FeatureEntry kFeatureEntries[] = {
flag_descriptions::kMultideviceDescription, kOsCrOS,
FEATURE_VALUE_TYPE(features::kMultidevice)},
#endif // OS_CHROMEOS
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+ {
+ "enable-accelerated-video", flag_descriptions::kAcceleratedVideoName,
+ flag_descriptions::kAcceleratedVideoDescription, kOsLinux,
+ SINGLE_VALUE_TYPE(switches::kEnableAcceleratedVideo),
+ },
+#else
{
"disable-accelerated-video-decode",
flag_descriptions::kAcceleratedVideoDecodeName,
@@ -1566,6 +1575,7 @@ const FeatureEntry kFeatureEntries[] = {
kOsMac | kOsWin | kOsCrOS | kOsAndroid,
SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode),
},
+#endif
{"mojo-video-encode-accelerator",
flag_descriptions::kMojoVideoEncodeAcceleratorName,
flag_descriptions::kMojoVideoEncodeAcceleratorDescription,
@@ -2224,12 +2234,17 @@ const FeatureEntry kFeatureEntries[] = {
FEATURE_VALUE_TYPE(features::kWebVrVsyncAlign)},
#endif // OS_ANDROID
#endif // ENABLE_VR
-#if defined(OS_CHROMEOS)
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+ {"enable-accelerated-mjpeg-decode",
+ flag_descriptions::kAcceleratedMjpegDecodeName,
+ flag_descriptions::kAcceleratedMjpegDecodeDescription, kOsLinux,
+ SINGLE_VALUE_TYPE(switches::kEnableAcceleratedMjpegDecode)},
+#elif defined(OS_CHROMEOS)
{"disable-accelerated-mjpeg-decode",
flag_descriptions::kAcceleratedMjpegDecodeName,
flag_descriptions::kAcceleratedMjpegDecodeDescription, kOsCrOS,
SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedMjpegDecode)},
-#endif // OS_CHROMEOS
+#endif
{"v8-cache-options", flag_descriptions::kV8CacheOptionsName,
flag_descriptions::kV8CacheOptionsDescription, kOsAll,
MULTI_VALUE_TYPE(kV8CacheOptionsChoices)},
Index: beta/chrome/browser/chromeos/login/chrome_restart_request.cc
===================================================================
--- beta.orig/chrome/browser/chromeos/login/chrome_restart_request.cc
+++ beta/chrome/browser/chromeos/login/chrome_restart_request.cc
@@ -19,6 +19,7 @@
#include "base/sys_info.h"
#include "base/timer/timer.h"
#include "base/values.h"
+#include "build/build_config.h"
#include "cc/base/switches.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/boot_times_recorder.h"
@@ -80,8 +81,13 @@ void DeriveCommandLine(const GURL& start
::switches::kDisable2dCanvasImageChromium,
::switches::kDisableAccelerated2dCanvas,
::switches::kDisableAcceleratedJpegDecoding,
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+ ::switches::kEnableAcceleratedMjpegDecode,
+ ::switches::kEnableAcceleratedVideo,
+#else
::switches::kDisableAcceleratedMjpegDecode,
::switches::kDisableAcceleratedVideoDecode,
+#endif
::switches::kDisableBlinkFeatures,
::switches::kDisableCastStreamingHWEncoding,
::switches::kDisableDistanceFieldText,
@@ -168,7 +174,7 @@ void DeriveCommandLine(const GURL& start
::switches::kDisableWebGLImageChromium,
::switches::kEnableWebGLImageChromium,
::switches::kEnableWebVR,
-#if BUILDFLAG(ENABLE_WEBRTC)
+#if BUILDFLAG(ENABLE_WEBRTC) && (defined(OS_CHROMEOS) || defined(OS_ANDROID))
::switches::kDisableWebRtcHWDecoding,
::switches::kDisableWebRtcHWEncoding,
#endif
Index: beta/chrome/browser/flag_descriptions.cc
===================================================================
--- beta.orig/chrome/browser/flag_descriptions.cc
+++ beta/chrome/browser/flag_descriptions.cc
@@ -14,6 +14,13 @@ const char kAccelerated2dCanvasDescripti
"Enables the use of the GPU to perform 2d canvas rendering instead of "
"using software rendering.";
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+const char kAcceleratedVideoName[] = "Hardware-accelerated video";
+const char kAcceleratedVideoDescription[] =
+ "Hardware-accelerated video where VA-API driver is installed on the"
+ "system.";
+#endif
+
const char kAcceleratedVideoDecodeName[] = "Hardware-accelerated video decode";
const char kAcceleratedVideoDecodeDescription[] =
"Hardware-accelerated video decode where available.";
@@ -1418,6 +1425,7 @@ const char kWebrtcEchoCanceller3Name[] =
const char kWebrtcEchoCanceller3Description[] =
"Experimental WebRTC echo canceller (AEC3).";
+#if !defined(OS_LINUX) || !defined(OS_CHROMEOS)
const char kWebrtcHwDecodingName[] = "WebRTC hardware video decoding";
const char kWebrtcHwDecodingDescription[] =
"Support in WebRTC for decoding video streams using platform hardware.";
@@ -1425,6 +1433,7 @@ const char kWebrtcHwDecodingDescription[
const char kWebrtcHwEncodingName[] = "WebRTC hardware video encoding";
const char kWebrtcHwEncodingDescription[] =
"Support in WebRTC for encoding video streams using platform hardware.";
+#endif
const char kWebrtcHwH264EncodingName[] = "WebRTC hardware h264 video encoding";
const char kWebrtcHwH264EncodingDescription[] =
@@ -2211,7 +2220,7 @@ const char kPermissionPromptPersistenceT
// Chrome OS -------------------------------------------------------------------
-#if defined(OS_CHROMEOS)
+#if defined(OS_CHROMEOS) || (defined(OS_LINUX) && !defined(OS_ANDROID))
const char kAcceleratedMjpegDecodeName[] =
"Hardware-accelerated mjpeg decode for captured frame";
@@ -2545,7 +2554,7 @@ const char kWakeOnPacketsName[] = "Wake
const char kWakeOnPacketsDescription[] =
"Enables waking the device based on the receipt of some network packets.";
-#endif // defined(OS_CHROMEOS)
+#endif // defined(OS_CHROMEOS) || BUILDFLAG(USE_VAAPI)
// Random platform combinations -----------------------------------------------
Index: beta/chrome/browser/flag_descriptions.h
===================================================================
--- beta.orig/chrome/browser/flag_descriptions.h
+++ beta/chrome/browser/flag_descriptions.h
@@ -36,6 +36,10 @@ namespace flag_descriptions {
extern const char kAccelerated2dCanvasName[];
extern const char kAccelerated2dCanvasDescription[];
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+extern const char kAcceleratedVideoName[];
+extern const char kAcceleratedVideoDescription[];
+#endif
extern const char kAcceleratedVideoDecodeName[];
extern const char kAcceleratedVideoDecodeDescription[];
@@ -1353,13 +1357,17 @@ extern const char kPermissionPromptPersi
#endif // defined(OS_MACOSX)
-// Chrome OS ------------------------------------------------------------------
-
-#if defined(OS_CHROMEOS)
+#if defined(OS_CHROMEOS) || (defined(OS_LINUX) && !defined(OS_ANDROID))
extern const char kAcceleratedMjpegDecodeName[];
extern const char kAcceleratedMjpegDecodeDescription[];
+#endif
+
+// Chrome OS ------------------------------------------------------------------
+
+#if defined(OS_CHROMEOS)
+
extern const char kAllowTouchpadThreeFingerClickName[];
extern const char kAllowTouchpadThreeFingerClickDescription[];
Index: beta/content/browser/gpu/compositor_util.cc
===================================================================
--- beta.orig/content/browser/gpu/compositor_util.cc
+++ beta/content/browser/gpu/compositor_util.cc
@@ -104,7 +104,11 @@ const GpuFeatureInfo GetGpuFeatureInfo(s
{"video_decode",
manager->IsFeatureBlacklisted(
gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE),
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+ !command_line.HasSwitch(switches::kEnableAcceleratedVideo),
+#else
command_line.HasSwitch(switches::kDisableAcceleratedVideoDecode),
+#endif
"Accelerated video decode has been disabled, either via blacklist,"
" about:flags or the command line.",
true},
@@ -112,7 +116,11 @@ const GpuFeatureInfo GetGpuFeatureInfo(s
{"video_encode",
manager->IsFeatureBlacklisted(
gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_ENCODE),
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+ !command_line.HasSwitch(switches::kEnableAcceleratedVideo),
+#else
command_line.HasSwitch(switches::kDisableWebRtcHWEncoding),
+#endif
"Accelerated video encode has been disabled, either via blacklist,"
" about:flags or the command line.",
true},
Index: beta/content/browser/gpu/gpu_data_manager_impl_private.cc
===================================================================
--- beta.orig/content/browser/gpu/gpu_data_manager_impl_private.cc
+++ beta/content/browser/gpu/gpu_data_manager_impl_private.cc
@@ -717,7 +717,11 @@ void GpuDataManagerImplPrivate::AppendRe
DCHECK(command_line);
if (ShouldDisableAcceleratedVideoDecode(command_line))
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+ command_line->AppendSwitch(switches::kEnableAcceleratedVideo);
+#else
command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
+#endif
#if defined(USE_AURA)
if (!CanUseGpuBrowserCompositor())
@@ -751,7 +755,11 @@ void GpuDataManagerImplPrivate::AppendGp
}
if (ShouldDisableAcceleratedVideoDecode(command_line)) {
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+ command_line->AppendSwitch(switches::kEnableAcceleratedVideo);
+#else
command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
+#endif
}
#if defined(USE_OZONE)
@@ -844,7 +852,12 @@ void GpuDataManagerImplPrivate::UpdateRe
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (!ShouldDisableAcceleratedVideoDecode(command_line) &&
- !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) {
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+ command_line->HasSwitch(switches::kEnableAcceleratedVideo)
+#else
+ !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)
+#endif
+ ) {
prefs->pepper_accelerated_video_decode_enabled = true;
}
}
@@ -1043,7 +1056,13 @@ bool GpuDataManagerImplPrivate::ShouldDi
// to resolve crbug/442039 has been collected.
const std::string group_name = base::FieldTrialList::FindFullName(
"DisableAcceleratedVideoDecode");
- if (command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) {
+ if (
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+ !command_line->HasSwitch(switches::kEnableAcceleratedVideo)
+#else
+ command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)
+#endif
+ ) {
// It was already disabled on the command line.
return false;
}
Index: beta/content/browser/gpu/gpu_process_host.cc
===================================================================
--- beta.orig/content/browser/gpu/gpu_process_host.cc
+++ beta/content/browser/gpu/gpu_process_host.cc
@@ -112,7 +112,11 @@ namespace {
// Command-line switches to propagate to the GPU process.
static const char* const kSwitchNames[] = {
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+ switches::kEnableAcceleratedVideo,
+#else
switches::kDisableAcceleratedVideoDecode,
+#endif
switches::kDisableBreakpad,
switches::kDisableGpuRasterization,
switches::kDisableGpuSandbox,
@@ -121,7 +125,7 @@ static const char* const kSwitchNames[]
switches::kDisableLogging,
switches::kDisableSeccompFilterSandbox,
switches::kDisableShaderNameHashing,
-#if BUILDFLAG(ENABLE_WEBRTC)
+#if BUILDFLAG(ENABLE_WEBRTC) && !defined(OS_LINUX)
switches::kDisableWebRtcHWEncoding,
#endif
#if defined(OS_WIN)
Index: beta/content/browser/renderer_host/media/video_capture_browsertest.cc
===================================================================
--- beta.orig/content/browser/renderer_host/media/video_capture_browsertest.cc
+++ beta/content/browser/renderer_host/media/video_capture_browsertest.cc
@@ -155,8 +155,13 @@ class VideoCaptureBrowserTest : public C
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kUseFakeJpegDecodeAccelerator);
} else {
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableAcceleratedMjpegDecode);
+#else
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kDisableAcceleratedMjpegDecode);
+#endif
}
if (params_.use_mojo_service) {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
Index: beta/content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.cc
===================================================================
--- beta.orig/content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.cc
+++ beta/content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.cc
@@ -56,15 +56,21 @@ void VideoCaptureGpuJpegDecoder::Initial
bool is_platform_supported =
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kUseFakeJpegDecodeAccelerator);
-#if defined(OS_CHROMEOS)
- // Non-ChromeOS platforms do not support HW JPEG decode now. Do not establish
- // gpu channel to avoid introducing overhead.
+#if !defined(OS_ANDROID) && defined(OS_LINUX)
+ // Non-ChromeOS or Non-Linux platforms do not support HW JPEG decode now. Do
+ // not establish gpu channel to avoid introducing overhead.
is_platform_supported = true;
#endif
if (!is_platform_supported ||
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+ !base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableAcceleratedMjpegDecode)
+#else
base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableAcceleratedMjpegDecode)) {
+ switches::kDisableAcceleratedMjpegDecode)
+#endif
+ ) {
decoder_status_ = FAILED;
RecordInitDecodeUMA_Locked();
return;
Index: beta/content/browser/renderer_host/render_process_host_impl.cc
===================================================================
--- beta.orig/content/browser/renderer_host/render_process_host_impl.cc
+++ beta/content/browser/renderer_host/render_process_host_impl.cc
@@ -2488,7 +2488,11 @@ void RenderProcessHostImpl::PropagateBro
switches::kDisable2dCanvasImageChromium,
switches::kDisable3DAPIs,
switches::kDisableAcceleratedJpegDecoding,
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ switches::kEnableAcceleratedVideo,
+#else
switches::kDisableAcceleratedVideoDecode,
+#endif
switches::kDisableBackgroundTimerThrottling,
switches::kDisableBreakpad,
switches::kDisablePreferCompositingToLCDText,
@@ -2641,8 +2645,10 @@ void RenderProcessHostImpl::PropagateBro
switches::kEnablePepperTesting,
#endif
#if BUILDFLAG(ENABLE_WEBRTC)
+#if !defined(OS_LINUX) || defined(OS_CHROMEOS)
switches::kDisableWebRtcHWDecoding,
switches::kDisableWebRtcHWEncoding,
+#endif
switches::kEnableWebRtcSrtpAesGcm,
switches::kEnableWebRtcSrtpEncryptedHeaders,
switches::kEnableWebRtcStunOrigin,
Index: beta/content/browser/webrtc/webrtc_media_recorder_browsertest.cc
===================================================================
--- beta.orig/content/browser/webrtc/webrtc_media_recorder_browsertest.cc
+++ beta/content/browser/webrtc/webrtc_media_recorder_browsertest.cc
@@ -58,7 +58,12 @@ class WebRtcMediaRecorderTest
return;
// This flag is also used for encoding, https://crbug.com/616640.
base::CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kDisableAcceleratedVideoDecode);
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ switches::kEnableAcceleratedVideo
+#else
+ switches::kDisableAcceleratedVideoDecode
+#endif
+ );
}
private:
Index: beta/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
===================================================================
--- beta.orig/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
+++ beta/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
@@ -57,22 +57,6 @@ inline bool IsChromeOS() {
#endif
}
-inline bool IsArchitectureX86_64() {
-#if defined(__x86_64__)
- return true;
-#else
- return false;
-#endif
-}
-
-inline bool IsArchitectureI386() {
-#if defined(__i386__)
- return true;
-#else
- return false;
-#endif
-}
-
inline bool IsArchitectureArm() {
#if defined(__arm__) || defined(__aarch64__)
return true;
@@ -97,21 +81,14 @@ inline bool UseLibV4L2() {
#endif
}
-bool IsAcceleratedVaapiVideoEncodeEnabled() {
- bool accelerated_encode_enabled = false;
-#if defined(OS_CHROMEOS)
- const base::CommandLine& command_line =
- *base::CommandLine::ForCurrentProcess();
- accelerated_encode_enabled =
- !command_line.HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode);
-#endif
- return accelerated_encode_enabled;
-}
-
bool IsAcceleratedVideoDecodeEnabled() {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ return command_line.HasSwitch(switches::kEnableAcceleratedVideo);
+#else
return !command_line.HasSwitch(switches::kDisableAcceleratedVideoDecode);
+#endif
}
intptr_t GpuSIGSYS_Handler(const struct arch_seccomp_data& args,
@@ -295,33 +272,6 @@ bool GpuProcessPolicy::PreSandboxHook()
GpuBrokerProcessPolicy::Create,
std::vector<BrokerFilePermission>()); // No extra files in whitelist.
- if (IsArchitectureX86_64() || IsArchitectureI386()) {
- // Accelerated video dlopen()'s some shared objects
- // inside the sandbox, so preload them now.
- if (IsAcceleratedVaapiVideoEncodeEnabled() ||
- IsAcceleratedVideoDecodeEnabled()) {
- const char* I965DrvVideoPath = NULL;
- const char* I965HybridDrvVideoPath = NULL;
-
- if (IsArchitectureX86_64()) {
- I965DrvVideoPath = "/usr/lib64/va/drivers/i965_drv_video.so";
- I965HybridDrvVideoPath = "/usr/lib64/va/drivers/hybrid_drv_video.so";
- } else if (IsArchitectureI386()) {
- I965DrvVideoPath = "/usr/lib/va/drivers/i965_drv_video.so";
- }
-
- dlopen(I965DrvVideoPath, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
- if (I965HybridDrvVideoPath)
- dlopen(I965HybridDrvVideoPath, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
- dlopen("libva.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
-#if defined(USE_OZONE)
- dlopen("libva-drm.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
-#elif defined(USE_X11)
- dlopen("libva-x11.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
-#endif
- }
- }
-
return true;
}
Index: beta/content/gpu/BUILD.gn
===================================================================
--- beta.orig/content/gpu/BUILD.gn
+++ beta/content/gpu/BUILD.gn
@@ -5,6 +5,7 @@
import("//build/config/ui.gni")
import("//gpu/vulkan/features.gni")
import("//media/media_options.gni")
+import("//media/gpu/args.gni")
import("//ui/ozone/ozone.gni")
# See //content/BUILD.gn for how this works.
@@ -45,7 +46,6 @@ target(link_target_type, "gpu_sources")
]
configs += [ "//content:content_implementation" ]
-
deps = [
"//base",
"//base/third_party/dynamic_annotations",
@@ -114,4 +114,8 @@ target(link_target_type, "gpu_sources")
if (enable_vulkan) {
deps += [ "//gpu/vulkan" ]
}
+
+ if (is_desktop_linux && use_vaapi) {
+ public_configs = [ "//media/gpu:libva_config" ]
+ }
}
Index: beta/content/gpu/gpu_main.cc
===================================================================
--- beta.orig/content/gpu/gpu_main.cc
+++ beta/content/gpu/gpu_main.cc
@@ -245,7 +245,7 @@ int GpuMain(const MainFunctionParams& pa
// Initializes StatisticsRecorder which tracks UMA histograms.
base::StatisticsRecorder::Initialize();
-#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
+#if defined(OS_LINUX)
// Set thread priority before sandbox initialization.
base::PlatformThread::SetCurrentThreadPriority(base::ThreadPriority::DISPLAY);
#endif
@@ -275,7 +275,7 @@ int GpuMain(const MainFunctionParams& pa
GetContentClient()->SetGpuInfo(gpu_init.gpu_info());
base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL;
-#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
+#if defined(OS_LINUX)
io_thread_priority = base::ThreadPriority::DISPLAY;
#endif
Index: beta/content/public/browser/gpu_utils.cc
===================================================================
--- beta.orig/content/public/browser/gpu_utils.cc
+++ beta/content/public/browser/gpu_utils.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
+#include "build/build_config.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
@@ -57,12 +58,19 @@ const gpu::GpuPreferences GetGpuPreferen
gpu_preferences.ui_prioritize_in_gpu_process =
command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess);
gpu_preferences.disable_accelerated_video_decode =
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ !command_line->HasSwitch(switches::kEnableAcceleratedVideo);
+#else
command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode);
-#if defined(OS_CHROMEOS)
+#endif
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ gpu_preferences.disable_vaapi_accelerated_video_encode =
+ !command_line->HasSwitch(switches::kEnableAcceleratedVideo);
+#elif defined(OS_CHROMEOS)
gpu_preferences.disable_vaapi_accelerated_video_encode =
command_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode);
#endif
-#if BUILDFLAG(ENABLE_WEBRTC)
+#if BUILDFLAG(ENABLE_WEBRTC) && (!defined(OS_LINUX) || defined(OS_CHROMEOS))
gpu_preferences.disable_web_rtc_hw_encoding =
command_line->HasSwitch(switches::kDisableWebRtcHWEncoding);
#endif
Index: beta/content/public/common/content_switches.cc
===================================================================
--- beta.orig/content/public/common/content_switches.cc
+++ beta/content/public/common/content_switches.cc
@@ -88,12 +88,21 @@ const char kDisable3DAPIs[]
// Disable gpu-accelerated 2d canvas.
const char kDisableAccelerated2dCanvas[] = "disable-accelerated-2d-canvas";
-
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+// Enable hardware accelerated mjpeg decode on linux
+const char kEnableAcceleratedMjpegDecode[] = "enable-accelerated-mjpeg-decode";
+#else
// Disable hardware acceleration of mjpeg decode for captured frame, where
// available.
const char kDisableAcceleratedMjpegDecode[] =
"disable-accelerated-mjpeg-decode";
+#endif
+#if defined(OS_LINUX)
+// Enables hardware acceleration of video for Linux only. VA-API driver
+// is required to be present on the system installation.
+const char kEnableAcceleratedVideo[] = "enable-accelerated-video";
+#endif
// Disables hardware acceleration of video decode, where available.
const char kDisableAcceleratedVideoDecode[] =
"disable-accelerated-video-decode";
@@ -933,11 +942,13 @@ const char kZygoteProcess[]
// ignores this switch on its stable and beta channels.
const char kDisableWebRtcEncryption[] = "disable-webrtc-encryption";
+#if defined(OS_CHROMEOS)
// Disables HW decode acceleration for WebRTC.
const char kDisableWebRtcHWDecoding[] = "disable-webrtc-hw-decoding";
// Disables HW encode acceleration for WebRTC.
const char kDisableWebRtcHWEncoding[] = "disable-webrtc-hw-encoding";
+#endif
// Enables negotiation of GCM cipher suites from RFC 7714 for SRTP in WebRTC.
// See https://tools.ietf.org/html/rfc7714 for further information.
Index: beta/content/public/common/content_switches.h
===================================================================
--- beta.orig/content/public/common/content_switches.h
+++ beta/content/public/common/content_switches.h
@@ -35,7 +35,11 @@ CONTENT_EXPORT extern const char kDisabl
CONTENT_EXPORT extern const char kDisable3DAPIs[];
CONTENT_EXPORT extern const char kDisableAccelerated2dCanvas[];
CONTENT_EXPORT extern const char kDisableAcceleratedJpegDecoding[];
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+CONTENT_EXPORT extern const char kEnableAcceleratedMjpegDecode[];
+#else
CONTENT_EXPORT extern const char kDisableAcceleratedMjpegDecode[];
+#endif
CONTENT_EXPORT extern const char kDisableAcceleratedVideoDecode[];
CONTENT_EXPORT extern const char kDisableAudioSupportForDesktopShare[];
extern const char kDisableBackingStoreLimit[];
@@ -107,6 +111,9 @@ CONTENT_EXPORT extern const char kDisabl
CONTENT_EXPORT extern const char kDomAutomationController[];
extern const char kDisable2dCanvasClipAntialiasing[];
CONTENT_EXPORT extern const char kDumpBlinkRuntimeCallStats[];
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+CONTENT_EXPORT extern const char kEnableAcceleratedVideo[];
+#endif
CONTENT_EXPORT extern const char kEnableAggressiveDOMStorageFlushing[];
CONTENT_EXPORT extern const char kEnablePreferCompositingToLCDText[];
CONTENT_EXPORT extern const char kEnableBlinkFeatures[];
@@ -261,8 +268,10 @@ CONTENT_EXPORT extern const char kZygote
#if BUILDFLAG(ENABLE_WEBRTC)
CONTENT_EXPORT extern const char kDisableWebRtcEncryption[];
+#if defined(OS_CHROMEOS)
CONTENT_EXPORT extern const char kDisableWebRtcHWDecoding[];
CONTENT_EXPORT extern const char kDisableWebRtcHWEncoding[];
+#endif
CONTENT_EXPORT extern const char kEnableWebRtcSrtpAesGcm[];
CONTENT_EXPORT extern const char kEnableWebRtcSrtpEncryptedHeaders[];
CONTENT_EXPORT extern const char kEnableWebRtcStunOrigin[];
Index: beta/content/renderer/media/webrtc/peer_connection_dependency_factory.cc
===================================================================
--- beta.orig/content/renderer/media/webrtc/peer_connection_dependency_factory.cc
+++ beta/content/renderer/media/webrtc/peer_connection_dependency_factory.cc
@@ -240,10 +240,19 @@ void PeerConnectionDependencyFactory::In
const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
if (gpu_factories && gpu_factories->IsGpuVideoAcceleratorEnabled()) {
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ if (cmd_line->HasSwitch(switches::kEnableAcceleratedVideo))
+#else
if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWDecoding))
+#endif
decoder_factory.reset(new RTCVideoDecoderFactory(gpu_factories));
- if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWEncoding)) {
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ if (cmd_line->HasSwitch(switches::kEnableAcceleratedVideo))
+#else
+ if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWEncoding))
+#endif
+ {
encoder_factory.reset(new RTCVideoEncoderFactory(gpu_factories));
}
}
Index: beta/content/renderer/render_thread_impl.cc
===================================================================
--- beta.orig/content/renderer/render_thread_impl.cc
+++ beta/content/renderer/render_thread_impl.cc
@@ -1453,7 +1453,11 @@ media::GpuVideoAcceleratorFactories* Ren
scoped_refptr<base::SingleThreadTaskRunner> media_task_runner =
GetMediaThreadTaskRunner();
const bool enable_video_accelerator =
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ cmd_line->HasSwitch(switches::kEnableAcceleratedVideo);
+#else
!cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode);
+#endif
const bool enable_gpu_memory_buffer_video_frames =
#if defined(OS_MACOSX) || defined(OS_LINUX)
!cmd_line->HasSwitch(switches::kDisableGpuMemoryBufferVideoFrames) &&
Index: beta/gpu/command_buffer/service/gpu_preferences.h
===================================================================
--- beta.orig/gpu/command_buffer/service/gpu_preferences.h
+++ beta/gpu/command_buffer/service/gpu_preferences.h
@@ -50,7 +50,7 @@ struct GPU_EXPORT GpuPreferences {
// Disables hardware acceleration of video decode, where available.
bool disable_accelerated_video_decode = false;
-#if defined(OS_CHROMEOS)
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
// Disables VA-API accelerated video encode.
bool disable_vaapi_accelerated_video_encode = false;
#endif
Index: beta/gpu/config/software_rendering_list.json
===================================================================
--- beta.orig/gpu/config/software_rendering_list.json
+++ beta/gpu/config/software_rendering_list.json
@@ -371,17 +371,6 @@
]
},
{
- "id": 48,
- "description": "Accelerated video decode is unavailable on Linux",
- "cr_bugs": [137247],
- "os": {
- "type": "linux"
- },
- "features": [
- "accelerated_video_decode"
- ]
- },
- {
"id": 50,
"description": "Disable VMware software renderer on older Mesa",
"cr_bugs": [145531, 332596, 571899, 629434],
Index: beta/media/filters/BUILD.gn
===================================================================
--- beta.orig/media/filters/BUILD.gn
+++ beta/media/filters/BUILD.gn
@@ -3,6 +3,7 @@
# found in the LICENSE file.
import("//media/media_options.gni")
+import("//media/gpu/args.gni")
source_set("filters") {
visibility = [
@@ -182,7 +183,7 @@ source_set("filters") {
deps += [ "//media/base/android" ]
}
- if (current_cpu != "arm" && is_chromeos) {
+ if (use_vaapi) {
sources += [
"h264_bitstream_buffer.cc",
"h264_bitstream_buffer.h",
Index: beta/media/gpu/BUILD.gn
===================================================================
--- beta.orig/media/gpu/BUILD.gn
+++ beta/media/gpu/BUILD.gn
@@ -24,6 +24,12 @@ if (is_mac) {
import("//build/config/mac/mac_sdk.gni")
}
+import("//build/config/linux/pkg_config.gni")
+
+pkg_config("libva_config") {
+ packages = [ "libva" ]
+}
+
if (use_vaapi) {
action("libva_generate_stubs") {
extra_header = "va_stub_header.fragment"
@@ -334,6 +340,7 @@ component("gpu") {
"vaapi_drm_picture.h",
]
}
+ public_configs = [ ":libva_config" ]
}
if (is_win) {
Index: beta/media/gpu/gpu_video_decode_accelerator_factory.cc
===================================================================
--- beta.orig/media/gpu/gpu_video_decode_accelerator_factory.cc
+++ beta/media/gpu/gpu_video_decode_accelerator_factory.cc
@@ -86,6 +86,7 @@ GpuVideoDecodeAcceleratorFactory::GetDec
// profile (instead of calculating a superset).
// TODO(posciak,henryhsu): improve this so that we choose a superset of
// resolutions and other supported profile parameters.
+ DVLOG(1) << "Get Supported profiles";
#if defined(OS_WIN)
capabilities.supported_profiles =
DXVAVideoDecodeAccelerator::GetSupportedProfiles(gpu_preferences,
Index: beta/media/gpu/vaapi_wrapper.cc
===================================================================
--- beta.orig/media/gpu/vaapi_wrapper.cc
+++ beta/media/gpu/vaapi_wrapper.cc
@@ -1116,6 +1116,7 @@ void VaapiWrapper::PreSandboxInitializat
if (drm_file.IsValid())
GetDisplayState()->SetDrmFd(drm_file.GetPlatformFile());
#endif
+ GetProfileInfos(); // dlopen all necessary libraries
}
// static
Index: beta/services/ui/gpu/gpu_main.cc
===================================================================
--- beta.orig/services/ui/gpu/gpu_main.cc
+++ beta/services/ui/gpu/gpu_main.cc
@@ -10,6 +10,7 @@
#include "base/power_monitor/power_monitor_device_source.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/sequenced_task_runner_handle.h"
+#include "build/build_config.h"
#include "components/viz/service/display_embedder/gpu_display_provider.h"
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
#include "components/viz/service/gl/gpu_service_impl.h"
@@ -79,7 +80,7 @@ GpuMain::GpuMain(mojom::GpuMainRequest r
thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
#endif
-#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
+#if defined(OS_LINUX)
thread_options.priority = base::ThreadPriority::DISPLAY;
#endif
CHECK(gpu_thread_.StartWithOptions(thread_options));
@@ -89,7 +90,7 @@ GpuMain::GpuMain(mojom::GpuMainRequest r
// should be possible to use |main_task_runner_| for doing IO tasks.
thread_options = base::Thread::Options(base::MessageLoop::TYPE_IO, 0);
thread_options.priority = base::ThreadPriority::NORMAL;
-#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
+#if defined(OS_LINUX)
// TODO(reveman): Remove this in favor of setting it explicitly for each type
// of process.
thread_options.priority = base::ThreadPriority::DISPLAY;