Support D3D apis on apitrace trace command.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 27 Feb 2012 10:36:53 +0000 (10:36 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 27 Feb 2012 10:36:53 +0000 (10:36 +0000)
cli/cli_trace.cpp
common/trace_api.hpp
common/trace_tools_trace.cpp

index 2672816..a67416b 100644 (file)
@@ -51,7 +51,13 @@ usage(void)
         "    with other apitrace utilities for replay or analysis.\n"
         "\n"
         "    -v, --verbose       verbose output\n"
-        "    -a, --api=API       specify API to trace (gl or egl);\n"
+        "    -a, --api=API       specify API to trace ("
+#ifdef _WIN32
+                                                      "gl, d3d7, d3d8, d3d9, or d3d10"
+#else
+                                                      "gl or egl"
+#endif
+                                                      ");\n"
         "                        default is `gl`\n"
         "    -o, --output=TRACE  specify output trace file;\n"
         "                        default is `PROGRAM.trace`\n";
@@ -90,6 +96,14 @@ command(int argc, char *argv[])
                 api = trace::API_GL;
             } else if (strcmp(optarg, "egl") == 0) {
                 api = trace::API_EGL;
+            } else if (strcmp(optarg, "d3d7") == 0) {
+                api = trace::API_D3D7;
+            } else if (strcmp(optarg, "d3d8") == 0) {
+                api = trace::API_D3D8;
+            } else if (strcmp(optarg, "d3d9") == 0) {
+                api = trace::API_D3D9;
+            } else if (strcmp(optarg, "d3d10") == 0) {
+                api = trace::API_D3D10;
             } else {
                 std::cerr << "error: unknown API `" << optarg << "`\n";
                 usage();
index 612a8f1..ed4823f 100644 (file)
@@ -38,6 +38,10 @@ namespace trace {
 enum API {
     API_GL, // GL + GLX/WGL/CGL
     API_EGL, // GL/GLES1/GLES2/VG + EGL
+    API_D3D7,
+    API_D3D8,
+    API_D3D9,
+    API_D3D10,
 };
 
 
index 39c6ddf..a6182d7 100644 (file)
@@ -62,6 +62,10 @@ traceProgram(API api,
     const char *relPath;
     const char *absPath;
 
+    /*
+     * TODO: simplify code
+     */
+
     switch (api) {
     case API_GL:
         relPath = "wrappers/" GL_TRACE_WRAPPER;
@@ -76,8 +80,26 @@ traceProgram(API api,
         absPath = APITRACE_WRAPPER_INSTALL_DIR "/" EGL_TRACE_WRAPPER;
         break;
 #endif
+#ifdef _WIN32
+    case API_D3D7:
+        relPath = "wrappers\\ddraw.dll";
+        absPath = APITRACE_WRAPPER_INSTALL_DIR "\\ddraw.dll";
+        break;
+    case API_D3D8:
+        relPath = "wrappers\\d3d8.dll";
+        absPath = APITRACE_WRAPPER_INSTALL_DIR "\\d3d8.dll";
+        break;
+    case API_D3D9:
+        relPath = "wrappers\\d3d9.dll";
+        absPath = APITRACE_WRAPPER_INSTALL_DIR "\\d3d9.dll";
+        break;
+    case API_D3D10:
+        relPath = "wrappers\\d3d10.dll";
+        absPath = APITRACE_WRAPPER_INSTALL_DIR "\\d3d10.dll";
+        break;
+#endif
     default:
-        std::cerr << "error: invalid API\n";
+        std::cerr << "error: unsupported API\n";
         return 1;
     }