Commit 23f46567 authored by apatrick@chromium.org's avatar apatrick@chromium.org

Preload D3DX DLLs before ANGLE is loaded.

This is in case they are not in the DLL search path. It tries the default search path first in case D3DX is installed in the regular place. If that fails then it uses an absolute path to where Chrome installs them.

I moved the call to SetErrorMode to be before ANGLE is loaded. Without this, a failing call to LoadLibrary would result in the display of a dialog box.

This is dependent on http://codereview.chromium.org/7831021.

BUG=69610

Review URL: http://codereview.chromium.org/7792078

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99892 0039d316-1c4b-4281-b951-d872f2087c98
parent 1629811b
...@@ -41,6 +41,19 @@ int GpuMain(const MainFunctionParams& parameters) { ...@@ -41,6 +41,19 @@ int GpuMain(const MainFunctionParams& parameters) {
ChildProcess::WaitForDebugger("Gpu"); ChildProcess::WaitForDebugger("Gpu");
} }
if (!command_line.HasSwitch(switches::kSingleProcess)) {
#if defined(OS_WIN)
// Prevent Windows from displaying a modal dialog on failures like not being
// able to load a DLL.
SetErrorMode(
SEM_FAILCRITICALERRORS |
SEM_NOGPFAULTERRORBOX |
SEM_NOOPENFILEERRORBOX);
#elif defined(USE_X11)
ui::SetDefaultX11ErrorHandlers();
#endif
}
// Initialization of the OpenGL bindings may fail, in which case we // Initialization of the OpenGL bindings may fail, in which case we
// will need to tear down this process. However, we can not do so // will need to tear down this process. However, we can not do so
// safely until the IPC channel is set up, because the detection of // safely until the IPC channel is set up, because the detection of
...@@ -92,19 +105,6 @@ int GpuMain(const MainFunctionParams& parameters) { ...@@ -92,19 +105,6 @@ int GpuMain(const MainFunctionParams& parameters) {
MessageLoop main_message_loop(message_loop_type); MessageLoop main_message_loop(message_loop_type);
base::PlatformThread::SetName("CrGpuMain"); base::PlatformThread::SetName("CrGpuMain");
if (!command_line.HasSwitch(switches::kSingleProcess)) {
#if defined(OS_WIN)
// Prevent Windows from displaying a modal dialog on failures like not being
// able to load a DLL.
SetErrorMode(
SEM_FAILCRITICALERRORS |
SEM_NOGPFAULTERRORBOX |
SEM_NOOPENFILEERRORBOX);
#elif defined(USE_X11)
ui::SetDefaultX11ErrorHandlers();
#endif
}
GpuProcess gpu_process; GpuProcess gpu_process;
GpuChildThread* child_thread = new GpuChildThread(dead_on_arrival); GpuChildThread* child_thread = new GpuChildThread(dead_on_arrival);
......
...@@ -2,13 +2,18 @@ ...@@ -2,13 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <d3dx9.h>
#include <vector> #include <vector>
#include "base/at_exit.h"
#include "base/base_paths.h" #include "base/base_paths.h"
#include "base/bind.h"
#include "base/file_path.h" #include "base/file_path.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/native_library.h" #include "base/native_library.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/stringprintf.h"
#include "ui/gfx/gl/gl_bindings.h" #include "ui/gfx/gl/gl_bindings.h"
#include "ui/gfx/gl/gl_implementation.h" #include "ui/gfx/gl/gl_implementation.h"
...@@ -29,6 +34,23 @@ void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near, ...@@ -29,6 +34,23 @@ void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near,
glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far)); glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far));
} }
bool LoadD3DXLibrary(const FilePath& module_path,
const FilePath::StringType& name) {
base::NativeLibrary library = base::LoadNativeLibrary(FilePath(name), NULL);
if (!library) {
library = base::LoadNativeLibrary(module_path.Append(name), NULL);
if (!library) {
VLOG(1) << name << " not found.";
return false;
}
}
base::AtExitManager::RegisterTask(
base::Bind(base::UnloadNativeLibrary, library));
return true;
}
} // namespace anonymous } // namespace anonymous
bool InitializeGLBindings(GLImplementation implementation) { bool InitializeGLBindings(GLImplementation implementation) {
...@@ -83,9 +105,18 @@ bool InitializeGLBindings(GLImplementation implementation) { ...@@ -83,9 +105,18 @@ bool InitializeGLBindings(GLImplementation implementation) {
SetupSoftwareRenderer(); SetupSoftwareRenderer();
#endif #endif
// Attempt to load D3DX and its dependencies using the default search path
// and if that fails, using an absolute path. This is to ensure these DLLs
// are loaded before ANGLE is loaded in case they are not in the default
// search path.
LoadD3DXLibrary(module_path, base::StringPrintf(L"d3dcompiler_%d.dll",
D3DX_SDK_VERSION));
LoadD3DXLibrary(module_path, base::StringPrintf(L"d3dx9_%d.dll",
D3DX_SDK_VERSION));
// Load libglesv2.dll before libegl.dll because the latter is dependent on // Load libglesv2.dll before libegl.dll because the latter is dependent on
// the former and if there is another version of libglesv2.dll in the dll // the former and if there is another version of libglesv2.dll in the dll
// search path, it will get loaded. // search path, it will get loaded instead.
base::NativeLibrary gles_library = base::LoadNativeLibrary( base::NativeLibrary gles_library = base::LoadNativeLibrary(
module_path.Append(L"libglesv2.dll"), NULL); module_path.Append(L"libglesv2.dll"), NULL);
if (!gles_library) { if (!gles_library) {
......
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