Commit 912769f6 authored by Klaus Weidner's avatar Klaus Weidner Committed by Commit Bot

Don't use GpuFence or SurfaceControl on SwiftShader

The EGL_ANDROID_native_fence_sync isn't reported as present to
applications, so Chrome uses heuristics to infer if it's present.
It's not usable in emulation or for SwiftShader.

SurfaceControl assumes that GpuFence support is available, so don't
use it if native fence sync is unavailable since that's used to
implement GpuFence on Android. This check already existed but
duplicated logic from gl_surface_egl, replace this with a feature
check.

Bug: 1086736
Change-Id: Ie2db42f605cb3eb90726b36b1bb264b4190bef80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2217036Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Klaus Weidner <klausw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772964}
parent c1d76e1f
......@@ -47,6 +47,7 @@
#include "base/no_destructor.h"
#include "base/synchronization/lock.h"
#include "ui/gl/android/android_surface_control_compat.h"
#include "ui/gl/gl_surface_egl.h"
#include "ui/gl/init/gl_factory.h"
#endif // OS_ANDROID
......@@ -112,6 +113,13 @@ GpuFeatureStatus GetAndroidSurfaceControlFeatureStatus(
if (!gpu_preferences.enable_android_surface_control)
return kGpuFeatureStatusDisabled;
// SurfaceControl as used by Chrome requires using GpuFence for
// synchronization, this is based on Android native fence sync
// support. If that is unavailable, i.e. on emulator or SwiftShader,
// don't claim SurfaceControl support.
if (!gl::GLSurfaceEGL::IsAndroidNativeFenceSyncSupported())
return kGpuFeatureStatusDisabled;
DCHECK(gl::SurfaceControl::IsSupported());
return kGpuFeatureStatusEnabled;
#endif
......
......@@ -312,11 +312,6 @@ bool SurfaceControl::IsSupported() {
if (!base::android::BuildInfo::GetInstance()->is_at_least_q())
return false;
// GLFence cannot be created successfully on emulator, and it is needed by
// Android surface control.
if (base::SysInfo::GetAndroidHardwareEGL() == "emulation")
return false;
CHECK(SurfaceControlMethods::Get().supported);
return true;
}
......
......@@ -30,6 +30,10 @@ namespace gl {
class GL_EXPORT SurfaceControl {
public:
// Check if the platform is capable of supporting the low-level SurfaceControl
// API. See also gpu/config/gpu_util's GetAndroidSurfaceControlFeatureStatus
// which checks other prerequisites such as Gpufence support before declaring
// support for the high-level SurfaceControl feature in Chrome.
static bool IsSupported();
// Returns true if overlays with |color_space| are supported by the platform.
......
......@@ -941,7 +941,9 @@ bool GLSurfaceEGL::InitializeOneOffCommon() {
// a useless wrapper function. See crbug.com/775707 for details. In short, if
// the symbol is present and we're on Android N or newer and we are not on
// Android emulator, assume that it's usable even if the extension wasn't
// reported.
// reported. TODO(https://crbug.com/1086781): Once this is fixed at the
// Android level, update the heuristic to trust the reported extension from
// that version onward.
g_egl_android_native_fence_sync_supported =
HasEGLExtension("EGL_ANDROID_native_fence_sync");
#if defined(OS_ANDROID)
......@@ -949,6 +951,7 @@ bool GLSurfaceEGL::InitializeOneOffCommon() {
base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_NOUGAT &&
g_driver_egl.fn.eglDupNativeFenceFDANDROIDFn &&
base::SysInfo::GetAndroidHardwareEGL() != "swiftshader" &&
base::SysInfo::GetAndroidHardwareEGL() != "emulation") {
g_egl_android_native_fence_sync_supported = true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment