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() { ...@@ -37,12 +37,12 @@ bool InitializeGLOneOff() {
cmd->GetSwitchValueASCII(switches::kUseGL); cmd->GetSwitchValueASCII(switches::kUseGL);
if (requested_implementation_name == "any") { if (requested_implementation_name == "any") {
fallback_to_software_gl = true; fallback_to_software_gl = true;
} else if (requested_implementation_name == } else if ((requested_implementation_name ==
kGLImplementationSwiftShaderName) { kGLImplementationSwiftShaderName) ||
(requested_implementation_name ==
kGLImplementationSwiftShaderForWebGLName)) {
impl = kGLImplementationSwiftShaderGL; impl = kGLImplementationSwiftShaderGL;
} else if (requested_implementation_name == } else if (requested_implementation_name == kGLImplementationANGLEName) {
kGLImplementationSwiftShaderForWebGLName ||
requested_implementation_name == kGLImplementationANGLEName) {
impl = kGLImplementationEGLGLES2; impl = kGLImplementationEGLGLES2;
} else { } else {
impl = GetNamedGLImplementation(requested_implementation_name); impl = GetNamedGLImplementation(requested_implementation_name);
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "base/at_exit.h" #include "base/at_exit.h"
#include "base/base_paths.h" #include "base/base_paths.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/native_library.h" #include "base/native_library.h"
...@@ -84,7 +83,7 @@ bool InitializeStaticOSMesaInternal() { ...@@ -84,7 +83,7 @@ bool InitializeStaticOSMesaInternal() {
return true; return true;
} }
bool InitializeStaticEGLInternal() { bool InitializeStaticEGLInternal(GLImplementation implementation) {
base::FilePath module_path; base::FilePath module_path;
if (!PathService::Get(base::DIR_MODULE, &module_path)) if (!PathService::Get(base::DIR_MODULE, &module_path))
return false; return false;
...@@ -96,14 +95,7 @@ bool InitializeStaticEGLInternal() { ...@@ -96,14 +95,7 @@ bool InitializeStaticEGLInternal() {
LoadD3DXLibrary(module_path, kD3DCompiler); LoadD3DXLibrary(module_path, kD3DCompiler);
base::FilePath gles_path; base::FilePath gles_path;
const base::CommandLine* command_line = if (implementation == kGLImplementationSwiftShaderGL) {
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 BUILDFLAG(ENABLE_SWIFTSHADER) #if BUILDFLAG(ENABLE_SWIFTSHADER)
gles_path = module_path.Append(L"swiftshader/"); gles_path = module_path.Append(L"swiftshader/");
// Preload library // Preload library
...@@ -268,7 +260,7 @@ bool InitializeStaticGLBindings(GLImplementation implementation) { ...@@ -268,7 +260,7 @@ bool InitializeStaticGLBindings(GLImplementation implementation) {
return InitializeStaticOSMesaInternal(); return InitializeStaticOSMesaInternal();
case kGLImplementationSwiftShaderGL: case kGLImplementationSwiftShaderGL:
case kGLImplementationEGLGLES2: case kGLImplementationEGLGLES2:
return InitializeStaticEGLInternal(); return InitializeStaticEGLInternal(implementation);
case kGLImplementationDesktopGL: case kGLImplementationDesktopGL:
return InitializeStaticWGLInternal(); return InitializeStaticWGLInternal();
case kGLImplementationMockGL: case kGLImplementationMockGL:
......
...@@ -81,23 +81,11 @@ bool InitializeStaticGLXInternal() { ...@@ -81,23 +81,11 @@ bool InitializeStaticGLXInternal() {
return true; return true;
} }
bool InitializeStaticEGLInternal() { bool InitializeStaticEGLInternal(GLImplementation implementation) {
base::FilePath glesv2_path(kGLESv2LibraryName); base::FilePath glesv2_path(kGLESv2LibraryName);
base::FilePath egl_path(kEGLLibraryName); base::FilePath egl_path(kEGLLibraryName);
const base::CommandLine* command_line = if (implementation == kGLImplementationSwiftShaderGL) {
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 BUILDFLAG(ENABLE_SWIFTSHADER) #if BUILDFLAG(ENABLE_SWIFTSHADER)
base::FilePath module_path; base::FilePath module_path;
if (!PathService::Get(base::DIR_MODULE, &module_path)) if (!PathService::Get(base::DIR_MODULE, &module_path))
...@@ -109,6 +97,13 @@ bool InitializeStaticEGLInternal() { ...@@ -109,6 +97,13 @@ bool InitializeStaticEGLInternal() {
#else #else
return false; return false;
#endif #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); base::NativeLibrary gles_library = LoadLibraryAndPrintError(glesv2_path);
...@@ -194,7 +189,7 @@ bool InitializeStaticGLBindings(GLImplementation implementation) { ...@@ -194,7 +189,7 @@ bool InitializeStaticGLBindings(GLImplementation implementation) {
return InitializeStaticGLXInternal(); return InitializeStaticGLXInternal();
case kGLImplementationSwiftShaderGL: case kGLImplementationSwiftShaderGL:
case kGLImplementationEGLGLES2: case kGLImplementationEGLGLES2:
return InitializeStaticEGLInternal(); return InitializeStaticEGLInternal(implementation);
case kGLImplementationMockGL: case kGLImplementationMockGL:
case kGLImplementationStubGL: case kGLImplementationStubGL:
SetGLImplementation(implementation); 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