Advertisement
Guest User

vaapi.patch

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