Advertisement
Guest User

vaapi.patch

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