Commit 06a905b5 authored by Alexis Hetu's avatar Alexis Hetu Committed by Commit Bot

Fixed fallback to software for tests

In ui/gl/init/gl_factory.cc, InitializeGLOneOffImplementation() has
functionality to fallback to software OpenGL, which wasn't working for
SwiftShader, since it uses the same initializer as Angle (which is EGL
and GLESv2). Currently, the way to distinguish between the two was
through command line flags, but the flags stay unchanged when falling
back to software OpenGL, so an extra argument was added in order to
know if the EGL/GLESv2 initialization has to use SwiftShader.

Bug: 726075
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ic4480f0e1e9ac385b90f2760408b10a9738a2498
Reviewed-on: https://chromium-review.googlesource.com/517912
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#476162}
parent d5226ddf
......@@ -37,12 +37,12 @@ bool InitializeGLOneOff() {
cmd->GetSwitchValueASCII(switches::kUseGL);
if (requested_implementation_name == "any") {
fallback_to_software_gl = true;
} else if (requested_implementation_name ==
kGLImplementationSwiftShaderName) {
} else if ((requested_implementation_name ==
kGLImplementationSwiftShaderName) ||
(requested_implementation_name ==
kGLImplementationSwiftShaderForWebGLName)) {
impl = kGLImplementationSwiftShaderGL;
} else if (requested_implementation_name ==
kGLImplementationSwiftShaderForWebGLName ||
requested_implementation_name == kGLImplementationANGLEName) {
} else if (requested_implementation_name == kGLImplementationANGLEName) {
impl = kGLImplementationEGLGLES2;
} else {
impl = GetNamedGLImplementation(requested_implementation_name);
......
......@@ -9,7 +9,6 @@
#include "base/at_exit.h"
#include "base/base_paths.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/native_library.h"
......@@ -84,7 +83,7 @@ bool InitializeStaticOSMesaInternal() {
return true;
}
bool InitializeStaticEGLInternal() {
bool InitializeStaticEGLInternal(GLImplementation implementation) {
base::FilePath module_path;
if (!PathService::Get(base::DIR_MODULE, &module_path))
return false;
......@@ -96,14 +95,7 @@ bool InitializeStaticEGLInternal() {
LoadD3DXLibrary(module_path, kD3DCompiler);
base::FilePath gles_path;
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
const std::string use_gl =
command_line->GetSwitchValueASCII(switches::kUseGL);
bool using_swift_shader =
(use_gl == kGLImplementationSwiftShaderName) ||
(use_gl == kGLImplementationSwiftShaderForWebGLName);
if (using_swift_shader) {
if (implementation == kGLImplementationSwiftShaderGL) {
#if BUILDFLAG(ENABLE_SWIFTSHADER)
gles_path = module_path.Append(L"swiftshader/");
// Preload library
......@@ -268,7 +260,7 @@ bool InitializeStaticGLBindings(GLImplementation implementation) {
return InitializeStaticOSMesaInternal();
case kGLImplementationSwiftShaderGL:
case kGLImplementationEGLGLES2:
return InitializeStaticEGLInternal();
return InitializeStaticEGLInternal(implementation);
case kGLImplementationDesktopGL:
return InitializeStaticWGLInternal();
case kGLImplementationMockGL:
......
......@@ -81,23 +81,11 @@ bool InitializeStaticGLXInternal() {
return true;
}
bool InitializeStaticEGLInternal() {
bool InitializeStaticEGLInternal(GLImplementation implementation) {
base::FilePath glesv2_path(kGLESv2LibraryName);
base::FilePath egl_path(kEGLLibraryName);
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
const std::string use_gl =
command_line->GetSwitchValueASCII(switches::kUseGL);
if (use_gl == kGLImplementationANGLEName) {
base::FilePath module_path;
if (!PathService::Get(base::DIR_MODULE, &module_path))
return false;
glesv2_path = module_path.Append(kGLESv2ANGLELibraryName);
egl_path = module_path.Append(kEGLANGLELibraryName);
} else if ((use_gl == kGLImplementationSwiftShaderName) ||
(use_gl == kGLImplementationSwiftShaderForWebGLName)) {
if (implementation == kGLImplementationSwiftShaderGL) {
#if BUILDFLAG(ENABLE_SWIFTSHADER)
base::FilePath module_path;
if (!PathService::Get(base::DIR_MODULE, &module_path))
......@@ -109,6 +97,13 @@ bool InitializeStaticEGLInternal() {
#else
return false;
#endif
} else {
base::FilePath module_path;
if (!PathService::Get(base::DIR_MODULE, &module_path))
return false;
glesv2_path = module_path.Append(kGLESv2ANGLELibraryName);
egl_path = module_path.Append(kEGLANGLELibraryName);
}
base::NativeLibrary gles_library = LoadLibraryAndPrintError(glesv2_path);
......@@ -194,7 +189,7 @@ bool InitializeStaticGLBindings(GLImplementation implementation) {
return InitializeStaticGLXInternal();
case kGLImplementationSwiftShaderGL:
case kGLImplementationEGLGLES2:
return InitializeStaticEGLInternal();
return InitializeStaticEGLInternal(implementation);
case kGLImplementationMockGL:
case kGLImplementationStubGL:
SetGLImplementation(implementation);
......
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