Commit f48f920d authored by Jonathan Backer's avatar Jonathan Backer Committed by Chromium LUCI CQ

Default SkiaRenderer GL and Vulkan for Android 10+

IsUsingVulkan is checked by IsUsingSkiaRenderer. So this CL enables
both for Android 10+ devices.

Some code was added to:

  - disable Vulkan for Android < 10 --- we use some Android 10 specific
  APIs and it has significant market share (~40% by frame count
  yesterday on UMA)

  - disable Vulkan on QCOM GPU by default --- performance is not yet
  as good as GL there

  - add an enable_by_device_name finch param so that we can bypass the
  Android Vulkan blocklist and test new GPUs on canary/dev/beta

Bug: 1012393
Change-Id: I1211743519c8cbe18025adea1696ab7d52a0b949
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2623951
Auto-Submit: Jonathan Backer <backer@chromium.org>
Commit-Queue: Jonathan Backer <backer@chromium.org>
Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843629}
parent 2a7240dd
......@@ -10,8 +10,8 @@
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "build/chromeos_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/gpu_switches.h"
......@@ -217,16 +217,18 @@ VulkanImplementationName ParseVulkanImplementationName(
}
}
// GrContext is not going to use Vulkan.
if (!base::FeatureList::IsEnabled(features::kVulkan))
return VulkanImplementationName::kNone;
if (features::IsUsingVulkan()) {
// If the vulkan feature is enabled from command line, we will force to use
// vulkan even if it is blocklisted.
return base::FeatureList::GetInstance()->IsFeatureOverriddenFromCommandLine(
features::kVulkan.name, base::FeatureList::OVERRIDE_ENABLE_FEATURE)
features::kVulkan.name,
base::FeatureList::OVERRIDE_ENABLE_FEATURE)
? VulkanImplementationName::kForcedNative
: VulkanImplementationName::kNative;
}
// GrContext is not going to use Vulkan.
return VulkanImplementationName::kNone;
#endif
}
......
......@@ -148,7 +148,14 @@ const base::Feature kVaapiWebPImageDecodeAcceleration{
// native implementation if --use-vulkan flag is not used. Otherwise
// --use-vulkan will be followed.
// Note Android WebView uses kWebViewVulkan instead of this.
const base::Feature kVulkan{"Vulkan", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kVulkan {
"Vulkan",
#if defined(OS_ANDROID)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
#endif
};
// Enable SkiaRenderer Dawn graphics backend. On Windows this will use D3D12,
// and on Linux this will use Vulkan.
......@@ -164,13 +171,31 @@ const base::Feature kEnableGrShaderCacheForVulkan{
"EnableGrShaderCacheForVulkan", base::FEATURE_ENABLED_BY_DEFAULT};
bool IsUsingVulkan() {
bool enable = base::FeatureList::IsEnabled(kVulkan);
#if defined(OS_ANDROID)
// Force on if Vulkan feature is enabled from command line.
base::FeatureList* feature_list = base::FeatureList::GetInstance();
if (feature_list &&
feature_list->IsFeatureOverriddenFromCommandLine(
features::kVulkan.name, base::FeatureList::OVERRIDE_ENABLE_FEATURE))
return true;
// No support for devices before Q -- exit before checking feature flags
// so that devices are not counted in finch trials.
if (base::android::BuildInfo::GetInstance()->sdk_int() <
base::android::SDK_VERSION_Q)
return false;
// WebView defaults disables Vulkan in AwMainDelegate::BasicStartupComplete.
bool enable = base::FeatureList::IsEnabled(kVulkan);
// Check WebView support.
enable = enable || (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kWebViewDrawFunctorUsesVulkan) &&
base::FeatureList::IsEnabled(kWebViewVulkan));
#endif
return enable;
#else
return base::FeatureList::IsEnabled(kVulkan);
#endif
}
#if defined(OS_ANDROID)
......
......@@ -847,8 +847,9 @@ bool GpuInit::InitializeVulkan() {
if (!use_swiftshader && !forced_native &&
!CheckVulkanCompabilities(
vulkan_implementation_->GetVulkanInstance()->vulkan_info(),
gpu_info_)) {
vulkan_implementation_->GetVulkanInstance()->vulkan_info(), gpu_info_,
base::GetFieldTrialParamValueByFeature(features::kVulkan,
"enable_by_device_name"))) {
vulkan_implementation_.reset();
return false;
}
......
......@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/pattern.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
......@@ -129,7 +130,8 @@ void ReportUMAPerSwapBuffers() {
}
bool CheckVulkanCompabilities(const VulkanInfo& vulkan_info,
const GPUInfo& gpu_info) {
const GPUInfo& gpu_info,
std::string enable_by_device_name) {
// Android uses AHB and SyncFD for interop. They are imported into GL with other
// API.
#if !defined(OS_ANDROID)
......@@ -160,6 +162,13 @@ bool CheckVulkanCompabilities(const VulkanInfo& vulkan_info,
const auto& device_info = vulkan_info.physical_devices.front();
auto enable_patterns = base::SplitString(
enable_by_device_name, "|", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
for (const auto& enable_pattern : enable_patterns) {
if (base::MatchPattern(device_info.properties.deviceName, enable_pattern))
return true;
}
constexpr uint32_t kVendorARM = 0x13b5;
if (device_info.properties.vendorID == kVendorARM) {
// https://crbug.com/1096222: Display problem with Huawei and Honor devices
......@@ -188,23 +197,11 @@ bool CheckVulkanCompabilities(const VulkanInfo& vulkan_info,
}
}
// https:://crbug.com/1165783: Performance is not yet as good as GL.
constexpr uint32_t kVendorQualcomm = 0x5143;
if (device_info.properties.vendorID == kVendorQualcomm) {
// Remove "Adreno (TM) " prefix.
base::StringPiece device_name(device_info.properties.deviceName);
if (!base::StartsWith(device_name, "Adreno (TM) ")) {
LOG(ERROR) << "Unexpected device_name " << device_name;
return false;
}
device_name.remove_prefix(12);
// Older Adreno GPUs are not performant with Vulkan.
std::vector<const char*> slow_gpus = {"4??", "50?", "51?"};
for (base::StringPiece slow_gpu : slow_gpus) {
if (base::MatchPattern(device_name, slow_gpu))
return false;
}
}
// https://crbug.com/1122650: Poor performance and untriaged crashes with
// Imagination GPUs.
......
......@@ -87,7 +87,8 @@ COMPONENT_EXPORT(VULKAN) void ReportUMAPerSwapBuffers();
COMPONENT_EXPORT(VULKAN)
bool CheckVulkanCompabilities(const VulkanInfo& vulkan_info,
const GPUInfo& gpu_info);
const GPUInfo& gpu_info,
std::string enable_by_device_name);
} // namespace gpu
......
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