From 7cda9be20eedac2f972f4b99d71a7732d87f1b9b Mon Sep 17 00:00:00 2001 From: Mike Lothian Date: Thu, 23 Apr 2020 09:51:10 +0100 Subject: [PATCH] Enable VAVDA, VAVEA and VAJDA on linux with VAAPI only This patch contains all the changes necessary to use VA-API along with vaapi-driver to run all media use cases supported with hardware acceleration. It is intended to remain as experimental accessible from chrome://flags on linux. It requires libva/intel-vaapi-driver to be installed on the system path where chrome is executed. Other drivers could be tested if available. Flags are kept independent for linux, where this feature has to be enabled before actually using it. This should not change how other OSes use the flags already, the new flags will show at the buttom on the section of unavailable experiments The changes cover a range of compiler pre-processor flags to enable the stack. It moves the presandbox operations to the vaapi_wrapper class as the hook function is available there. vaInit will open driver on the correct installed folder. chrome flags consolidtation into only two flags for linux. Mjpeg and accelerated video are used. The other flags are kept for ChromeOS and other OSes. Developer testing was made on skylake hardware, ChromeOS and Ubuntu. BUG=NONE TEST="subjective testing with VAVDA,VAVEA and VAJDA, autotest for encoder" TEST="and decoder hardware accelerated" TEST="have libva/intel-vaapi-driver installed and not installed in the system" TEST="repeat on different hardware families" R=posciak@chromium.org R=kcwu@chromium.org 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 Change-Id: Ifbbf5c9e5221a8b5733fc6d4d0cf984a1f103171 Signed-off-by: Daniel Charles --- chrome/browser/about_flags.cc | 8 ++++---- chrome/browser/flag_descriptions.cc | 9 ++++++--- chrome/browser/flag_descriptions.h | 10 ++++++++-- gpu/config/software_rendering_list.json | 3 ++- media/gpu/vaapi/vaapi_video_decode_accelerator.cc | 5 +++++ 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 65f76461ec12..5820726d7ad5 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -2153,7 +2153,7 @@ const FeatureEntry kFeatureEntries[] = { "disable-accelerated-video-decode", flag_descriptions::kAcceleratedVideoDecodeName, flag_descriptions::kAcceleratedVideoDecodeDescription, - kOsMac | kOsWin | kOsCrOS | kOsAndroid, + kOsMac | kOsWin | kOsCrOS | kOsAndroid | kOsLinux, SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode), }, { @@ -2585,12 +2585,12 @@ const FeatureEntry kFeatureEntries[] = { flag_descriptions::kWebXrForceRuntimeDescription, kOsDesktop, MULTI_VALUE_TYPE(kWebXrForceRuntimeChoices)}, #endif // ENABLE_VR -#if defined(OS_CHROMEOS) +#if defined(OS_CHROMEOS) || defined(OS_LINUX) {"disable-accelerated-mjpeg-decode", flag_descriptions::kAcceleratedMjpegDecodeName, - flag_descriptions::kAcceleratedMjpegDecodeDescription, kOsCrOS, + flag_descriptions::kAcceleratedMjpegDecodeDescription, kOsCrOS | kOsLinux, SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedMjpegDecode)}, -#endif // OS_CHROMEOS +#endif // OS_CHROMEOS | OS_LINUX {"system-keyboard-lock", flag_descriptions::kSystemKeyboardLockName, flag_descriptions::kSystemKeyboardLockDescription, kOsDesktop, FEATURE_VALUE_TYPE(features::kSystemKeyboardLock)}, diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc index e80fab827621..98b36fa0bcca 100644 --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc @@ -2980,16 +2980,19 @@ const char kMetalDescription[] = #endif -// Chrome OS ------------------------------------------------------------------- - -#if defined(OS_CHROMEOS) +// Chrome OS and Linux ------------------------------------------------------------------- +#if defined(OS_CHROMEOS) || (defined(OS_LINUX) && !defined(OS_ANDROID)) const char kAcceleratedMjpegDecodeName[] = "Hardware-accelerated mjpeg decode for captured frame"; const char kAcceleratedMjpegDecodeDescription[] = "Enable hardware-accelerated mjpeg decode for captured frame where " "available."; +#endif +// Chrome OS ----------------------------------------------------------------------------- + +#if defined(OS_CHROMEOS) const char kAggregatedMlAppRankingName[] = "Rank suggested apps with ML."; const char kAggregatedMlAppRankingDescription[] = "Use the aggregated ML model to rank the suggested apps."; diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h index 7672b58e6a25..a3baa084c5a0 100644 --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h @@ -1711,13 +1711,19 @@ extern const char kMetalDescription[]; #endif // defined(OS_MACOSX) -// Chrome OS ------------------------------------------------------------------ +// Chrome OS and Linux --------------------------------------------------------- -#if defined(OS_CHROMEOS) +#if defined(OS_CHROMEOS) || (defined(OS_LINUX) && !defined(OS_ANDROID)) extern const char kAcceleratedMjpegDecodeName[]; extern const char kAcceleratedMjpegDecodeDescription[]; +#endif + +// Chrome OS ------------------------------------------------------------------- + +#if defined(OS_CHROMEOS) + extern const char kAggregatedMlAppRankingName[]; extern const char kAggregatedMlAppRankingDescription[]; diff --git a/gpu/config/software_rendering_list.json b/gpu/config/software_rendering_list.json index 68bed9e49ddf..5e7fe9cf433b 100644 --- a/gpu/config/software_rendering_list.json +++ b/gpu/config/software_rendering_list.json @@ -337,11 +337,12 @@ }, { "id": 48, - "description": "Accelerated video decode is unavailable on Linux", + "description": "Accelerated VA-API video decode is not supported on NVIDIA platforms", "cr_bugs": [137247, 1032907], "os": { "type": "linux" }, + "vendor_id": "0x10de", "exceptions": [ { "machine_model_name": ["Chromecast"] diff --git a/media/gpu/vaapi/vaapi_video_decode_accelerator.cc b/media/gpu/vaapi/vaapi_video_decode_accelerator.cc index 5020b2b8bf96..a6f1d681b851 100644 --- a/media/gpu/vaapi/vaapi_video_decode_accelerator.cc +++ b/media/gpu/vaapi/vaapi_video_decode_accelerator.cc @@ -66,6 +66,7 @@ void ReportToUMA(VAVDADecoderFailure failure) { VAVDA_DECODER_FAILURES_MAX + 1); } +#if defined(OS_ANDROID) || defined(OS_CHROMEOS) // Returns true if the CPU is an Intel Gemini Lake or later (including Kaby // Lake) Cpu platform id's are referenced from the following file in kernel // source arch/x86/include/asm/intel-family.h @@ -78,6 +79,7 @@ bool IsGeminiLakeOrLater() { cpuid.model() >= kGeminiLakeModelId; return is_geminilake_or_later; } +#endif } // namespace @@ -1155,6 +1157,8 @@ VaapiVideoDecodeAccelerator::DecideBufferAllocationMode() { if (output_mode_ == VideoDecodeAccelerator::Config::OutputMode::IMPORT) return BufferAllocationMode::kNormal; +#if defined(OS_ANDROID) || defined(OS_CHROMEOS) + // Move this to chromeOs only as it is causing problem in some intel linux drivers // On Gemini Lake, Kaby Lake and later we can pass to libva the client's // PictureBuffers to decode onto, which skips the use of the Vpp unit and its // associated format reconciliation copy, avoiding all internal buffer @@ -1171,6 +1175,7 @@ VaapiVideoDecodeAccelerator::DecideBufferAllocationMode() { num_extra_pics_ = 3; return BufferAllocationMode::kNone; } +#endif // If we're here, we have to use the Vpp unit and allocate buffers for // |decoder_|; usually we'd have to allocate the |decoder_|s -- 2.26.2