6 Copyright 2011 Jose Fonseca, Zack Rusin
7 Copyright 2008-2010 VMware, Inc.
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31 This includes a set of tools for:
32 - trace OpenGL, D3D8, and D3D9 APIs calls to a file;
33 - retrace OpenGL calls from a file;
34 - visualize trace files, and inspect state.
39 * It has not been tested with many applications. Bugs in less used features may
40 cause application crashes.
41 * Direct3D 8 support is currently broken.
42 * No Direct3D retrace support
45 = Building from source =
47 Requirements common for all platforms:
48 * Python (requires version 2.6)
49 * CMake (tested with version 2.8)
51 Requirements to build the GUI (optional):
52 * Qt (tested with version 4.7)
53 * QJSON (tested with version 0.7.1)
63 You can also build the 32bit GL wrapper on 64bit distro with a multilib gcc by
66 cmake -H. -Bbuild32 -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_LINK_FLAGS=-m32
67 make -C build32 glxtrace
72 Additional requirements:
74 * Microsoft Visual Studio (tested with 2008 version) or MinGW (tested with gcc version 4.4)
76 * Microsoft DirectX SDK (tested with August 2007 release)
78 To build with Visual Studio invoke CMake as:
80 cmake -G "Visual Studio 9 2008" -H. -Bbuild
81 cmake --build build --config MinSizeRel
83 If you are building with GUI support (i.e, with QT and QJSON), it should detect
84 the official QT sdk automatically, but you will need to build QJSON yourself
85 and also set the QJSON_INCLUDE_DIR and QJSON_LIBRARIES variables in the
86 generated CMakeCache.txt when building apitrace and repeat the above sequence.
88 It's also possible to build for Windows on Linux with MinGW cross compilers.
89 See http://www.cmake.org/Wiki/CmakeMingw for detailed instructions.
97 Run the application you want to trace as
99 LD_PRELOAD=/path/to/glxtrace.so /path/to/application
101 and it will generate a trace named "application.trace" in the current
102 directory. You can specify the written trace filename by setting the
103 TRACE_FILE envirnment variable before running.
107 /path/to/tracedump application.trace | less -R
109 Replay the trace with
111 /path/to/glretrace application.trace
113 Pass the -db option to use a double buffered visual. Pass --help to glretrace
118 /path/to/qapitrace application.trace
121 The LD_PRELOAD mechanism should work with most applications. There are some
122 applications, e.g., Unigine Heaven, which global function pointers with the
123 same name as GL entrypoints, living in a shared object that wasn't linked with
124 -Bsymbolic flag, so relocations to those globals function pointers get
125 overwritten with the address to our wrapper library, and the application will
126 segfault when trying to write to them. For these applications it is possible
127 to trace by using glxtrace.so as an ordinary libGL.so and injecting into
130 ln -s glxtrace.so libGL.so
131 ln -s glxtrace.so libGL.so.1
132 ln -s glxtrace.so libGL.so.1.2
133 export LD_LIBRARY_PATH=/path/to/directory/where/glxtrace/is:$LD_LIBRARY_PATH
134 export TRACE_LIBGL=/path/to/real/libGL.so.1
140 * Copy opengl32.dll, d3d8.dll, or d3d9.dll from build/wrappers directory to the
141 directory with the application you want to trace.
143 * Run the application.
145 * View the trace with
147 /path/to/tracedump application.trace
149 * Replay the trace with
151 /path/to/glretrace application.trace
156 * http://zrusin.blogspot.com/2011/04/apitrace.html
157 * http://jrfonseca.blogspot.com/2008/07/tracing-d3d-applications.html
163 * [http://www.mikoweb.eu/index.php?node=21 Proxy DLL]
164 * [http://www.codeguru.com/cpp/g-m/directx/directx8/article.php/c11453/ Intercept Calls to DirectX with a Proxy DLL]
165 * [http://graphics.stanford.edu/~mdfisher/D3D9Interceptor.html Direct3D 9 API Interceptor]
168 * [http://msdn.microsoft.com/en-us/library/ee417062.aspx Microsoft PIX]
169 * [http://doc.51windows.net/Directx9_SDK/?url=/directx9_sdk/graphics/programmingguide/TutorialsAndSamplesAndToolsAndTips/Tools/D3DSpy.htm D3DSpy]: the predecessor of PIX
170 * [http://developer.amd.com/gpu/PerfStudio/pages/APITraceWindow.aspx AMD GPU PerfStudio]
176 * [http://www.opengl.org/sdk/tools/BuGLe/ BuGLe]
177 * [http://code.google.com/p/glintercept/ GLIntercept]
178 * [https://gitorious.org/tracy tracy]: OpenGL ES and OpenVG trace, retrace, and state inspection
181 * [http://www.gremedy.com/products.php gDEBugger]
182 * [http://cumbia.informatik.uni-stuttgart.de/glsldevil/index.html glslDevil]
183 * [http://developer.amd.com/gpu/PerfStudio/pages/APITraceWindow.aspx AMD GPU PerfStudio]