Advertisement
Guest User

vaapi.patch

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