Commit dd957d67 authored by Zhenyao Mo's avatar Zhenyao Mo Committed by Commit Bot

Collect correct GL strings when falling back to SwiftShader.

Plus some minor fixes.
1) consistently use gpu_preferences_ instead of gpu_preferences in case in the
   future we want to update gpu_preferences_ in the beginning.
2) change ShouldEnableSwiftShader() to EnableSwiftShaderIfNeeded().

I don't think this is the root cause why SwiftShader fails to fall back as
reported in the bug, but still, it's good to fix this issue.

BUG=852537
TEST=about:gpu
R=piman@chromium.org
TBR=rsesek@chromium.org

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I17ab4d26b4eea079bcd9f732e6689c76f002d584
Reviewed-on: https://chromium-review.googlesource.com/1100123Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Reviewed-by: default avatarAlexis Hétu <sugoi@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567324}
parent fbb70225
...@@ -58,9 +58,7 @@ base::OnceClosure MaybeWrapWithGPUSandboxHook( ...@@ -58,9 +58,7 @@ base::OnceClosure MaybeWrapWithGPUSandboxHook(
gpu::InitializeSwitchableGPUs( gpu::InitializeSwitchableGPUs(
gpu_feature_info.enabled_gpu_driver_bug_workarounds); gpu_feature_info.enabled_gpu_driver_bug_workarounds);
} }
// Calling ShouldEnableSwiftShader will append the proper command line gpu::EnableSwiftShaderIfNeeded(
// switch in order to enable SwiftShader if required.
gpu::ShouldEnableSwiftShader(
command_line, gpu_feature_info, command_line, gpu_feature_info,
gpu_preferences.disable_software_rasterizer, needs_more_info); gpu_preferences.disable_software_rasterizer, needs_more_info);
// Preload either the desktop GL or the osmesa so, depending on the // Preload either the desktop GL or the osmesa so, depending on the
......
...@@ -578,7 +578,7 @@ bool InitializeGLThreadSafe(base::CommandLine* command_line, ...@@ -578,7 +578,7 @@ bool InitializeGLThreadSafe(base::CommandLine* command_line,
} }
#endif // OS_ANDROID #endif // OS_ANDROID
bool ShouldEnableSwiftShader(base::CommandLine* command_line, bool EnableSwiftShaderIfNeeded(base::CommandLine* command_line,
const GpuFeatureInfo& gpu_feature_info, const GpuFeatureInfo& gpu_feature_info,
bool disable_software_rasterizer, bool disable_software_rasterizer,
bool blacklist_needs_more_info) { bool blacklist_needs_more_info) {
......
...@@ -67,7 +67,8 @@ GPU_EXPORT bool InitializeGLThreadSafe(base::CommandLine* command_line, ...@@ -67,7 +67,8 @@ GPU_EXPORT bool InitializeGLThreadSafe(base::CommandLine* command_line,
// Returns whether SwiftShader should be enabled. If true, the proper command // Returns whether SwiftShader should be enabled. If true, the proper command
// line switch to enable SwiftShader will be appended to 'command_line'. // line switch to enable SwiftShader will be appended to 'command_line'.
GPU_EXPORT bool ShouldEnableSwiftShader(base::CommandLine* command_line, GPU_EXPORT bool EnableSwiftShaderIfNeeded(
base::CommandLine* command_line,
const GpuFeatureInfo& gpu_feature_info, const GpuFeatureInfo& gpu_feature_info,
bool disable_software_rasterizer, bool disable_software_rasterizer,
bool blacklist_needs_more_info); bool blacklist_needs_more_info);
......
...@@ -115,7 +115,7 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, ...@@ -115,7 +115,7 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line,
// Compute blacklist and driver bug workaround decisions based on basic GPU // Compute blacklist and driver bug workaround decisions based on basic GPU
// info. // info.
gpu_feature_info_ = gpu::ComputeGpuFeatureInfo( gpu_feature_info_ = gpu::ComputeGpuFeatureInfo(
gpu_info_, gpu_preferences, command_line, &needs_more_info); gpu_info_, gpu_preferences_, command_line, &needs_more_info);
} }
#endif // !OS_ANDROID && !IS_CHROMECAST #endif // !OS_ANDROID && !IS_CHROMECAST
gpu_info_.in_process_gpu = false; gpu_info_.in_process_gpu = false;
...@@ -136,7 +136,7 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, ...@@ -136,7 +136,7 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line,
use_swiftshader = true; use_swiftshader = true;
} }
bool enable_watchdog = !gpu_preferences.disable_gpu_watchdog && bool enable_watchdog = !gpu_preferences_.disable_gpu_watchdog &&
!command_line->HasSwitch(switches::kHeadless); !command_line->HasSwitch(switches::kHeadless);
// Disable the watchdog in debug builds because they tend to only be run by // Disable the watchdog in debug builds because they tend to only be run by
...@@ -180,7 +180,7 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, ...@@ -180,7 +180,7 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line,
// On Chrome OS ARM Mali, GPU driver userspace creates threads when // On Chrome OS ARM Mali, GPU driver userspace creates threads when
// initializing a GL context, so start the sandbox early. // initializing a GL context, so start the sandbox early.
// TODO(zmo): Need to collect OS version before this. // 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( gpu_info_.sandboxed = sandbox_helper_->EnsureSandboxInitialized(
watchdog_thread_.get(), &gpu_info_, gpu_preferences_); watchdog_thread_.get(), &gpu_info_, gpu_preferences_);
attempted_startsandbox = true; attempted_startsandbox = true;
...@@ -199,9 +199,9 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, ...@@ -199,9 +199,9 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line,
#endif #endif
if (!use_swiftshader) { if (!use_swiftshader) {
use_swiftshader = ShouldEnableSwiftShader( use_swiftshader = EnableSwiftShaderIfNeeded(
command_line, gpu_feature_info_, 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 && if (gl_initialized && use_swiftshader &&
gl::GetGLImplementation() != gl::kGLImplementationSwiftShaderGL) { gl::GetGLImplementation() != gl::kGLImplementationSwiftShaderGL) {
...@@ -218,14 +218,14 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, ...@@ -218,14 +218,14 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line,
// We need to collect GL strings (VENDOR, RENDERER) for blacklisting purposes. // We need to collect GL strings (VENDOR, RENDERER) for blacklisting purposes.
if (!gl_disabled && !use_swiftshader) { if (!gl_disabled && !use_swiftshader) {
if (!CollectGraphicsInfo(&gpu_info_, gpu_preferences)) if (!CollectGraphicsInfo(&gpu_info_, gpu_preferences_))
return false; return false;
gpu::SetKeysForCrashLogging(gpu_info_); gpu::SetKeysForCrashLogging(gpu_info_);
gpu_feature_info_ = gpu::ComputeGpuFeatureInfo(gpu_info_, gpu_preferences, gpu_feature_info_ = gpu::ComputeGpuFeatureInfo(gpu_info_, gpu_preferences_,
command_line, nullptr); command_line, nullptr);
use_swiftshader = ShouldEnableSwiftShader( use_swiftshader = EnableSwiftShaderIfNeeded(
command_line, gpu_feature_info_, command_line, gpu_feature_info_,
gpu_preferences.disable_software_rasterizer, false); gpu_preferences_.disable_software_rasterizer, false);
if (use_swiftshader) { if (use_swiftshader) {
gl::init::ShutdownGL(true); gl::init::ShutdownGL(true);
if (!gl::init::InitializeGLNoExtensionsOneOff()) { if (!gl::init::InitializeGLNoExtensionsOneOff()) {
...@@ -307,11 +307,11 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line, ...@@ -307,11 +307,11 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line,
const GpuPreferences& gpu_preferences) { const GpuPreferences& gpu_preferences) {
gpu_preferences_ = gpu_preferences; gpu_preferences_ = gpu_preferences;
init_successful_ = true; init_successful_ = true;
DCHECK(!ShouldEnableSwiftShader(command_line, gpu_feature_info_, DCHECK(!EnableSwiftShaderIfNeeded(
gpu_preferences.disable_software_rasterizer, command_line, gpu_feature_info_,
false)); gpu_preferences_.disable_software_rasterizer, false));
InitializeGLThreadSafe(command_line, gpu_preferences, &gpu_info_, InitializeGLThreadSafe(command_line, gpu_preferences_, &gpu_info_,
&gpu_feature_info_); &gpu_feature_info_);
} }
#else #else
...@@ -337,7 +337,7 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line, ...@@ -337,7 +337,7 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line,
CollectBasicGraphicsInfo(command_line, &gpu_info_); CollectBasicGraphicsInfo(command_line, &gpu_info_);
} }
if (!PopGpuFeatureInfoCache(&gpu_feature_info_)) { if (!PopGpuFeatureInfoCache(&gpu_feature_info_)) {
gpu_feature_info_ = ComputeGpuFeatureInfo(gpu_info_, gpu_preferences, gpu_feature_info_ = ComputeGpuFeatureInfo(gpu_info_, gpu_preferences_,
command_line, &needs_more_info); command_line, &needs_more_info);
} }
if (SwitchableGPUsSupported(gpu_info_, *command_line)) { if (SwitchableGPUsSupported(gpu_info_, *command_line)) {
...@@ -346,9 +346,9 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line, ...@@ -346,9 +346,9 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line,
} }
#endif // !IS_CHROMECAST #endif // !IS_CHROMECAST
bool use_swiftshader = ShouldEnableSwiftShader( bool use_swiftshader = EnableSwiftShaderIfNeeded(
command_line, gpu_feature_info_, 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()) { if (!gl::init::InitializeGLNoExtensionsOneOff()) {
VLOG(1) << "gl::init::InitializeGLNoExtensionsOneOff failed"; VLOG(1) << "gl::init::InitializeGLNoExtensionsOneOff failed";
return; return;
...@@ -356,12 +356,12 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line, ...@@ -356,12 +356,12 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line,
bool gl_disabled = gl::GetGLImplementation() == gl::kGLImplementationDisabled; bool gl_disabled = gl::GetGLImplementation() == gl::kGLImplementationDisabled;
if (!gl_disabled && !use_swiftshader) { if (!gl_disabled && !use_swiftshader) {
CollectContextGraphicsInfo(&gpu_info_, gpu_preferences); CollectContextGraphicsInfo(&gpu_info_, gpu_preferences_);
gpu_feature_info_ = ComputeGpuFeatureInfo(gpu_info_, gpu_preferences, gpu_feature_info_ = ComputeGpuFeatureInfo(gpu_info_, gpu_preferences_,
command_line, nullptr); command_line, nullptr);
use_swiftshader = ShouldEnableSwiftShader( use_swiftshader = EnableSwiftShaderIfNeeded(
command_line, gpu_feature_info_, command_line, gpu_feature_info_,
gpu_preferences.disable_software_rasterizer, false); gpu_preferences_.disable_software_rasterizer, false);
if (use_swiftshader) { if (use_swiftshader) {
gl::init::ShutdownGL(true); gl::init::ShutdownGL(true);
if (!gl::init::InitializeGLNoExtensionsOneOff()) { if (!gl::init::InitializeGLNoExtensionsOneOff()) {
...@@ -393,9 +393,7 @@ void GpuInit::AdjustInfoToSwiftShader() { ...@@ -393,9 +393,7 @@ void GpuInit::AdjustInfoToSwiftShader() {
gpu_info_for_hardware_gpu_ = gpu_info_; gpu_info_for_hardware_gpu_ = gpu_info_;
gpu_feature_info_for_hardware_gpu_ = gpu_feature_info_; gpu_feature_info_for_hardware_gpu_ = gpu_feature_info_;
gpu_feature_info_ = ComputeGpuFeatureInfoForSwiftShader(); gpu_feature_info_ = ComputeGpuFeatureInfoForSwiftShader();
gpu_info_.gl_vendor = "Google Inc."; CollectContextGraphicsInfo(&gpu_info_, gpu_preferences_);
gpu_info_.gl_renderer = "Google SwiftShader";
gpu_info_.gl_version = "OpenGL ES 2.0 SwiftShader";
} }
void GpuInit::AdjustInfoToNoGpu() { void GpuInit::AdjustInfoToNoGpu() {
......
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