Merge ~b-stolk/chromium-browser/+git/snap-from-source:dynamic-nv12-test into ~chromium-team/chromium-browser/+git/snap-from-source:hwacc-dev

Proposed by Bram Stolk
Status: Merged
Merged at revision: 306f8cea55dd2cdf4bbcccb7357ecefb704c3b60
Proposed branch: ~b-stolk/chromium-browser/+git/snap-from-source:dynamic-nv12-test
Merge into: ~chromium-team/chromium-browser/+git/snap-from-source:hwacc-dev
Diff against target: 251 lines (+212/-5)
4 files modified
build/args.gn (+3/-2)
build/chromium-patches/af887ba.diff (+206/-0)
build/chromium-patches/series (+1/-0)
launcher/chromium.launcher (+2/-3)
Reviewer Review Type Date Requested Status
Nathan Teodosio Needs Fixing
Review via email: mp+436150@code.launchpad.net

Commit message

This is a patch that was sent to me by Intel to address the issue of webcams on non intel platforms and the use of the flag --video-capture-use-gpu-memory-buffer

It dynamically checks for nv12 support before using it.

Patch M107: https://chromium-review.googlesource.com/c/chromium/src/+/4179735
Patch main: https://chromium-review.googlesource.com/c/chromium/src/+/4167408

Description of the change

Addresses nv12 and non-intel platforms.

