summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/os.hpp3
-rw-r--r--retrace/dxgiretrace.py47
-rw-r--r--retrace/retrace.hpp12
-rw-r--r--retrace/retrace_main.cpp21
4 files changed, 83 insertions, 0 deletions
diff --git a/common/os.hpp b/common/os.hpp
index cc72a0ea..91c819fc 100644
--- a/common/os.hpp
+++ b/common/os.hpp
@@ -42,6 +42,9 @@
#ifndef vsnprintf
#define vsnprintf _vsnprintf
#endif
+#ifndef strcasecmp
+#define strcasecmp stricmp
+#endif
#endif /* !_WIN32 */
namespace os {
diff --git a/retrace/dxgiretrace.py b/retrace/dxgiretrace.py
index c7baaf28..95face8b 100644
--- a/retrace/dxgiretrace.py
+++ b/retrace/dxgiretrace.py
@@ -88,8 +88,55 @@ createWindow(DXGI_SWAP_CHAIN_DESC *pSwapChainDesc) {
print r' DriverType = D3D_DRIVER_TYPE_HARDWARE;'
print r' }'
+ if function.name.startswith('D3D10CreateDevice'):
+ self.forceDriver('D3D10_DRIVER_TYPE')
+ if function.name.startswith('D3D11CreateDevice'):
+ self.forceDriver('D3D_DRIVER_TYPE')
+
Retracer.invokeFunction(self, function)
+ def forceDriver(self, enum):
+ print r' switch (retrace::driver) {'
+ print r' case retrace::DRIVER_HARDWARE:'
+ print r' DriverType = %s_HARDWARE;' % enum
+ print r' Software = NULL;'
+ print r' break;'
+ print r' case retrace::DRIVER_SOFTWARE:'
+ print r' pAdapter = NULL;'
+ print r' DriverType = %s_WARP;' % enum
+ print r' Software = NULL;'
+ print r' break;'
+ print r' case retrace::DRIVER_REFERENCE:'
+ print r' pAdapter = NULL;'
+ print r' DriverType = %s_REFERENCE;' % enum
+ print r' Software = NULL;'
+ print r' break;'
+ print r' case retrace::DRIVER_NULL:'
+ print r' pAdapter = NULL;'
+ print r' DriverType = %s_NULL;' % enum
+ print r' Software = NULL;'
+ print r' break;'
+ print r' case retrace::DRIVER_MODULE:'
+ print r' pAdapter = NULL;'
+ print r' DriverType = %s_SOFTWARE;' % enum
+ print r' Software = LoadLibraryA(retrace::driverModule);'
+ print r' if (!Software) {'
+ print r' retrace::warning(call) << "failed to load " << retrace::driverModule << "\n";'
+ print r' }'
+ print r' break;'
+ print r' default:'
+ print r' assert(0);'
+ print r' /* fall-through */'
+ print r' case retrace::DRIVER_DEFAULT:'
+ print r' if (DriverType == %s_SOFTWARE) {' % enum
+ print r' Software = LoadLibraryA("d3d10warp");'
+ print r' if (!Software) {'
+ print r' retrace::warning(call) << "failed to load d3d10warp.dll\n";'
+ print r' }'
+ print r' }'
+ print r' break;'
+ print r' }'
+
def invokeInterfaceMethod(self, interface, method):
# keep track of the last used device for state dumping
if interface.name in ('ID3D10Device', 'ID3D10Device1'):
diff --git a/retrace/retrace.hpp b/retrace/retrace.hpp
index cc77029e..228c8135 100644
--- a/retrace/retrace.hpp
+++ b/retrace/retrace.hpp
@@ -152,6 +152,18 @@ extern bool profilingPixelsDrawn;
extern bool dumpingState;
+enum Driver {
+ DRIVER_DEFAULT,
+ DRIVER_HARDWARE, // force hardware
+ DRIVER_SOFTWARE,
+ DRIVER_REFERENCE,
+ DRIVER_NULL,
+ DRIVER_MODULE,
+};
+
+extern Driver driver;
+extern const char *driverModule;
+
extern bool doubleBuffer;
extern bool coreProfile;
diff --git a/retrace/retrace_main.cpp b/retrace/retrace_main.cpp
index a59ee9ae..63d3dab0 100644
--- a/retrace/retrace_main.cpp
+++ b/retrace/retrace_main.cpp
@@ -61,6 +61,9 @@ int verbosity = 0;
bool debug = true;
bool dumpingState = false;
+Driver driver = DRIVER_DEFAULT;
+const char *driverModule = NULL;
+
bool doubleBuffer = true;
bool coreProfile = false;
@@ -106,6 +109,7 @@ takeSnapshot(unsigned call_no) {
image::Image *src = dumper->getSnapshot();
if (!src) {
+ std::cout << "Failed to get snapshot\n";
return;
}
@@ -505,6 +509,7 @@ usage(const char *argv0) {
" -C, --calls=CALLSET calls to compare (default is every frame)\n"
" --core use core profile\n"
" --db use a double buffer visual (default)\n"
+ " --driver=DRIVER force driver type (`hw`, `sw`, `ref`, `null`, or driver module name)\n"
" --sb use a single buffer visual\n"
" -s, --snapshot-prefix=PREFIX take snapshots; `-` for PNM stdout output\n"
" -S, --snapshot=CALLSET calls to snapshot (default is every frame)\n"
@@ -516,6 +521,7 @@ usage(const char *argv0) {
enum {
CORE_OPT = CHAR_MAX + 1,
DB_OPT,
+ DRIVER_OPT,
PCPU_OPT,
PGPU_OPT,
PPD_OPT,
@@ -532,6 +538,7 @@ longOptions[] = {
{"compare", required_argument, 0, 'c'},
{"core", no_argument, 0, CORE_OPT},
{"db", no_argument, 0, DB_OPT},
+ {"driver", required_argument, 0, DRIVER_OPT},
{"dump-state", required_argument, 0, 'D'},
{"help", no_argument, 0, 'h'},
{"pcpu", no_argument, 0, PCPU_OPT},
@@ -594,6 +601,20 @@ int main(int argc, char **argv)
case DB_OPT:
retrace::doubleBuffer = true;
break;
+ case DRIVER_OPT:
+ if (strcasecmp(optarg, "hw") == 0) {
+ driver = DRIVER_HARDWARE;
+ } else if (strcasecmp(optarg, "sw") == 0) {
+ driver = DRIVER_SOFTWARE;
+ } else if (strcasecmp(optarg, "ref") == 0) {
+ driver = DRIVER_REFERENCE;
+ } else if (strcasecmp(optarg, "null") == 0) {
+ driver = DRIVER_NULL;
+ } else {
+ driver = DRIVER_MODULE;
+ driverModule = optarg;
+ }
+ break;
case SB_OPT:
retrace::doubleBuffer = false;
break;