Advertisement
Guest User

vaapi.patch

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