Advertisement
Guest User

vaapi.patch

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