Guest User

vaapi.patch

a guest
Aug 30th, 2017
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.15 KB | None | 0 0
  1. From 53b93dfe87fd10cced5d2a2a63072dfc7a2af6e4 Mon Sep 17 00:00:00 2001
  2. From: Daniel Charles <[email protected]>
  3. Date: Fri, 28 Jul 2017 16:31:47 -0700
  4. Subject: [PATCH] Enable VAVDA, VAVEA and VAJDA on linux with VAAPI only
  5.  
  6. This patch contains all the changes necessary to use VA-API along with
  7. vaapi-driver to run all media use cases supported with hardware acceleration.
  8.  
  9. It is intended to remain as experimental accessible from chrome://flags on linux.
  10. It requires libva/intel-vaapi-driver to be installed on the system path where
  11. chrome is executed. Other drivers could be tested if available. Flags are
  12. kept independent for linux, where this feature has to be enabled before
  13. actually using it. This should not change how other OSes use the flags
  14. already, the new flags will show at the buttom on the section of unavailable
  15. experiments
  16.  
  17. The changes cover a range of compiler pre-processor flags to enable the stack.
  18. It moves the presandbox operations to the vaapi_wrapper class as the hook function
  19. is available there. vaInit will open driver on the correct installed folder.
  20.  
  21. chrome flags consolidtation into only two flags for linux. Mjpeg and accelerated
  22. video are used. The other flags are kept for ChromeOS and other OSes.
  23.  
  24. Developer testing was made on skylake hardware, ChromeOS and Ubuntu.
  25.  
  26. BUG=NONE
  27. TEST="subjective testing with VAVDA,VAVEA and VAJDA, autotest for encoder"
  28. TEST="and decoder hardware accelerated"
  29. TEST="have libva/intel-vaapi-driver installed and not installed in the system"
  30. TEST="repeat on different hardware families"
  31.  
  32. 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
  33. Change-Id: Ifbbf5c9e5221a8b5733fc6d4d0cf984a1f103171
  34. Signed-off-by: Daniel Charles <[email protected]>
  35. ---
  36.  
  37. --- a/AUTHORS
  38. +++ b/AUTHORS
  39. @@ -159,6 +159,7 @@
  40. Daniel Bevenius <[email protected]>
  41. Daniel Bomar <[email protected]>
  42. Daniel Carvalho Liedke <[email protected]>
  43. +Daniel Charles <[email protected]>
  44. Daniel Imms <[email protected]>
  45. Daniel Johnson <[email protected]>
  46. Daniel Lockyer <[email protected]>
  47. --- a/chrome/browser/about_flags.cc
  48. +++ b/chrome/browser/about_flags.cc
  49. @@ -1161,12 +1161,14 @@
  50. flag_descriptions::kUiPartialSwapDescription, kOsAll,
  51. SINGLE_DISABLE_VALUE_TYPE(switches::kUIDisablePartialSwap)},
  52. #if BUILDFLAG(ENABLE_WEBRTC)
  53. +#if !defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
  54. {"disable-webrtc-hw-decoding", flag_descriptions::kWebrtcHwDecodingName,
  55. flag_descriptions::kWebrtcHwDecodingDescription, kOsAndroid | kOsCrOS,
  56. SINGLE_DISABLE_VALUE_TYPE(switches::kDisableWebRtcHWDecoding)},
  57. {"disable-webrtc-hw-encoding", flag_descriptions::kWebrtcHwEncodingName,
  58. flag_descriptions::kWebrtcHwEncodingDescription, kOsAndroid | kOsCrOS,
  59. SINGLE_DISABLE_VALUE_TYPE(switches::kDisableWebRtcHWEncoding)},
  60. +#endif
  61. {"enable-webrtc-hw-h264-encoding",
  62. flag_descriptions::kWebrtcHwH264EncodingName,
  63. flag_descriptions::kWebrtcHwH264EncodingDescription, kOsAndroid | kOsCrOS,
  64. @@ -1474,6 +1476,13 @@
  65. flag_descriptions::kMultideviceDescription, kOsCrOS,
  66. FEATURE_VALUE_TYPE(features::kMultidevice)},
  67. #endif // OS_CHROMEOS
  68. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
  69. + {
  70. + "enable-accelerated-video", flag_descriptions::kAcceleratedVideoName,
  71. + flag_descriptions::kAcceleratedVideoDescription, kOsLinux,
  72. + SINGLE_VALUE_TYPE(switches::kEnableAcceleratedVideo),
  73. + },
  74. +#else
  75. {
  76. "disable-accelerated-video-decode",
  77. flag_descriptions::kAcceleratedVideoDecodeName,
  78. @@ -1481,6 +1490,7 @@
  79. kOsMac | kOsWin | kOsCrOS | kOsAndroid,
  80. SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode),
  81. },
  82. +#endif
  83. #if defined(OS_WIN)
  84. {
  85. "enable-hdr", flag_descriptions::kEnableHDRName,
  86. @@ -2127,12 +2137,17 @@
  87. FEATURE_VALUE_TYPE(chrome::android::kWebVrAutopresent)},
  88. #endif // OS_ANDROID
  89. #endif // ENABLE_VR
  90. -#if defined(OS_CHROMEOS)
  91. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
  92. + {"enable-accelerated-mjpeg-decode",
  93. + flag_descriptions::kAcceleratedMjpegDecodeName,
  94. + flag_descriptions::kAcceleratedMjpegDecodeDescription, kOsLinux,
  95. + SINGLE_VALUE_TYPE(switches::kEnableAcceleratedMjpegDecode)},
  96. +#elif defined(OS_CHROMEOS)
  97. {"disable-accelerated-mjpeg-decode",
  98. flag_descriptions::kAcceleratedMjpegDecodeName,
  99. flag_descriptions::kAcceleratedMjpegDecodeDescription, kOsCrOS,
  100. SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedMjpegDecode)},
  101. -#endif // OS_CHROMEOS
  102. +#endif
  103. {"v8-cache-options", flag_descriptions::kV8CacheOptionsName,
  104. flag_descriptions::kV8CacheOptionsDescription, kOsAll,
  105. MULTI_VALUE_TYPE(kV8CacheOptionsChoices)},
  106. --- a/chrome/browser/chromeos/login/chrome_restart_request.cc
  107. +++ b/chrome/browser/chromeos/login/chrome_restart_request.cc
  108. @@ -19,6 +19,7 @@
  109. #include "base/sys_info.h"
  110. #include "base/timer/timer.h"
  111. #include "base/values.h"
  112. +#include "build/build_config.h"
  113. #include "cc/base/switches.h"
  114. #include "chrome/browser/browser_process.h"
  115. #include "chrome/browser/chromeos/boot_times_recorder.h"
  116. @@ -79,8 +80,13 @@
  117. ::switches::kDisable2dCanvasImageChromium,
  118. ::switches::kDisableAccelerated2dCanvas,
  119. ::switches::kDisableAcceleratedJpegDecoding,
  120. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
  121. + ::switches::kEnableAcceleratedMjpegDecode,
  122. + ::switches::kEnableAcceleratedVideo,
  123. +#else
  124. ::switches::kDisableAcceleratedMjpegDecode,
  125. ::switches::kDisableAcceleratedVideoDecode,
  126. +#endif
  127. ::switches::kDisableBlinkFeatures,
  128. ::switches::kDisableCastStreamingHWEncoding,
  129. ::switches::kDisableDistanceFieldText,
  130. @@ -169,7 +175,7 @@
  131. ::switches::kDisableWebGLImageChromium,
  132. ::switches::kEnableWebGLImageChromium,
  133. ::switches::kEnableWebVR,
  134. -#if BUILDFLAG(ENABLE_WEBRTC)
  135. +#if BUILDFLAG(ENABLE_WEBRTC) && (defined(OS_CHROMEOS) || defined(OS_ANDROID))
  136. ::switches::kDisableWebRtcHWDecoding,
  137. ::switches::kDisableWebRtcHWEncoding,
  138. #endif
  139. --- a/chrome/browser/flag_descriptions.cc
  140. +++ b/chrome/browser/flag_descriptions.cc
  141. @@ -370,6 +370,13 @@ const char kAccelerated2dCanvasDescript
  142. "Enables the use of the GPU to perform 2d canvas rendering instead of "
  143. "using software rendering.";
  144.  
  145. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
  146. +const char kAcceleratedVideoName[] = "Hardware-accelerated video";
  147. +const char kAcceleratedVideoDescription[] =
  148. + "Hardware-accelerated video where VA-API driver is installed on the"
  149. + "system.";
  150. +#endif
  151. +
  152. const char kAcceleratedVideoDecodeName[] = "Hardware-accelerated video decode";
  153. const char kAcceleratedVideoDecodeDescription[] =
  154. "Hardware-accelerated video decode where available.";
  155. @@ -527,6 +540,7 @@
  156. const char kWebglDraftExtensionsDescription[] =
  157. "Enabling this option allows web applications to access the WebGL "
  158. "Extensions that are still in draft status.";
  159.  
  160. +#if !defined(OS_LINUX) || !defined(OS_CHROMEOS)
  161. const char kWebrtcHwDecodingName[] = "WebRTC hardware video decoding";
  162.  
  163. const char kWebrtcHwDecodingDescription[] =
  164. "Support in WebRTC for decoding video streams using platform hardware.";
  165.  
  166. @@ -536,6 +544,7 @@
  167. const char kWebrtcHwEncodingName[] = "WebRTC hardware video encoding";
  168.  
  169. const char kWebrtcHwEncodingDescription[] =
  170. "Support in WebRTC for encoding video streams using platform hardware.";
  171. +#endif
  172.  
  173. const char kWebrtcHwH264EncodingName[] = "WebRTC hardware h264 video encoding";
  174.  
  175. const char kWebrtcHwH264EncodingDescription[] =
  176. "Support in WebRTC for encoding h264 video streams using platform "
  177. "hardware.";
  178. @@ -1514,7 +1524,7 @@
  179.  
  180. #endif // defined(OS_MACOSX)
  181.  
  182. -#if defined(OS_CHROMEOS)
  183. +#if defined(OS_CHROMEOS) || (defined(OS_LINUX) && !defined(OS_ANDROID))
  184.  
  185. const char kAcceleratedMjpegDecodeName[] =
  186. "Hardware-accelerated mjpeg decode for captured frame";
  187. @@ -2126,7 +2135,7 @@
  188. "Enable hardware-accelerated mjpeg decode for captured frame where "
  189. "available.";
  190.  
  191. -#endif // defined(OS_CHROMEOS)
  192. +#endif // defined(OS_CHROMEOS) || BUILDFLAG(USE_VAAPI)
  193.  
  194. #if defined(OS_WIN)
  195.  
  196. --- a/chrome/browser/flag_descriptions.h
  197. +++ b/chrome/browser/flag_descriptions.h
  198. @@ -34,6 +34,10 @@
  199. extern const char kAccelerated2dCanvasName[];
  200. extern const char kAccelerated2dCanvasDescription[];
  201.  
  202. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
  203. +extern const char kAcceleratedVideoName[];
  204. +extern const char kAcceleratedVideoDescription[];
  205. +#endif
  206. extern const char kAcceleratedVideoDecodeName[];
  207. extern const char kAcceleratedVideoDecodeDescription[];
  208.  
  209. @@ -1251,13 +1255,17 @@
  210.  
  211. #endif // defined(OS_MACOSX)
  212.  
  213. -// Chrome OS ------------------------------------------------------------------
  214. -
  215. -#if defined(OS_CHROMEOS)
  216. +#if defined(OS_CHROMEOS) || (defined(OS_LINUX) && !defined(OS_ANDROID))
  217.  
  218. extern const char kAcceleratedMjpegDecodeName[];
  219. extern const char kAcceleratedMjpegDecodeDescription[];
  220.  
  221. +#endif
  222. +
  223. +// Chrome OS ------------------------------------------------------------------
  224. +
  225. +#if defined(OS_CHROMEOS)
  226. +
  227. extern const char kAllowTouchpadThreeFingerClickName[];
  228. extern const char kAllowTouchpadThreeFingerClickDescription[];
  229.  
  230. --- a/content/browser/gpu/compositor_util.cc
  231. +++ b/content/browser/gpu/compositor_util.cc
  232. @@ -104,7 +104,11 @@
  233. {"video_decode",
  234. manager->IsFeatureBlacklisted(
  235. gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE),
  236. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
  237. + !command_line.HasSwitch(switches::kEnableAcceleratedVideo),
  238. +#else
  239. command_line.HasSwitch(switches::kDisableAcceleratedVideoDecode),
  240. +#endif
  241. "Accelerated video decode has been disabled, either via blacklist,"
  242. " about:flags or the command line.",
  243. true},
  244. @@ -112,7 +116,11 @@
  245. {"video_encode",
  246. manager->IsFeatureBlacklisted(
  247. gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_ENCODE),
  248. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
  249. + !command_line.HasSwitch(switches::kEnableAcceleratedVideo),
  250. +#else
  251. command_line.HasSwitch(switches::kDisableWebRtcHWEncoding),
  252. +#endif
  253. "Accelerated video encode has been disabled, either via blacklist,"
  254. " about:flags or the command line.",
  255. true},
  256. --- a/content/browser/gpu/gpu_data_manager_impl_private.cc
  257. +++ b/content/browser/gpu/gpu_data_manager_impl_private.cc
  258. @@ -760,7 +760,11 @@
  259. DCHECK(command_line);
  260.  
  261. if (ShouldDisableAcceleratedVideoDecode(command_line))
  262. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
  263. + command_line->AppendSwitch(switches::kEnableAcceleratedVideo);
  264. +#else
  265. command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
  266. +#endif
  267.  
  268. #if defined(USE_AURA)
  269. if (!CanUseGpuBrowserCompositor())
  270. @@ -818,7 +833,11 @@
  271. if (gpu_preferences) {
  272. gpu_preferences->disable_accelerated_video_decode = true;
  273. } else {
  274. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
  275. + command_line->AppendSwitch(switches::kEnableAcceleratedVideo);
  276. +#else
  277. command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
  278. +#endif
  279. }
  280. }
  281. @@ -912,7 +920,12 @@
  282. const base::CommandLine* command_line =
  283. base::CommandLine::ForCurrentProcess();
  284. if (!ShouldDisableAcceleratedVideoDecode(command_line) &&
  285. - !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) {
  286. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
  287. + command_line->HasSwitch(switches::kEnableAcceleratedVideo)
  288. +#else
  289. + !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)
  290. +#endif
  291. + ) {
  292. prefs->pepper_accelerated_video_decode_enabled = true;
  293. }
  294. prefs->disable_2d_canvas_copy_on_write =
  295. @@ -1107,7 +1120,13 @@
  296. // to resolve crbug/442039 has been collected.
  297. const std::string group_name = base::FieldTrialList::FindFullName(
  298. "DisableAcceleratedVideoDecode");
  299. - if (command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) {
  300. + if (
  301. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
  302. + !command_line->HasSwitch(switches::kEnableAcceleratedVideo)
  303. +#else
  304. + command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)
  305. +#endif
  306. + ) {
  307. // It was already disabled on the command line.
  308. return false;
  309. }
  310. --- a/content/browser/gpu/gpu_process_host.cc
  311. +++ b/content/browser/gpu/gpu_process_host.cc
  312. @@ -116,7 +116,11 @@
  313. // Command-line switches to propagate to the GPU process.
  314. static const char* const kSwitchNames[] = {
  315. switches::kCreateDefaultGLContext,
  316. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
  317. + switches::kEnableAcceleratedVideo,
  318. +#else
  319. switches::kDisableAcceleratedVideoDecode,
  320. +#endif
  321. switches::kDisableBreakpad,
  322. switches::kDisableES3GLContext,
  323. switches::kDisableGpuRasterization,
  324. @@ -126,7 +130,7 @@
  325. switches::kDisableLogging,
  326. switches::kDisableSeccompFilterSandbox,
  327. switches::kDisableShaderNameHashing,
  328. -#if BUILDFLAG(ENABLE_WEBRTC)
  329. +#if BUILDFLAG(ENABLE_WEBRTC) && !defined(OS_LINUX)
  330. switches::kDisableWebRtcHWEncoding,
  331. #endif
  332. #if defined(OS_WIN)
  333. --- a/content/browser/renderer_host/media/video_capture_browsertest.cc
  334. +++ b/content/browser/renderer_host/media/video_capture_browsertest.cc
  335. @@ -154,8 +154,13 @@
  336. base::CommandLine::ForCurrentProcess()->AppendSwitch(
  337. switches::kUseFakeJpegDecodeAccelerator);
  338. } else {
  339. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
  340. + base::CommandLine::ForCurrentProcess()->AppendSwitch(
  341. + switches::kEnableAcceleratedMjpegDecode);
  342. +#else
  343. base::CommandLine::ForCurrentProcess()->AppendSwitch(
  344. switches::kDisableAcceleratedMjpegDecode);
  345. +#endif
  346. }
  347. if (params_.use_mojo_service) {
  348. base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
  349. --- a/content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.cc
  350. +++ b/content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.cc
  351. @@ -56,15 +56,21 @@
  352. bool is_platform_supported =
  353. base::CommandLine::ForCurrentProcess()->HasSwitch(
  354. switches::kUseFakeJpegDecodeAccelerator);
  355. -#if defined(OS_CHROMEOS)
  356. - // Non-ChromeOS platforms do not support HW JPEG decode now. Do not establish
  357. - // gpu channel to avoid introducing overhead.
  358. +#if !defined(OS_ANDROID) && defined(OS_LINUX)
  359. + // Non-ChromeOS or Non-Linux platforms do not support HW JPEG decode now. Do
  360. + // not establish gpu channel to avoid introducing overhead.
  361. is_platform_supported = true;
  362. #endif
  363.  
  364. if (!is_platform_supported ||
  365. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
  366. + !base::CommandLine::ForCurrentProcess()->HasSwitch(
  367. + switches::kEnableAcceleratedMjpegDecode)
  368. +#else
  369. base::CommandLine::ForCurrentProcess()->HasSwitch(
  370. - switches::kDisableAcceleratedMjpegDecode)) {
  371. + switches::kDisableAcceleratedMjpegDecode)
  372. +#endif
  373. + ) {
  374. decoder_status_ = FAILED;
  375. RecordInitDecodeUMA_Locked();
  376. return;
  377. --- a/content/browser/renderer_host/render_process_host_impl.cc
  378. +++ b/content/browser/renderer_host/render_process_host_impl.cc
  379. @@ -2450,7 +2450,11 @@
  380. switches::kDisable2dCanvasImageChromium,
  381. switches::kDisable3DAPIs,
  382. switches::kDisableAcceleratedJpegDecoding,
  383. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
  384. + switches::kEnableAcceleratedVideo,
  385. +#else
  386. switches::kDisableAcceleratedVideoDecode,
  387. +#endif
  388. switches::kDisableBackgroundTimerThrottling,
  389. switches::kDisableBlinkFeatures,
  390. switches::kDisableBreakpad,
  391. @@ -2603,8 +2607,10 @@
  392. switches::kEnablePepperTesting,
  393. #endif
  394. #if BUILDFLAG(ENABLE_WEBRTC)
  395. +#if !defined(OS_LINUX) || defined(OS_CHROMEOS)
  396. switches::kDisableWebRtcHWDecoding,
  397. switches::kDisableWebRtcHWEncoding,
  398. +#endif
  399. switches::kEnableWebRtcSrtpAesGcm,
  400. switches::kEnableWebRtcStunOrigin,
  401. switches::kEnforceWebRtcIPPermissionCheck,
  402. --- a/content/browser/webrtc/webrtc_media_recorder_browsertest.cc
  403. +++ b/content/browser/webrtc/webrtc_media_recorder_browsertest.cc
  404. @@ -58,7 +58,12 @@
  405. return;
  406. // This flag is also used for encoding, https://crbug.com/616640.
  407. base::CommandLine::ForCurrentProcess()->AppendSwitch(
  408. - switches::kDisableAcceleratedVideoDecode);
  409. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
  410. + switches::kEnableAcceleratedVideo
  411. +#else
  412. + switches::kDisableAcceleratedVideoDecode
  413. +#endif
  414. + );
  415. }
  416.  
  417. private:
  418. --- a/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
  419. +++ b/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
  420. @@ -56,22 +56,6 @@
  421. #endif
  422. }
  423.  
  424. -inline bool IsArchitectureX86_64() {
  425. -#if defined(__x86_64__)
  426. - return true;
  427. -#else
  428. - return false;
  429. -#endif
  430. -}
  431. -
  432. -inline bool IsArchitectureI386() {
  433. -#if defined(__i386__)
  434. - return true;
  435. -#else
  436. - return false;
  437. -#endif
  438. -}
  439. -
  440. inline bool IsArchitectureArm() {
  441. #if defined(__arm__) || defined(__aarch64__)
  442. return true;
  443. @@ -96,21 +80,14 @@
  444. #endif
  445. }
  446.  
  447. -bool IsAcceleratedVaapiVideoEncodeEnabled() {
  448. - bool accelerated_encode_enabled = false;
  449. -#if defined(OS_CHROMEOS)
  450. - const base::CommandLine& command_line =
  451. - *base::CommandLine::ForCurrentProcess();
  452. - accelerated_encode_enabled =
  453. - !command_line.HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode);
  454. -#endif
  455. - return accelerated_encode_enabled;
  456. -}
  457. -
  458. bool IsAcceleratedVideoDecodeEnabled() {
  459. const base::CommandLine& command_line =
  460. *base::CommandLine::ForCurrentProcess();
  461. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
  462. + return command_line.HasSwitch(switches::kEnableAcceleratedVideo);
  463. +#else
  464. return !command_line.HasSwitch(switches::kDisableAcceleratedVideoDecode);
  465. +#endif
  466. }
  467.  
  468. intptr_t GpuSIGSYS_Handler(const struct arch_seccomp_data& args,
  469. @@ -296,33 +273,6 @@
  470. GpuBrokerProcessPolicy::Create,
  471. std::vector<BrokerFilePermission>()); // No extra files in whitelist.
  472.  
  473. - if (IsArchitectureX86_64() || IsArchitectureI386()) {
  474. - // Accelerated video dlopen()'s some shared objects
  475. - // inside the sandbox, so preload them now.
  476. - if (IsAcceleratedVaapiVideoEncodeEnabled() ||
  477. - IsAcceleratedVideoDecodeEnabled()) {
  478. - const char* I965DrvVideoPath = NULL;
  479. - const char* I965HybridDrvVideoPath = NULL;
  480. -
  481. - if (IsArchitectureX86_64()) {
  482. - I965DrvVideoPath = "/usr/lib64/va/drivers/i965_drv_video.so";
  483. - I965HybridDrvVideoPath = "/usr/lib64/va/drivers/hybrid_drv_video.so";
  484. - } else if (IsArchitectureI386()) {
  485. - I965DrvVideoPath = "/usr/lib/va/drivers/i965_drv_video.so";
  486. - }
  487. -
  488. - dlopen(I965DrvVideoPath, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
  489. - if (I965HybridDrvVideoPath)
  490. - dlopen(I965HybridDrvVideoPath, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
  491. - dlopen("libva.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
  492. -#if defined(USE_OZONE)
  493. - dlopen("libva-drm.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
  494. -#elif defined(USE_X11)
  495. - dlopen("libva-x11.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
  496. -#endif
  497. - }
  498. - }
  499. -
  500. return true;
  501. }
  502.  
  503. --- a/content/gpu/BUILD.gn
  504. +++ b/content/gpu/BUILD.gn
  505. @@ -45,7 +45,6 @@
  506. ]
  507.  
  508. configs += [ "//content:content_implementation" ]
  509. -
  510. deps = [
  511. "//base",
  512. "//base/third_party/dynamic_annotations",
  513. @@ -114,4 +113,8 @@
  514. if (enable_vulkan) {
  515. deps += [ "//gpu/vulkan" ]
  516. }
  517. +
  518. + if (is_desktop_linux) {
  519. + public_configs = [ "//media/gpu:libva_config" ]
  520. + }
  521. }
  522. --- a/content/gpu/gpu_main.cc
  523. +++ b/content/gpu/gpu_main.cc
  524. @@ -246,7 +246,7 @@
  525. // Initializes StatisticsRecorder which tracks UMA histograms.
  526. base::StatisticsRecorder::Initialize();
  527.  
  528. -#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
  529. +#if defined(OS_LINUX)
  530. // Set thread priority before sandbox initialization.
  531. base::PlatformThread::SetCurrentThreadPriority(base::ThreadPriority::DISPLAY);
  532. #endif
  533. @@ -274,7 +274,7 @@
  534. GetContentClient()->SetGpuInfo(gpu_init.gpu_info());
  535.  
  536. base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL;
  537. -#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
  538. +#if defined(OS_LINUX)
  539. io_thread_priority = base::ThreadPriority::DISPLAY;
  540. #endif
  541.  
  542. --- a/content/public/browser/gpu_utils.cc
  543. +++ b/content/public/browser/gpu_utils.cc
  544. @@ -7,6 +7,7 @@
  545. #include "base/command_line.h"
  546. #include "base/single_thread_task_runner.h"
  547. #include "base/strings/string_number_conversions.h"
  548. +#include "build/build_config.h"
  549. #include "content/browser/gpu/gpu_process_host.h"
  550. #include "content/public/common/content_features.h"
  551. #include "content/public/common/content_switches.h"
  552. @@ -56,12 +57,19 @@
  553. gpu_preferences.ui_prioritize_in_gpu_process =
  554. command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess);
  555. gpu_preferences.disable_accelerated_video_decode =
  556. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
  557. + !command_line->HasSwitch(switches::kEnableAcceleratedVideo);
  558. +#else
  559. command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode);
  560. -#if defined(OS_CHROMEOS)
  561. +#endif
  562. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
  563. + gpu_preferences.disable_vaapi_accelerated_video_encode =
  564. + !command_line->HasSwitch(switches::kEnableAcceleratedVideo);
  565. +#elif defined(OS_CHROMEOS)
  566. gpu_preferences.disable_vaapi_accelerated_video_encode =
  567. command_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode);
  568. #endif
  569. -#if BUILDFLAG(ENABLE_WEBRTC)
  570. +#if BUILDFLAG(ENABLE_WEBRTC) && (!defined(OS_LINUX) || defined(OS_CHROMEOS))
  571. gpu_preferences.disable_web_rtc_hw_encoding =
  572. command_line->HasSwitch(switches::kDisableWebRtcHWEncoding);
  573. #endif
  574. --- a/content/public/common/content_switches.cc
  575. +++ b/content/public/common/content_switches.cc
  576. @@ -85,12 +85,21 @@
  577.  
  578. // Disable gpu-accelerated 2d canvas.
  579. const char kDisableAccelerated2dCanvas[] = "disable-accelerated-2d-canvas";
  580. -
  581. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
  582. +// Enable hardware accelerated mjpeg decode on linux
  583. +const char kEnableAcceleratedMjpegDecode[] = "enable-accelerated-mjpeg-decode";
  584. +#else
  585. // Disable hardware acceleration of mjpeg decode for captured frame, where
  586. // available.
  587. const char kDisableAcceleratedMjpegDecode[] =
  588. "disable-accelerated-mjpeg-decode";
  589. +#endif
  590.  
  591. +#if defined(OS_LINUX)
  592. +// Enables hardware acceleration of video for Linux only. VA-API driver
  593. +// is required to be present on the system installation.
  594. +const char kEnableAcceleratedVideo[] = "enable-accelerated-video";
  595. +#endif
  596. // Disables hardware acceleration of video decode, where available.
  597. const char kDisableAcceleratedVideoDecode[] =
  598. "disable-accelerated-video-decode";
  599. @@ -915,11 +924,13 @@
  600. // ignores this switch on its stable and beta channels.
  601. const char kDisableWebRtcEncryption[] = "disable-webrtc-encryption";
  602.  
  603. +#if defined(OS_CHROMEOS)
  604. // Disables HW decode acceleration for WebRTC.
  605. const char kDisableWebRtcHWDecoding[] = "disable-webrtc-hw-decoding";
  606.  
  607. // Disables HW encode acceleration for WebRTC.
  608. const char kDisableWebRtcHWEncoding[] = "disable-webrtc-hw-encoding";
  609. +#endif
  610.  
  611. // Enables negotiation of GCM cipher suites from RFC 7714 for SRTP in WebRTC.
  612. // See https://tools.ietf.org/html/rfc7714 for further information.
  613. --- a/content/public/common/content_switches.h
  614. +++ b/content/public/common/content_switches.h
  615. @@ -34,7 +34,11 @@
  616. CONTENT_EXPORT extern const char kDisable3DAPIs[];
  617. CONTENT_EXPORT extern const char kDisableAccelerated2dCanvas[];
  618. CONTENT_EXPORT extern const char kDisableAcceleratedJpegDecoding[];
  619. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
  620. +CONTENT_EXPORT extern const char kEnableAcceleratedMjpegDecode[];
  621. +#else
  622. CONTENT_EXPORT extern const char kDisableAcceleratedMjpegDecode[];
  623. +#endif
  624. CONTENT_EXPORT extern const char kDisableAcceleratedVideoDecode[];
  625. CONTENT_EXPORT extern const char kDisableAudioSupportForDesktopShare[];
  626. extern const char kDisableBackingStoreLimit[];
  627. @@ -107,6 +110,9 @@
  628. CONTENT_EXPORT extern const char kDomAutomationController[];
  629. extern const char kDisable2dCanvasClipAntialiasing[];
  630. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
  631. +CONTENT_EXPORT extern const char kEnableAcceleratedVideo[];
  632. +#endif
  633. CONTENT_EXPORT extern const char kEnableAggressiveDOMStorageFlushing[];
  634. CONTENT_EXPORT extern const char kEnablePreferCompositingToLCDText[];
  635. CONTENT_EXPORT extern const char kEnableBlinkFeatures[];
  636. @@ -257,8 +264,10 @@
  637.  
  638. #if BUILDFLAG(ENABLE_WEBRTC)
  639. CONTENT_EXPORT extern const char kDisableWebRtcEncryption[];
  640. +#if defined(OS_CHROMEOS)
  641. CONTENT_EXPORT extern const char kDisableWebRtcHWDecoding[];
  642. CONTENT_EXPORT extern const char kDisableWebRtcHWEncoding[];
  643. +#endif
  644. CONTENT_EXPORT extern const char kEnableWebRtcSrtpAesGcm[];
  645. CONTENT_EXPORT extern const char kEnableWebRtcStunOrigin[];
  646. CONTENT_EXPORT extern const char kEnforceWebRtcIPPermissionCheck[];
  647. --- a/content/renderer/media/webrtc/peer_connection_dependency_factory.cc
  648. +++ b/content/renderer/media/webrtc/peer_connection_dependency_factory.cc
  649. @@ -240,10 +240,19 @@
  650.  
  651. const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
  652. if (gpu_factories && gpu_factories->IsGpuVideoAcceleratorEnabled()) {
  653. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
  654. + if (cmd_line->HasSwitch(switches::kEnableAcceleratedVideo))
  655. +#else
  656. if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWDecoding))
  657. +#endif
  658. decoder_factory.reset(new RTCVideoDecoderFactory(gpu_factories));
  659.  
  660. - if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWEncoding)) {
  661. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
  662. + if (cmd_line->HasSwitch(switches::kEnableAcceleratedVideo))
  663. +#else
  664. + if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWEncoding))
  665. +#endif
  666. + {
  667. encoder_factory.reset(new RTCVideoEncoderFactory(gpu_factories));
  668. }
  669. }
  670. --- a/content/renderer/render_thread_impl.cc
  671. +++ b/content/renderer/render_thread_impl.cc
  672. @@ -1443,7 +1443,11 @@
  673. scoped_refptr<base::SingleThreadTaskRunner> media_task_runner =
  674. GetMediaThreadTaskRunner();
  675. const bool enable_video_accelerator =
  676. +#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
  677. + cmd_line->HasSwitch(switches::kEnableAcceleratedVideo);
  678. +#else
  679. !cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode);
  680. +#endif
  681. const bool enable_gpu_memory_buffer_video_frames =
  682. #if defined(OS_MACOSX) || defined(OS_LINUX)
  683. !cmd_line->HasSwitch(switches::kDisableGpuMemoryBufferVideoFrames) &&
  684. --- a/gpu/command_buffer/service/gpu_preferences.h
  685. +++ b/gpu/command_buffer/service/gpu_preferences.h
  686. @@ -50,7 +50,7 @@
  687. // Disables hardware acceleration of video decode, where available.
  688. bool disable_accelerated_video_decode = false;
  689.  
  690. -#if defined(OS_CHROMEOS)
  691. +#if defined(OS_CHROMEOS) || defined(OS_LINUX)
  692. // Disables VA-API accelerated video encode.
  693. bool disable_vaapi_accelerated_video_encode = false;
  694. #endif
  695. --- a/gpu/config/software_rendering_list.json
  696. +++ b/gpu/config/software_rendering_list.json
  697. @@ -371,17 +371,6 @@
  698. ]
  699. },
  700. {
  701. - "id": 48,
  702. - "description": "Accelerated video decode is unavailable on Linux",
  703. - "cr_bugs": [137247],
  704. - "os": {
  705. - "type": "linux"
  706. - },
  707. - "features": [
  708. - "accelerated_video_decode"
  709. - ]
  710. - },
  711. - {
  712. "id": 50,
  713. "description": "Disable VMware software renderer on older Mesa",
  714. "cr_bugs": [145531, 332596, 571899, 629434],
  715. --- a/media/BUILD.gn
  716. +++ b/media/BUILD.gn
  717. @@ -195,7 +195,7 @@
  718. ]
  719. }
  720.  
  721. - if (current_cpu != "arm" && is_chromeos) {
  722. + if (current_cpu != "arm" && (is_chromeos || is_desktop_linux)) {
  723. sources += [
  724. "filters/h264_bitstream_buffer.cc",
  725. "filters/h264_bitstream_buffer.h",
  726. --- a/media/gpu/BUILD.gn
  727. +++ b/media/gpu/BUILD.gn
  728. @@ -18,6 +18,15 @@
  729. import("//build/config/mac/mac_sdk.gni")
  730. }
  731.  
  732. +if (is_desktop_linux && use_vaapi) {
  733. + import("//build/config/linux/pkg_config.gni")
  734. +
  735. + pkg_config("libva_config") {
  736. + packages = [ "libva" ]
  737. + }
  738. +}
  739. +
  740. + if (use_vaapi) {
  741. - if (is_chromeos && current_cpu != "arm") {
  742. action("libva_generate_stubs") {
  743. extra_header = "va_stub_header.fragment"
  744. @@ -241,7 +266,7 @@
  745. }
  746.  
  747. - if (is_chromeos) {
  748. + if (is_chromeos || is_desktop_linux) {
  749. sources += [
  750. "vp8_decoder.cc",
  751. "vp8_decoder.h",
  752. @@ -341,6 +349,9 @@
  753. "vaapi_drm_picture.h",
  754. ]
  755. }
  756. + if (is_desktop_linux) {
  757. + public_configs = [ ":libva_config" ]
  758. + }
  759. }
  760.  
  761. if (is_win) {
  762. @@ -387,7 +398,7 @@
  763. }
  764.  
  765. # TODO(watk): Run this on bots. http://crbug.com/461437
  766. -if (is_win || is_android || is_chromeos) {
  767. +if (is_win || is_android || is_chromeos || is_desktop_linux) {
  768. test("video_decode_accelerator_unittest") {
  769. sources = [
  770. "video_accelerator_unittest_helpers.h",
  771. @@ -500,7 +511,7 @@
  772. }
  773. }
  774.  
  775. -if (is_chromeos || is_mac || is_win) {
  776. +if (is_chromeos || is_mac || is_win || is_desktop_linux) {
  777. test("video_encode_accelerator_unittest") {
  778. deps = [
  779. "//base",
  780. @@ -532,7 +543,7 @@
  781. }
  782. }
  783.  
  784. -if (is_chromeos) {
  785. +if (is_chromeos || is_desktop_linux) {
  786. test("jpeg_decode_accelerator_unittest") {
  787. deps = [
  788. "//base",
  789. --- a/media/gpu/gpu_video_decode_accelerator_factory.cc
  790. +++ b/media/gpu/gpu_video_decode_accelerator_factory.cc
  791. @@ -18,7 +18,7 @@
  792. #include "media/gpu/dxva_video_decode_accelerator_win.h"
  793. #elif defined(OS_MACOSX)
  794. #include "media/gpu/vt_video_decode_accelerator_mac.h"
  795. -#elif defined(OS_CHROMEOS)
  796. +#elif defined(OS_CHROMEOS) || defined(OS_LINUX)
  797. #if defined(USE_V4L2_CODEC)
  798. #include "media/gpu/v4l2_device.h"
  799. #include "media/gpu/v4l2_slice_video_decode_accelerator.h"
  800. @@ -85,6 +85,7 @@
  801. // profile (instead of calculating a superset).
  802. // TODO(posciak,henryhsu): improve this so that we choose a superset of
  803. // resolutions and other supported profile parameters.
  804. + DVLOG(1) << "Get Supported profiles";
  805. #if defined(OS_WIN)
  806. capabilities.supported_profiles =
  807. DXVAVideoDecodeAccelerator::GetSupportedProfiles(gpu_preferences,
  808. --- a/media/gpu/gpu_video_encode_accelerator_factory.cc
  809. +++ b/media/gpu/gpu_video_encode_accelerator_factory.cc
  810. @@ -9,7 +9,7 @@
  811. #include "media/gpu/features.h"
  812. #include "media/gpu/gpu_video_accelerator_util.h"
  813.  
  814. -#if defined(OS_CHROMEOS)
  815. +#if defined(OS_CHROMEOS) || defined(OS_LINUX)
  816. #if defined(USE_V4L2_CODEC)
  817. #include "media/gpu/v4l2_video_encode_accelerator.h"
  818. #endif
  819. --- a/media/gpu/vaapi_wrapper.cc
  820. +++ b/media/gpu/vaapi_wrapper.cc
  821. @@ -1110,6 +1110,7 @@
  822. if (drm_file.IsValid())
  823. GetDisplayState()->SetDrmFd(drm_file.GetPlatformFile());
  824. #endif
  825. + GetProfileInfos(); // dlopen all necessary libraries
  826. }
  827.  
  828. // static
  829. --- a/services/ui/gpu/gpu_main.cc
  830. +++ b/services/ui/gpu/gpu_main.cc
  831. @@ -10,6 +10,7 @@
  832. #include "base/power_monitor/power_monitor_device_source.h"
  833. #include "base/single_thread_task_runner.h"
  834. +#include "build/build_config.h"
  835. #include "components/viz/frame_sinks/mojo_frame_sink_manager.h"
  836. #include "gpu/command_buffer/common/activity_flags.h"
  837. #include "gpu/ipc/common/gpu_memory_buffer_support.h"
  838. @@ -79,7 +80,7 @@
  839. thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
  840. #endif
  841.  
  842. -#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
  843. +#if defined(OS_LINUX)
  844. thread_options.priority = base::ThreadPriority::DISPLAY;
  845. #endif
  846. CHECK(gpu_thread_.StartWithOptions(thread_options));
  847. @@ -89,7 +90,7 @@
  848. // should be possible to use |main_task_runner_| for doing IO tasks.
  849. thread_options = base::Thread::Options(base::MessageLoop::TYPE_IO, 0);
  850. thread_options.priority = base::ThreadPriority::NORMAL;
  851. -#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
  852. +#if defined(OS_LINUX)
  853. // TODO(reveman): Remove this in favor of setting it explicitly for each type
  854. // of process.
  855. thread_options.priority = base::ThreadPriority::DISPLAY;
Advertisement
Add Comment
Please, Sign In to add comment