summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--o3d/core/win/d3d9/install_check.cc4
-rw-r--r--o3d/core/win/d3d9/renderer_d3d9.cc61
-rw-r--r--o3d/core/win/d3d9/software_renderer_d3d9.h46
-rw-r--r--o3d/main.scons4
-rw-r--r--o3d/plugin/build.scons19
-rw-r--r--o3d/svn_paths.scons6
-rw-r--r--o3d/tests/build.scons17
7 files changed, 137 insertions, 20 deletions
diff --git a/o3d/core/win/d3d9/install_check.cc b/o3d/core/win/d3d9/install_check.cc
index cf4d584..6dfd157 100644
--- a/o3d/core/win/d3d9/install_check.cc
+++ b/o3d/core/win/d3d9/install_check.cc
@@ -215,8 +215,8 @@ bool D3D9SoftwareInstallCheck(std::string* error) {
return false;
}
- if (!PathAppend(dll_path.get(), _T("O3DExtras\\swrend\\d3d9.dll"))) {
- *error = "Failed to compute new plugin location.";
+ if (!PathAppend(dll_path.get(), _T("O3DExtras\\swiftshader_d3d9.dll"))) {
+ *error = "Failed to compute new software renderer location.";
return false;
}
diff --git a/o3d/core/win/d3d9/renderer_d3d9.cc b/o3d/core/win/d3d9/renderer_d3d9.cc
index ec2c0d3..08e8100 100644
--- a/o3d/core/win/d3d9/renderer_d3d9.cc
+++ b/o3d/core/win/d3d9/renderer_d3d9.cc
@@ -54,6 +54,7 @@
#include "core/win/d3d9/primitive_d3d9.h"
#include "core/win/d3d9/render_surface_d3d9.h"
#include "core/win/d3d9/sampler_d3d9.h"
+#include "core/win/d3d9/software_renderer_d3d9.h"
#include "core/win/d3d9/stream_bank_d3d9.h"
#include "core/win/d3d9/texture_d3d9.h"
#include "core/win/d3d9/utils_d3d9.h"
@@ -297,7 +298,7 @@ bool CheckDeviceCaps(LPDIRECT3D9 d3d, Features* features) {
<< " for depth/stencil buffers.";
return false;
}
- }
+ }
return true;
}
@@ -329,11 +330,11 @@ Renderer::InitStatus CreateDirect3D(Direct3DCreate9_Ptr d3d_create_function,
// For certain GPU drivers we need to force anti-aliasing off to avoid a
// a huge performance hit when certain types of windows are used on the same
// desktop as O3D. This function returns true if O3D is running on one
-// of these GPUs/Drivers.
+// of these GPUs/Drivers.
bool ForceAntiAliasingOff(LPDIRECT3D9* d3d) {
D3DADAPTER_IDENTIFIER9 identifier;
HRESULT hr = (*d3d)->GetAdapterIdentifier(D3DADAPTER_DEFAULT, 0, &identifier);
-
+
unsigned int vendor_id = identifier.VendorId;
unsigned int device_id = identifier.DeviceId;
unsigned int product = HIWORD(identifier.DriverVersion.HighPart);
@@ -345,14 +346,46 @@ bool ForceAntiAliasingOff(LPDIRECT3D9* d3d) {
if (vendor_id == 4098 && // ATI
product == 6 &&
version == 14 &&
- subversion == 10 &&
+ subversion == 10 &&
build <= 6800) {
return true;
- }
+ }
return false;
}
+namespace {
+// Returns whether the ForceSoftwareRenderer value of the Software\Google\o3d
+// key is non-zero.
+bool IsForceSoftwareRendererEnabled() {
+ HKEY key;
+ if (FAILED(RegOpenKeyEx(HKEY_CURRENT_USER,
+ TEXT("Software\\Google\\o3d"),
+ 0,
+ KEY_READ,
+ &key))) {
+ return false;
+ }
+
+ bool enabled = false;
+ DWORD type;
+ DWORD value;
+ DWORD size = sizeof(value);
+ if (SUCCEEDED(RegQueryValueEx(key,
+ TEXT("ForceSoftwareRenderer"),
+ NULL,
+ &type,
+ reinterpret_cast<LPBYTE>(&value),
+ &size))) {
+ if (type == REG_DWORD && size == sizeof(value) && value) {
+ enabled = true;
+ }
+ }
+ RegCloseKey(key);
+
+ return enabled;
+}
+}
// Helper function that gets the D3D Interface, checks the available
// multisampling modes and selects the most advanced one available to create
@@ -368,9 +401,17 @@ Renderer::InitStatus InitializeD3D9Context(
int* out_width,
int* out_height) {
- // Try the hardware renderer first.
- Renderer::InitStatus status_hardware = CreateDirect3D(
- Direct3DCreate9, d3d, features);
+ // Check registry to see if the developer has opted to force the software
+ // renderer.
+ Renderer::InitStatus status_hardware;
+ if (IsForceSoftwareRendererEnabled()) {
+ // Simulate GPU not up to spec.
+ status_hardware = Renderer::GPU_NOT_UP_TO_SPEC;
+ } else {
+ // Create a hardware device.
+ status_hardware = CreateDirect3D(Direct3DCreate9, d3d, features);
+ }
+
if (status_hardware != Renderer::SUCCESS) {
Renderer::InitStatus status_software = CreateDirect3D(
Direct3DCreate9Software, d3d, features);
@@ -387,6 +428,8 @@ Renderer::InitStatus InitializeD3D9Context(
}
return status_hardware;
}
+
+ SetupSoftwareRenderer(*d3d);
}
D3DDISPLAYMODE d3ddm;
@@ -394,7 +437,7 @@ Renderer::InitStatus InitializeD3D9Context(
return Renderer::GPU_NOT_UP_TO_SPEC;
// NOTE: make sure the backbuffer matches this format, as it is
- // currently currently assumed to be 32-bit 8X8R8G8B
+ // currently assumed to be 32-bit 8X8R8G8B
ZeroMemory(d3d_present_parameters, sizeof(*d3d_present_parameters));
d3d_present_parameters->Windowed = !fullscreen;
diff --git a/o3d/core/win/d3d9/software_renderer_d3d9.h b/o3d/core/win/d3d9/software_renderer_d3d9.h
new file mode 100644
index 0000000..fcfa8ef
--- /dev/null
+++ b/o3d/core/win/d3d9/software_renderer_d3d9.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef O3D_CORE_WIN_D3D9_SOFTWARE_RENDERER_D3D9_H
+#define O3D_CORE_WIN_D3D9_SOFTWARE_RENDERER_D3D9_H
+
+#include <d3d9.h>
+
+namespace o3d {
+
+// Not implemented.
+inline bool SetupSoftwareRenderer(IDirect3D9* d3d) {
+ return false;
+}
+
+} // namespace o3d
+
+#endif // O3D_CORE_WIN_D3D9_SOFTWARE_RENDERER_D3D9_H
diff --git a/o3d/main.scons b/o3d/main.scons
index 1f026fc..192d82a 100644
--- a/o3d/main.scons
+++ b/o3d/main.scons
@@ -87,6 +87,9 @@ base_env.Append(
DOCS_DIR = '$DESTINATION_ROOT/docs',
CPPPATH = [
+ # The internal dir is first so that headers in internal can replace
+ # those in external.
+ '$INTERNAL_DIR',
'$SCONSTRUCT_DIR/..',
'$SCONSTRUCT_DIR',
'$CHROME_SRC_DIR',
@@ -308,6 +311,7 @@ windows_env = binaries_env.Clone(
windows_env.Append(
CPPPATH = [
'$PLATFORM_SDK_VISTA_6_0_DIR/Include',
+ '$SWIFTSHADER_DIR',
],
LIBPATH = [
'$PLATFORM_SDK_VISTA_6_0_DIR/Lib',
diff --git a/o3d/plugin/build.scons b/o3d/plugin/build.scons
index 666cd7a..9bd29dd 100644
--- a/o3d/plugin/build.scons
+++ b/o3d/plugin/build.scons
@@ -270,7 +270,7 @@ if env.Bit('mac'):
env['SHLIBPREFIX'] = ['']
env['SHLIBSUFFIX'] = ['']
plugin_dll = env.SharedLibrary('o3d', inputs)
- plugin_install = env.Replicate('$ARTIFACTS_DIR/O3D.plugin/Contents/MacOS/', plugin_dll)
+ plugin_artifacts = env.Replicate('$ARTIFACTS_DIR/O3D.plugin/Contents/MacOS/', plugin_dll)
# insert version number into Info.plist
env.ReplaceStrings(
@@ -385,10 +385,10 @@ if env.Bit('mac'):
else:
plugin_dll = env.SharedLibrary('npo3dautoplugin', inputs)
# copy to artifacts
- plugin_install = env.Replicate('$ARTIFACTS_DIR', plugin_dll)
+ plugin_artifacts = env.Replicate('$ARTIFACTS_DIR', plugin_dll)
if env.Bit('linux'):
- env.Requires(plugin_install, env.Replicate(
+ env.Requires(plugin_artifacts, env.Replicate(
'$ARTIFACTS_DIR', [
'$CG_DIR/lib/libCg.so',
'$CG_DIR/lib/libCgGL.so',
@@ -398,15 +398,22 @@ if env.Bit('linux'):
# alias 'plugin' to build the plug-in in artifacts
-env.Alias('plugin', plugin_install)
+env.Alias('plugin', plugin_artifacts)
# TODO: have a common way to do colliding installs like this.
# Do the install step only if this variant is the first target.
if (env['BUILD_TYPE'] == ARGUMENTS.get('MODE') or
(ARGUMENTS.get('MODE', 'default') == 'default' and
env['BUILD_TYPE'] == 'dbg-d3d')):
- i = env.Replicate('$FIREFOX_PLUGIN_DIR', plugin_dll[0])
- env.Alias('install', i)
+ plugin_install = env.Replicate('$FIREFOX_PLUGIN_DIR', plugin_dll[0])
+ env.Alias('install', plugin_install)
+
+ if env.Bit('windows'):
+ # Copy SwiftShader to plugin dir.
+ swiftshader_path = env.subst('$SWIFTSHADER_DIR/swiftshader_d3d9.dll')
+ if os.path.exists(swiftshader_path):
+ env.Requires(plugin_install,
+ env.Replicate('$FIREFOX_PLUGIN_DIR/O3DExtras', swiftshader_path))
if env.Bit('windows'):
# Make the logging program
diff --git a/o3d/svn_paths.scons b/o3d/svn_paths.scons
index 019a618..4741f6a 100644
--- a/o3d/svn_paths.scons
+++ b/o3d/svn_paths.scons
@@ -51,17 +51,18 @@ env.Replace(
GTEST_DIR = '$THIRD_PARTY/gtest/files',
# TODO: pull from Chrome's SVN with gclient ?
ICU38_DIR = '$THIRD_PARTY/icu38/files',
+ INTERNAL_DIR = '$SCONSTRUCT_DIR/../o3d-internal',
JPEG_DIR = '$THIRD_PARTY/jpeg/src',
JSDOCTOOLKIT_DIR = '$THIRD_PARTY/jsdoctoolkit/files',
# To run selenium tests you will need a tgz'ed copy of firefox.
# Specify the path to it below.
# See tests/build.scons
MAC_HERMETIC_FIREFOX_DIR = (
- '$SCONSTRUCT_DIR/../o3d-internal/third_party/firefox'),
+ '$INTERNAL_DIR/third_party/firefox'),
# If we have directx redistributables present,
# then build o3dextras.
DIRECTX_REDIST_DIR=(
- '$SCONSTRUCT_DIR/../o3d-internal/third_party/dx_nov_2007_redist'),
+ '$INTERNAL_DIR/third_party/dx_nov_2007_redist'),
# NACL has to be in this weird directory because it looks for
# googleclient two levels above it.
NACL_DIR = '$THIRD_PARTY/native_client/googleclient/native_client',
@@ -75,6 +76,7 @@ env.Replace(
SELENIUM_PYTHON_DIR = '$THIRD_PARTY/py/selenium',
# TODO: pull from SVN with gclient ?
SKIA_DIR = '$THIRD_PARTY/skia',
+ SWIFTSHADER_DIR = '$INTERNAL_DIR/third_party/swiftshader/files',
# TODO: pull from SVN with gclient ?
V8_SRC_DIR = '$THIRD_PARTY/v8',
WIX_DIR = '$THIRD_PARTY/wix_2_0_4221/files',
diff --git a/o3d/tests/build.scons b/o3d/tests/build.scons
index 32f4417..83efd83 100644
--- a/o3d/tests/build.scons
+++ b/o3d/tests/build.scons
@@ -152,6 +152,14 @@ if env.Bit('windows'):
# Adding extra line for cleaner formatting.
env.Help('\n')
+swiftshader_install = []
+if env.Bit('windows'):
+ # Copy SwiftShader to plugin dir.
+ swiftshader_path = env.subst('$SWIFTSHADER_DIR/swiftshader_d3d9.dll')
+ if os.path.exists(swiftshader_path):
+ swiftshader_install = env.Replicate('$ARTIFACTS_DIR/O3DExtras',
+ swiftshader_path)
+
# -------------------------------------------------------------------------
# Unit tests
@@ -318,6 +326,7 @@ unit_tests_req += env.Replicate(
# Also require gl related libraries based on variant.
unit_tests_req += gl_requirements
+unit_tests_req += swiftshader_install
# Add requirements for unit tests.
env.Requires(unit_tests_install, unit_tests_req)
@@ -449,7 +458,10 @@ if ARGUMENTS.get('SYSTEM_TESTS_ENABLED', False):
# Also require gl related libraries based on variant.
system_tests_req += gl_requirements
-
+
+ # Require SwiftShader (only if it is available).
+ system_tests_req += swiftshader_install
+
# Add requirements for system_tests.
env.Requires(system_tests_install, system_tests_req)
@@ -592,6 +604,9 @@ def DeferSelenium(env):
'--screenshotsdir=$ARTIFACTS_DIR/selenium/screenshots_firefox'])] +
cleanup_steps,
)
+
+ # Require SwiftShader (only if it is available).
+ run_env.Requires(run_selenium_firefox, swiftshader_install)
if run_env.Bit('windows'):
run_selenium_ie = run_env.Alias(