Commit 26d74ed3 authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

Initialize vulkan in GpuIinit::InitializeInPorcess()

Bug: 1016258
Change-Id: I2e5327139ef2a381068f11d0caaaca741da48a75
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1895376Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712777}
parent d150cbe6
......@@ -359,41 +359,7 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line,
}
}
#if BUILDFLAG(ENABLE_VULKAN)
if (gpu_feature_info_.status_values[gpu::GPU_FEATURE_TYPE_VULKAN] ==
gpu::kGpuFeatureStatusEnabled) {
DCHECK_NE(gpu_preferences_.use_vulkan,
gpu::VulkanImplementationName::kNone);
bool vulkan_use_swiftshader = gpu_preferences_.use_vulkan ==
gpu::VulkanImplementationName::kSwiftshader;
const bool enforce_protected_memory =
gpu_preferences_.enforce_vulkan_protected_memory;
vulkan_implementation_ = gpu::CreateVulkanImplementation(
vulkan_use_swiftshader,
enforce_protected_memory ? true : false /* allow_protected_memory */,
enforce_protected_memory);
if (!vulkan_implementation_ ||
!vulkan_implementation_->InitializeVulkanInstance(
!gpu_preferences_.disable_vulkan_surface)) {
DLOG(ERROR) << "Failed to create and initialize Vulkan implementation.";
vulkan_implementation_ = nullptr;
CHECK(!gpu_preferences_.disable_vulkan_fallback_to_gl_for_testing);
}
}
if (!vulkan_implementation_) {
if (gpu_preferences_.gr_context_type == gpu::GrContextType::kVulkan) {
gpu_preferences_.gr_context_type = gpu::GrContextType::kGL;
}
gpu_preferences_.use_vulkan = gpu::VulkanImplementationName::kNone;
gpu_feature_info_.status_values[gpu::GPU_FEATURE_TYPE_VULKAN] =
gpu::kGpuFeatureStatusDisabled;
}
#else
gpu_preferences_.use_vulkan = gpu::VulkanImplementationName::kNone;
gpu_feature_info_.status_values[gpu::GPU_FEATURE_TYPE_VULKAN] =
gpu::kGpuFeatureStatusDisabled;
#endif
InitializeVulkan();
// Collect GPU process info
if (!gl_disabled) {
......@@ -526,6 +492,7 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line,
InitializeGLThreadSafe(command_line, gpu_preferences_, &gpu_info_,
&gpu_feature_info_);
InitializeVulkan();
default_offscreen_surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size());
......@@ -663,4 +630,41 @@ scoped_refptr<gl::GLSurface> GpuInit::TakeDefaultOffscreenSurface() {
return std::move(default_offscreen_surface_);
}
void GpuInit::InitializeVulkan() {
#if BUILDFLAG(ENABLE_VULKAN)
if (gpu_feature_info_.status_values[gpu::GPU_FEATURE_TYPE_VULKAN] ==
gpu::kGpuFeatureStatusEnabled) {
DCHECK_NE(gpu_preferences_.use_vulkan,
gpu::VulkanImplementationName::kNone);
bool vulkan_use_swiftshader = gpu_preferences_.use_vulkan ==
gpu::VulkanImplementationName::kSwiftshader;
const bool enforce_protected_memory =
gpu_preferences_.enforce_vulkan_protected_memory;
vulkan_implementation_ = gpu::CreateVulkanImplementation(
vulkan_use_swiftshader,
enforce_protected_memory ? true : false /* allow_protected_memory */,
enforce_protected_memory);
if (!vulkan_implementation_ ||
!vulkan_implementation_->InitializeVulkanInstance(
!gpu_preferences_.disable_vulkan_surface)) {
DLOG(ERROR) << "Failed to create and initialize Vulkan implementation.";
vulkan_implementation_ = nullptr;
CHECK(!gpu_preferences_.disable_vulkan_fallback_to_gl_for_testing);
}
}
if (!vulkan_implementation_) {
if (gpu_preferences_.gr_context_type == gpu::GrContextType::kVulkan) {
gpu_preferences_.gr_context_type = gpu::GrContextType::kGL;
}
gpu_preferences_.use_vulkan = gpu::VulkanImplementationName::kNone;
gpu_feature_info_.status_values[gpu::GPU_FEATURE_TYPE_VULKAN] =
gpu::kGpuFeatureStatusDisabled;
}
#else
gpu_preferences_.use_vulkan = gpu::VulkanImplementationName::kNone;
gpu_feature_info_.status_values[gpu::GPU_FEATURE_TYPE_VULKAN] =
gpu::kGpuFeatureStatusDisabled;
#endif // BUILDFLAG(ENABLE_VULKAN)
}
} // namespace gpu
......@@ -79,6 +79,8 @@ class GPU_IPC_SERVICE_EXPORT GpuInit {
#endif
private:
void InitializeVulkan();
GpuSandboxHelper* sandbox_helper_ = nullptr;
std::unique_ptr<GpuWatchdogThread> watchdog_thread_;
GPUInfo gpu_info_;
......
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