Commit 3fea38ba authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

Fix --enable-features=Vulkan broken.

With this change, --gr-context-type=Vulkan or --enable-features=Vulkan
will enable vulkan compositing. If the --use-vulkan=impl_name is used,
the specified vulkan implementation will be used otherwise the native
vulkan implementation will be used by default.

Bug: 1009029
Change-Id: I7730f48ab000b7edf6db892ac63bc585383d4fb3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1878529
Commit-Queue: Vasiliy Telezhnikov <vasilyt@chromium.org>
Reviewed-by: default avatarVasiliy Telezhnikov <vasilyt@chromium.org>
Auto-Submit: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709449}
parent 46d13c69
...@@ -156,8 +156,6 @@ GpuPreferences ParseGpuPreferences(const base::CommandLine* command_line) { ...@@ -156,8 +156,6 @@ GpuPreferences ParseGpuPreferences(const base::CommandLine* command_line) {
gpu_preferences.enable_webgpu = gpu_preferences.enable_webgpu =
command_line->HasSwitch(switches::kEnableUnsafeWebGPU); command_line->HasSwitch(switches::kEnableUnsafeWebGPU);
if (command_line->HasSwitch(switches::kUseVulkan)) { if (command_line->HasSwitch(switches::kUseVulkan)) {
DLOG_IF(ERROR, base::FeatureList::IsEnabled(features::kVulkan))
<< "--enabled-features=Vulkan is overrided by --use-vulkan.";
auto value = command_line->GetSwitchValueASCII(switches::kUseVulkan); auto value = command_line->GetSwitchValueASCII(switches::kUseVulkan);
if (value.empty() || value == switches::kVulkanImplementationNameNative) { if (value.empty() || value == switches::kVulkanImplementationNameNative) {
gpu_preferences.use_vulkan = VulkanImplementationName::kForcedNative; gpu_preferences.use_vulkan = VulkanImplementationName::kForcedNative;
...@@ -166,10 +164,6 @@ GpuPreferences ParseGpuPreferences(const base::CommandLine* command_line) { ...@@ -166,10 +164,6 @@ GpuPreferences ParseGpuPreferences(const base::CommandLine* command_line) {
} else { } else {
gpu_preferences.use_vulkan = VulkanImplementationName::kNone; gpu_preferences.use_vulkan = VulkanImplementationName::kNone;
} }
} else {
gpu_preferences.use_vulkan = base::FeatureList::IsEnabled(features::kVulkan)
? gpu::VulkanImplementationName::kNative
: gpu::VulkanImplementationName::kNone;
} }
gpu_preferences.disable_vulkan_surface = gpu_preferences.disable_vulkan_surface =
command_line->HasSwitch(switches::kDisableVulkanSurface); command_line->HasSwitch(switches::kDisableVulkanSurface);
...@@ -178,8 +172,6 @@ GpuPreferences ParseGpuPreferences(const base::CommandLine* command_line) { ...@@ -178,8 +172,6 @@ GpuPreferences ParseGpuPreferences(const base::CommandLine* command_line) {
if (value == switches::kGrContextTypeGL) { if (value == switches::kGrContextTypeGL) {
gpu_preferences.gr_context_type = GrContextType::kGL; gpu_preferences.gr_context_type = GrContextType::kGL;
} else if (value == switches::kGrContextTypeVulkan) { } else if (value == switches::kGrContextTypeVulkan) {
DCHECK(gpu_preferences.use_vulkan != VulkanImplementationName::kNone)
<< "GrContextType is Vulkan, but Vulkan is not enabled.";
gpu_preferences.gr_context_type = GrContextType::kVulkan; gpu_preferences.gr_context_type = GrContextType::kVulkan;
} else if (value == switches::kGrContextTypeMetal) { } else if (value == switches::kGrContextTypeMetal) {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
...@@ -198,9 +190,19 @@ GpuPreferences ParseGpuPreferences(const base::CommandLine* command_line) { ...@@ -198,9 +190,19 @@ GpuPreferences ParseGpuPreferences(const base::CommandLine* command_line) {
GrContextType::kMetal : GrContextType::kMetal :
GrContextType::kGL; GrContextType::kGL;
#else #else
gpu_preferences.gr_context_type = GrContextType::kGL; if (base::FeatureList::IsEnabled(features::kVulkan)) {
gpu_preferences.gr_context_type = GrContextType::kVulkan;
} else {
gpu_preferences.gr_context_type = GrContextType::kGL;
}
#endif #endif
} }
if (gpu_preferences.gr_context_type == GrContextType::kVulkan &&
gpu_preferences.use_vulkan == gpu::VulkanImplementationName::kNone) {
// If gpu_preferences.use_vulkan is not set from --use-vulkan, the native
// vulkan implementation will be used by default.
gpu_preferences.use_vulkan = gpu::VulkanImplementationName::kNative;
}
return gpu_preferences; return gpu_preferences;
} }
......
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