diff options
Diffstat (limited to 'chromium/gpu/ipc/service/gpu_init.cc')
-rw-r--r-- | chromium/gpu/ipc/service/gpu_init.cc | 133 |
1 files changed, 60 insertions, 73 deletions
diff --git a/chromium/gpu/ipc/service/gpu_init.cc b/chromium/gpu/ipc/service/gpu_init.cc index 63a5d345d2a..4ba6ee242e5 100644 --- a/chromium/gpu/ipc/service/gpu_init.cc +++ b/chromium/gpu/ipc/service/gpu_init.cc @@ -4,6 +4,8 @@ #include "gpu/ipc/service/gpu_init.h" +#include <string> + #include "base/command_line.h" #include "base/metrics/histogram_macros.h" #include "base/strings/string_number_conversions.h" @@ -36,15 +38,20 @@ #include "ui/gl/gl_surface_egl.h" #endif +#if BUILDFLAG(ENABLE_VULKAN) +#include "gpu/vulkan/init/vulkan_factory.h" +#include "gpu/vulkan/vulkan_implementation.h" +#endif + namespace gpu { namespace { -#if !defined(OS_MACOSX) -bool CollectGraphicsInfo(GPUInfo* gpu_info) { +bool CollectGraphicsInfo(GPUInfo* gpu_info, + const GpuPreferences& gpu_preferences) { DCHECK(gpu_info); TRACE_EVENT0("gpu,startup", "Collect Graphics Info"); base::TimeTicks before_collect_context_graphics_info = base::TimeTicks::Now(); - bool success = CollectContextGraphicsInfo(gpu_info); + bool success = CollectContextGraphicsInfo(gpu_info, gpu_preferences); if (!success) LOG(ERROR) << "gpu::CollectGraphicsInfo failed."; @@ -52,11 +59,10 @@ bool CollectGraphicsInfo(GPUInfo* gpu_info) { if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2 && gl::GLSurfaceEGL::IsDirectCompositionSupported()) { gpu_info->direct_composition = true; - } - - if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2 && - DirectCompositionSurfaceWin::AreOverlaysSupported()) { - gpu_info->supports_overlays = true; + gpu_info->supports_overlays = + DirectCompositionSurfaceWin::AreOverlaysSupported(); + gpu_info->overlay_capabilities = + DirectCompositionSurfaceWin::GetOverlayCapabilities(); } #endif // defined(OS_WIN) @@ -67,7 +73,6 @@ bool CollectGraphicsInfo(GPUInfo* gpu_info) { } return success; } -#endif // defined(OS_MACOSX) #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(IS_CHROMECAST) bool CanAccessNvidiaDeviceFile() { @@ -107,17 +112,14 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, #if defined(OS_LINUX) && !defined(OS_CHROMEOS) if (gpu_info_.gpu.vendor_id == 0x10de && // NVIDIA - gpu_info_.driver_vendor == "NVIDIA" && !CanAccessNvidiaDeviceFile()) + gpu_info_.gpu.driver_vendor == "NVIDIA" && !CanAccessNvidiaDeviceFile()) return false; #endif if (!PopGpuFeatureInfoCache(&gpu_feature_info_)) { // Compute blacklist and driver bug workaround decisions based on basic GPU // info. gpu_feature_info_ = gpu::ComputeGpuFeatureInfo( - gpu_info_, gpu_preferences.ignore_gpu_blacklist, - gpu_preferences.disable_gpu_driver_bug_workarounds, - gpu_preferences.log_gpu_control_list_decisions, command_line, - &needs_more_info); + gpu_info_, gpu_preferences_, command_line, &needs_more_info); } #endif // !OS_ANDROID && !IS_CHROMECAST gpu_info_.in_process_gpu = false; @@ -138,7 +140,7 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, use_swiftshader = true; } - bool enable_watchdog = !gpu_preferences.disable_gpu_watchdog && + bool enable_watchdog = !gpu_preferences_.disable_gpu_watchdog && !command_line->HasSwitch(switches::kHeadless); // Disable the watchdog in debug builds because they tend to only be run by @@ -158,7 +160,8 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, // Start the GPU watchdog only after anything that is expected to be time // consuming has completed, otherwise the process is liable to be aborted. if (enable_watchdog && !delayed_watchdog_enable) { - watchdog_thread_ = gpu::GpuWatchdogThread::Create(); + watchdog_thread_ = gpu::GpuWatchdogThread::Create( + gpu_preferences_.watchdog_starts_backgrounded); #if defined(OS_WIN) // This is a workaround for an occasional deadlock between watchdog and // current thread. Watchdog hangs at thread initialization in @@ -174,6 +177,20 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, #endif // OS_WIN } +#if BUILDFLAG(ENABLE_VULKAN) + if (gpu_preferences_.enable_vulkan) { + vulkan_implementation_ = gpu::CreateVulkanImplementation(); + if (!vulkan_implementation_ || + !vulkan_implementation_->InitializeVulkanInstance()) { + DLOG(WARNING) << "Failed to create and initialize Vulkan implementation."; + vulkan_implementation_ = nullptr; + } + gpu_preferences_.enable_vulkan = !!vulkan_implementation_; + } +#else + gpu_preferences_.enable_vulkan = false; +#endif + sandbox_helper_->PreSandboxStartup(); bool attempted_startsandbox = false; @@ -181,7 +198,7 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, // On Chrome OS ARM Mali, GPU driver userspace creates threads when // initializing a GL context, so start the sandbox early. // TODO(zmo): Need to collect OS version before this. - if (gpu_preferences.gpu_sandbox_start_early) { + if (gpu_preferences_.gpu_sandbox_start_early) { gpu_info_.sandboxed = sandbox_helper_->EnsureSandboxInitialized( watchdog_thread_.get(), &gpu_info_, gpu_preferences_); attempted_startsandbox = true; @@ -200,9 +217,9 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, #endif if (!use_swiftshader) { - use_swiftshader = ShouldEnableSwiftShader( + use_swiftshader = EnableSwiftShaderIfNeeded( command_line, gpu_feature_info_, - gpu_preferences.disable_software_rasterizer, needs_more_info); + gpu_preferences_.disable_software_rasterizer, needs_more_info); } if (gl_initialized && use_swiftshader && gl::GetGLImplementation() != gl::kGLImplementationSwiftShaderGL) { @@ -218,23 +235,15 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, bool gl_disabled = gl::GetGLImplementation() == gl::kGLImplementationDisabled; // We need to collect GL strings (VENDOR, RENDERER) for blacklisting purposes. - // However, on Mac we don't actually use them. As documented in - // crbug.com/222934, due to some driver issues, glGetString could take - // multiple seconds to finish, which in turn cause the GPU process to crash. - // By skipping the following code on Mac, we don't really lose anything, - // because the basic GPU information is passed down from the host process. -#if !defined(OS_MACOSX) if (!gl_disabled && !use_swiftshader) { - if (!CollectGraphicsInfo(&gpu_info_)) + if (!CollectGraphicsInfo(&gpu_info_, gpu_preferences_)) return false; gpu::SetKeysForCrashLogging(gpu_info_); - gpu_feature_info_ = gpu::ComputeGpuFeatureInfo( - gpu_info_, gpu_preferences.ignore_gpu_blacklist, - gpu_preferences.disable_gpu_driver_bug_workarounds, - gpu_preferences.log_gpu_control_list_decisions, command_line, nullptr); - use_swiftshader = ShouldEnableSwiftShader( + gpu_feature_info_ = gpu::ComputeGpuFeatureInfo(gpu_info_, gpu_preferences_, + command_line, nullptr); + use_swiftshader = EnableSwiftShaderIfNeeded( command_line, gpu_feature_info_, - gpu_preferences.disable_software_rasterizer, false); + gpu_preferences_.disable_software_rasterizer, false); if (use_swiftshader) { gl::init::ShutdownGL(true); if (!gl::init::InitializeGLNoExtensionsOneOff()) { @@ -244,11 +253,8 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, } } } -#endif if (use_swiftshader) { AdjustInfoToSwiftShader(); - } else if (gl_disabled) { - AdjustInfoToNoGpu(); } if (kGpuFeatureStatusEnabled != @@ -290,7 +296,8 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, watchdog_thread_->Stop(); watchdog_thread_ = nullptr; } else if (enable_watchdog && delayed_watchdog_enable) { - watchdog_thread_ = gpu::GpuWatchdogThread::Create(); + watchdog_thread_ = gpu::GpuWatchdogThread::Create( + gpu_preferences_.watchdog_starts_backgrounded); } if (!gpu_info_.sandboxed && !attempted_startsandbox) { @@ -316,14 +323,12 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line, const GpuPreferences& gpu_preferences) { gpu_preferences_ = gpu_preferences; init_successful_ = true; - DCHECK(!ShouldEnableSwiftShader(command_line, gpu_feature_info_, - gpu_preferences.disable_software_rasterizer, - false)); - - InitializeGLThreadSafe(command_line, gpu_preferences.ignore_gpu_blacklist, - gpu_preferences.disable_gpu_driver_bug_workarounds, - gpu_preferences.log_gpu_control_list_decisions, - &gpu_info_, &gpu_feature_info_); + DCHECK(!EnableSwiftShaderIfNeeded( + command_line, gpu_feature_info_, + gpu_preferences_.disable_software_rasterizer, false)); + + InitializeGLThreadSafe(command_line, gpu_preferences_, &gpu_info_, + &gpu_feature_info_); } #else void GpuInit::InitializeInProcess(base::CommandLine* command_line, @@ -334,7 +339,7 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line, ui::OzonePlatform::InitParams params; params.single_process = true; #if defined(OS_CHROMEOS) - params.using_mojo = base::FeatureList::IsEnabled(features::kMash) || + params.using_mojo = !features::IsAshInBrowserProcess() || command_line->HasSwitch(switches::kEnableDrmMojo); #else params.using_mojo = command_line->HasSwitch(switches::kEnableDrmMojo); @@ -348,11 +353,8 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line, CollectBasicGraphicsInfo(command_line, &gpu_info_); } if (!PopGpuFeatureInfoCache(&gpu_feature_info_)) { - gpu_feature_info_ = ComputeGpuFeatureInfo( - gpu_info_, gpu_preferences.ignore_gpu_blacklist, - gpu_preferences.disable_gpu_driver_bug_workarounds, - gpu_preferences.log_gpu_control_list_decisions, command_line, - &needs_more_info); + gpu_feature_info_ = ComputeGpuFeatureInfo(gpu_info_, gpu_preferences_, + command_line, &needs_more_info); } if (SwitchableGPUsSupported(gpu_info_, *command_line)) { InitializeSwitchableGPUs( @@ -360,9 +362,9 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line, } #endif // !IS_CHROMECAST - bool use_swiftshader = ShouldEnableSwiftShader( + bool use_swiftshader = EnableSwiftShaderIfNeeded( command_line, gpu_feature_info_, - gpu_preferences.disable_software_rasterizer, needs_more_info); + gpu_preferences_.disable_software_rasterizer, needs_more_info); if (!gl::init::InitializeGLNoExtensionsOneOff()) { VLOG(1) << "gl::init::InitializeGLNoExtensionsOneOff failed"; return; @@ -370,14 +372,12 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line, bool gl_disabled = gl::GetGLImplementation() == gl::kGLImplementationDisabled; if (!gl_disabled && !use_swiftshader) { - CollectContextGraphicsInfo(&gpu_info_); - gpu_feature_info_ = ComputeGpuFeatureInfo( - gpu_info_, gpu_preferences.ignore_gpu_blacklist, - gpu_preferences.disable_gpu_driver_bug_workarounds, - gpu_preferences.log_gpu_control_list_decisions, command_line, nullptr); - use_swiftshader = ShouldEnableSwiftShader( + CollectContextGraphicsInfo(&gpu_info_, gpu_preferences_); + gpu_feature_info_ = ComputeGpuFeatureInfo(gpu_info_, gpu_preferences_, + command_line, nullptr); + use_swiftshader = EnableSwiftShaderIfNeeded( command_line, gpu_feature_info_, - gpu_preferences.disable_software_rasterizer, false); + gpu_preferences_.disable_software_rasterizer, false); if (use_swiftshader) { gl::init::ShutdownGL(true); if (!gl::init::InitializeGLNoExtensionsOneOff()) { @@ -389,8 +389,6 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line, } if (use_swiftshader) { AdjustInfoToSwiftShader(); - } else if (gl_disabled) { - AdjustInfoToNoGpu(); } if (!gl_disabled) { @@ -409,18 +407,7 @@ void GpuInit::AdjustInfoToSwiftShader() { gpu_info_for_hardware_gpu_ = gpu_info_; gpu_feature_info_for_hardware_gpu_ = gpu_feature_info_; gpu_feature_info_ = ComputeGpuFeatureInfoForSwiftShader(); - gpu_info_.gl_vendor = "Google Inc."; - gpu_info_.gl_renderer = "Google SwiftShader"; - gpu_info_.gl_version = "OpenGL ES 2.0 SwiftShader"; -} - -void GpuInit::AdjustInfoToNoGpu() { - gpu_info_for_hardware_gpu_ = gpu_info_; - gpu_feature_info_for_hardware_gpu_ = gpu_feature_info_; - gpu_feature_info_ = ComputeGpuFeatureInfoWithNoGpu(); - gpu_info_.gl_vendor = "Disabled"; - gpu_info_.gl_renderer = "Disabled"; - gpu_info_.gl_version = "Disabled"; + CollectContextGraphicsInfo(&gpu_info_, gpu_preferences_); } } // namespace gpu |