Advertisement
Guest User

vaapi.patch

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