To post a comment you must log in.
Revision history for this message
Nathan Teodosio (nteodosio) :
review: Needs Fixing
Revision history for this message
Nathan Teodosio (nteodosio) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/build/args.gn b/build/args.gn
index 06beeef..ae91a41 100644
--- a/build/args.gn
+++ b/build/args.gn
@@ -34,6 +34,7 @@ target_os = "linux"
34current_os = "linux"34current_os = "linux"
35proprietary_codecs = true35proprietary_codecs = true
36ffmpeg_branding = "Chrome"36ffmpeg_branding = "Chrome"
37use_system_minigbm = true37use_system_minigbm = false
38use_intel_minigbm = false38use_intel_minigbm = true
39use_amdgpu_minigbm = true
39pkg_config = "/snap/gnome-3-38-2004/current/usr/bin/pkg-config"40pkg_config = "/snap/gnome-3-38-2004/current/usr/bin/pkg-config"
diff --git a/build/chromium-patches/af887ba.diff b/build/chromium-patches/af887ba.diff
40new file mode 10064441new file mode 100644
index 0000000..8c74ace
--- /dev/null
+++ b/build/chromium-patches/af887ba.diff
@@ -0,0 +1,206 @@
1From af887ba502876aa590d1890b543ccebfa3db8566 Mon Sep 17 00:00:00 2001
2From: Yaowei Zhou <yaowei.zhou@intel.com>
3Date: Thu, 19 Jan 2023 16:30:25 +0800
4Subject: [PATCH] Dynamic check NV12 format when enable the video capture use gpu memory ubffers
5
6Bug: N/A
7Change-Id: I8ba75b3981ebb890662d2a3b3981c0578d0f6ec7
8---
9
10diff --git a/content/browser/gpu/gpu_memory_buffer_manager_singleton.cc b/content/browser/gpu/gpu_memory_buffer_manager_singleton.cc
11index 1899912..5a6a992 100644
12--- a/content/browser/gpu/gpu_memory_buffer_manager_singleton.cc
13+++ b/content/browser/gpu/gpu_memory_buffer_manager_singleton.cc
14@@ -22,6 +22,10 @@
15 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
16 #endif
17
18+#if BUILDFLAG(IS_LINUX)
19+#include "media/capture/capture_switches.h"
20+#endif
21+
22 namespace content {
23 namespace {
24
25@@ -53,6 +57,23 @@
26 #endif
27 }
28
29+#if BUILDFLAG(IS_LINUX)
30+// Dynamic check NV12 format support as supported format inconsistent in
31+// system and chromium miniGBM
32+void DynamicUpdateVideoCaptureUseGpuMemoryBuffer(bool support_nv12) {
33+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
34+ switches::kDisableVideoCaptureUseGpuMemoryBuffer) ||
35+ !base::CommandLine::ForCurrentProcess()->HasSwitch(
36+ switches::kVideoCaptureUseGpuMemoryBuffer)) {
37+ return;
38+ }
39+
40+ if (!support_nv12) {
41+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
42+ switches::kDisableVideoCaptureUseGpuMemoryBuffer);
43+ }
44+}
45+#endif // BUILDFLAG(IS_LINUX)
46 } // namespace
47
48 GpuMemoryBufferManagerSingleton::GpuMemoryBufferManagerSingleton(int client_id)
49@@ -80,6 +101,12 @@
50 }
51
52 void GpuMemoryBufferManagerSingleton::OnGpuExtraInfoUpdate() {
53+#if BUILDFLAG(IS_LINUX) && \
54+ (BUILDFLAG(OZONE_PLATFORM_X11) || BUILDFLAG(OZONE_PLATFORM_WAYLAND))
55+ DynamicUpdateVideoCaptureUseGpuMemoryBuffer(
56+ gpu_data_manager_impl_->GetGpuExtraInfo().gpu_memory_buffer_support_NV12);
57+#endif
58+
59 #if defined(USE_OZONE_PLATFORM_X11)
60 // X11 fetches buffer formats on gpu and passes them via gpu extra info.
61 if (!ShouldSetBufferFormatsFromGpuExtraInfo())
62diff --git a/ui/gfx/gpu_extra_info.h b/ui/gfx/gpu_extra_info.h
63index e8fa594..d1edbfea 100644
64--- a/ui/gfx/gpu_extra_info.h
65+++ b/ui/gfx/gpu_extra_info.h
66@@ -65,6 +65,10 @@
67 #if defined(USE_OZONE_PLATFORM_X11)
68 std::vector<gfx::BufferUsageAndFormat> gpu_memory_buffer_support_x11;
69 #endif
70+#if BUILDFLAG(IS_LINUX) && \
71+ (BUILDFLAG(OZONE_PLATFORM_X11) || BUILDFLAG(OZONE_PLATFORM_WAYLAND))
72+ bool gpu_memory_buffer_support_NV12;
73+#endif
74 };
75
76 } // namespace gfx
77diff --git a/ui/gfx/mojom/BUILD.gn b/ui/gfx/mojom/BUILD.gn
78index 37b984d..4921b84 100644
79--- a/ui/gfx/mojom/BUILD.gn
80+++ b/ui/gfx/mojom/BUILD.gn
81@@ -50,7 +50,9 @@
82 if (ozone_platform_x11) {
83 enabled_features += [ "enable_x11_params" ]
84 }
85-
86+ if (is_linux && (ozone_platform_x11 || ozone_platform_wayland)) {
87+ enabled_features += [ "enable_nv12_params" ]
88+ }
89 shared_cpp_typemaps = [
90 {
91 types = [
92diff --git a/ui/gfx/mojom/gpu_extra_info.mojom b/ui/gfx/mojom/gpu_extra_info.mojom
93index 3de1c579..6d724c2b 100644
94--- a/ui/gfx/mojom/gpu_extra_info.mojom
95+++ b/ui/gfx/mojom/gpu_extra_info.mojom
96@@ -24,4 +24,7 @@
97
98 [EnableIf=enable_x11_params]
99 array<gfx.mojom.BufferUsageAndFormat> gpu_memory_buffer_support_x11;
100+
101+ [EnableIf=enable_nv12_params]
102+ bool gpu_memory_buffer_support_NV12;
103 };
104diff --git a/ui/gfx/mojom/gpu_extra_info_mojom_traits.cc b/ui/gfx/mojom/gpu_extra_info_mojom_traits.cc
105index 15c7340..9add661 100644
106--- a/ui/gfx/mojom/gpu_extra_info_mojom_traits.cc
107+++ b/ui/gfx/mojom/gpu_extra_info_mojom_traits.cc
108@@ -28,6 +28,10 @@
109 if (!data.ReadGpuMemoryBufferSupportX11(&out->gpu_memory_buffer_support_x11))
110 return false;
111 #endif
112+#if BUILDFLAG(IS_LINUX) && \
113+ (BUILDFLAG(OZONE_PLATFORM_X11) || BUILDFLAG(OZONE_PLATFORM_WAYLAND))
114+ out->gpu_memory_buffer_support_NV12 = data.gpu_memory_buffer_support_NV12();
115+#endif
116 return true;
117 }
118
119diff --git a/ui/gfx/mojom/gpu_extra_info_mojom_traits.h b/ui/gfx/mojom/gpu_extra_info_mojom_traits.h
120index 12b616f..7c908bf 100644
121--- a/ui/gfx/mojom/gpu_extra_info_mojom_traits.h
122+++ b/ui/gfx/mojom/gpu_extra_info_mojom_traits.h
123@@ -68,6 +68,12 @@
124 return input.gpu_memory_buffer_support_x11;
125 }
126 #endif
127+#if BUILDFLAG(IS_LINUX) && \
128+ (BUILDFLAG(OZONE_PLATFORM_X11) || BUILDFLAG(OZONE_PLATFORM_WAYLAND))
129+ static bool gpu_memory_buffer_support_NV12(const gfx::GpuExtraInfo& input) {
130+ return input.gpu_memory_buffer_support_NV12;
131+ }
132+#endif
133 };
134
135 } // namespace mojo
136diff --git a/ui/ozone/platform/wayland/gpu/wayland_gl_egl_utility.cc b/ui/ozone/platform/wayland/gpu/wayland_gl_egl_utility.cc
137index b3e92d8..ee165fe 100644
138--- a/ui/ozone/platform/wayland/gpu/wayland_gl_egl_utility.cc
139+++ b/ui/ozone/platform/wayland/gpu/wayland_gl_egl_utility.cc
140@@ -5,6 +5,11 @@
141 #include "ui/ozone/platform/wayland/gpu/wayland_gl_egl_utility.h"
142
143 #include "base/containers/contains.h"
144+#if BUILDFLAG(IS_LINUX)
145+#include "ui/gfx/native_pixmap.h"
146+#include "ui/ozone/public/ozone_platform.h"
147+#include "ui/ozone/public/surface_factory_ozone.h"
148+#endif // BUILDFLAG(IS_LINUX)
149
150 // From ANGLE's egl/eglext.h. Follows the same approach as in
151 // ui/gl/gl_surface_egl.cc
152@@ -74,7 +79,23 @@
153
154 void WaylandGLEGLUtility::CollectGpuExtraInfo(
155 bool enable_native_gpu_memory_buffers,
156- gfx::GpuExtraInfo& gpu_extra_info) const {}
157+ gfx::GpuExtraInfo& gpu_extra_info) const {
158+#if BUILDFLAG(IS_LINUX)
159+ if (!enable_native_gpu_memory_buffers) {
160+ gpu_extra_info.gpu_memory_buffer_support_NV12 = false;
161+ return;
162+ }
163+ scoped_refptr<gfx::NativePixmap> pixmap;
164+ pixmap = ui::OzonePlatform::GetInstance()
165+ ->GetSurfaceFactoryOzone()
166+ ->CreateNativePixmap(gfx::kNullAcceleratedWidget, nullptr,
167+ gfx::Size(2, 2),
168+ gfx::BufferFormat::YUV_420_BIPLANAR,
169+ gfx::BufferUsage::GPU_READ_CPU_READ_WRITE);
170+
171+ gpu_extra_info.gpu_memory_buffer_support_NV12 = !!pixmap;
172+#endif // BUILDFLAG(IS_LINUX)
173+}
174
175 bool WaylandGLEGLUtility::X11DoesVisualHaveAlphaForTest() const {
176 return false;
177diff --git a/ui/ozone/platform/x11/gl_egl_utility_x11.cc b/ui/ozone/platform/x11/gl_egl_utility_x11.cc
178index 58c7fe6..0eb5608 100644
179--- a/ui/ozone/platform/x11/gl_egl_utility_x11.cc
180+++ b/ui/ozone/platform/x11/gl_egl_utility_x11.cc
181@@ -12,6 +12,10 @@
182 #include "ui/gl/gl_implementation.h"
183 #include "ui/gl/gl_utils.h"
184
185+#if BUILDFLAG(IS_LINUX)
186+#include "base/ranges/algorithm.h"
187+#endif
188+
189 namespace ui {
190
191 GLEGLUtilityX11::GLEGLUtilityX11() = default;
192@@ -45,6 +49,14 @@
193 // ANGLE does not yet support EGL_EXT_image_dma_buf_import[_modifiers].
194 gpu_extra_info.gpu_memory_buffer_support_x11.clear();
195 }
196+#if BUILDFLAG(IS_LINUX)
197+ gpu_extra_info.gpu_memory_buffer_support_NV12 = base::ranges::any_of(
198+ ui::GpuMemoryBufferSupportX11::GetInstance()->supported_configs(),
199+ [](gfx::BufferUsageAndFormat other) {
200+ return other.format == gfx::BufferFormat::YUV_420_BIPLANAR &&
201+ other.usage == gfx::BufferUsage::GPU_READ_CPU_READ_WRITE;
202+ });
203+#endif
204 }
205
206 bool GLEGLUtilityX11::X11DoesVisualHaveAlphaForTest() const {
diff --git a/build/chromium-patches/series b/build/chromium-patches/series
index 373ea12..5517f2b 100644
--- a/build/chromium-patches/series
+++ b/build/chromium-patches/series
@@ -31,3 +31,4 @@ dont-collect-motherboard-metrics.patch
314ed5da1.diff 314ed5da1.diff
3240002f9.diff3240002f9.diff
33linker-oom-armhf.patch33linker-oom-armhf.patch
34af887ba.diff
diff --git a/launcher/chromium.launcher b/launcher/chromium.launcher
index e366d6a..4c79460 100755
--- a/launcher/chromium.launcher
+++ b/launcher/chromium.launcher
@@ -113,9 +113,8 @@ fi
113# Add necessary flags for VAAPI video en/decoding113# Add necessary flags for VAAPI video en/decoding
114CHROMIUM_VAAPI_FLAGS='--enable-features=VaapiVideoDecoder,VaapiVideoEncoder --disable-features=UseChromeOSDirectVideoDecoder --use-gl=egl --video-capture-use-external-dma-buffer'114CHROMIUM_VAAPI_FLAGS='--enable-features=VaapiVideoDecoder,VaapiVideoEncoder --disable-features=UseChromeOSDirectVideoDecoder --use-gl=egl --video-capture-use-external-dma-buffer'
115115
116# The following flag should only be used on Intel GPUs, and when the binary was built with intel minigbm.116# With the patch for dynamic NV12 support detection, this should now be safe on non-Intel platforms.
117# Which means we have to leave it out for now.117CHROMIUM_VAAPI_FLAGS="--video-capture-use-gpu-memory-buffer $CHROMIUM_VAAPI_FLAGS"
118#CHROMIUM_VAAPI_FLAGS="--video-capture-use-gpu-memory-buffer $CHROMIUM_VAAPI_FLAGS"
119118
120if [ -n "$WAYLAND_DISPLAY" ]; then119if [ -n "$WAYLAND_DISPLAY" ]; then
121 CHROMIUM_VAAPI_FLAGS="--ozone-platform=wayland $CHROMIUM_VAAPI_FLAGS"120 CHROMIUM_VAAPI_FLAGS="--ozone-platform=wayland $CHROMIUM_VAAPI_FLAGS"

Subscribers

People subscribed via source and target branches

to status/vote changes: