summarylogtreecommitdiffstats
path: root/add-feature-to-allow-zero-copy-video-formats.patch
blob: dd4ab91e642f34cc63c2884d2ea6421f8d59a468 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
From fb42a91ffae45f6a7c1639ebf0f1622b7c346d1d Mon Sep 17 00:00:00 2001
From: Robert Mader <robert.mader@collabora.com>
Date: Thu, 5 Sep 2024 23:56:20 +0000
Subject: [PATCH] media: Add feature to allow zero-copy video formats with GL
 on Linux

With EGL formats like NV12 can usually be imported directly from VA-API
and V4L2 decoders. Doing so can improve performance a lot - and in cases
where there is no PP to convert to RGB, not supporting it can break HW
decoding altogether.
Unfortunately allowing it unconditionally could cause regressions in
various scenarios - such as when using GLX or a driver that doesn't
support sampling NV12.

Thus introduce a feature - disabled by default for now - to make it easy
to enable these formats.

Note that on Wayland it might be required to disable overlay delegation
with `--disable-features=WaylandOverlayDelegation`.

Change-Id: I8ee396de5f6d4958278b0f0bd53bfa9a7007c8c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5038617
Reviewed-by: Ted (Chromium) Meyer <tmathmeyer@chromium.org>
Reviewed-by: Andres Calderon Jaramillo <andrescj@chromium.org>
Commit-Queue: Andres Calderon Jaramillo <andrescj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1351792}
---
 media/mojo/services/gpu_mojo_media_client_linux.cc | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/media/mojo/services/gpu_mojo_media_client_linux.cc b/media/mojo/services/gpu_mojo_media_client_linux.cc
index c592c2e4c2c2..cd86a3253e07 100644
--- a/media/mojo/services/gpu_mojo_media_client_linux.cc
+++ b/media/mojo/services/gpu_mojo_media_client_linux.cc
@@ -18,6 +18,10 @@ namespace media {
 
 namespace {
 
+BASE_FEATURE(kVaapiVideoDecodeLinuxZeroCopyGL,
+             "VaapiVideoDecodeLinuxZeroCopyGL",
+             base::FEATURE_DISABLED_BY_DEFAULT);
+
 VideoDecoderType GetPreferredLinuxDecoderImplementation() {
   // VaapiVideoDecoder flag is required for VaapiVideoDecoder.
   if (!base::FeatureList::IsEnabled(kVaapiVideoDecodeLinux)) {
@@ -50,8 +54,15 @@ std::vector<Fourcc> GetPreferredRenderableFourccs(
   if (gpu_preferences.gr_context_type == gpu::GrContextType::kVulkan) {
     renderable_fourccs.emplace_back(Fourcc::NV12);
     renderable_fourccs.emplace_back(Fourcc::P010);
-  }
+  } else
 #endif  // BUILDFLAG(ENABLE_VULKAN)
+    // Allow zero-copy formats with GL for testing or in controlled
+    // environments.
+    if (gpu_preferences.gr_context_type == gpu::GrContextType::kGL &&
+        base::FeatureList::IsEnabled(kVaapiVideoDecodeLinuxZeroCopyGL)) {
+      renderable_fourccs.emplace_back(Fourcc::NV12);
+      renderable_fourccs.emplace_back(Fourcc::P010);
+    }
 
   // Support 1-copy argb textures.
   //