├── .gitignore ├── README.md ├── build ├── vs2002 │ ├── InsightProfiler.sln │ ├── insight.vcproj │ ├── test-multiple_threads.vcproj │ ├── test-single_thread.vcproj │ └── test-single_thread_async.vcproj ├── vs2003 │ ├── InsightProfiler.sln │ ├── insight.vcproj │ ├── test-multiple_threads.vcproj │ ├── test-single_thread.vcproj │ └── test-single_thread_async.vcproj ├── vs2005 │ ├── InsightProfiler.sln │ ├── insight.vcproj │ ├── test-multiple_threads.vcproj │ ├── test-single_thread.vcproj │ └── test-single_thread_async.vcproj ├── vs2008 │ ├── InsightProfiler.sln │ ├── insight.vcproj │ ├── test-multiple_threads.vcproj │ ├── test-single_thread.vcproj │ └── test-single_thread_async.vcproj └── vs2010 │ ├── InsightProfiler.sln │ ├── insight.vcxproj │ ├── insight.vcxproj.filters │ ├── test-multiple_threads.vcxproj │ ├── test-multiple_threads.vcxproj.filters │ ├── test-single_thread.vcxproj │ ├── test-single_thread.vcxproj.filters │ ├── test-single_thread_async.vcxproj │ └── test-single_thread_async.vcxproj.filters ├── insight ├── redist │ └── insight.h └── source │ ├── insight.cpp │ ├── insight_backend.cpp │ ├── insight_backend.h │ ├── insight_background_png.h │ ├── insight_bar_png.h │ ├── insight_graph_d3d9.cpp │ ├── insight_graph_d3d9.h │ ├── insight_gui.cpp │ ├── insight_gui.h │ └── insight_utils.h ├── scripts ├── generate_projects.cmd ├── premake4.exe └── premake4.lua └── tests ├── test-multiple_threads.cpp ├── test-single_thread.cpp └── test-single_thread_async.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | bin/* 2 | release/* 3 | *.ncb 4 | *.suo 5 | *.user 6 | *.sdf 7 | *.opensdf 8 | *.ipch 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Insight Profiler version 1.0-RC2, by Yuriy O'Donnell 2 | ================================================ 3 | 4 | Insight is an instrumented thread profiler with real-time timing data display. 5 | It is mainly geared toward PC games development and only supports Windows C++ applications. 6 | The main goal is to provide real-time game thread timing overview with minimal overhead. 7 | Insight uses rdtsc instruction to get high-precision time information. It has very small cost, 8 | but is not reliable by any means. Therefore timing output should be considered a rough estimate. 9 | In practice, though, this estimate is pretty close to reality and is good enough for gamedev. 10 | 11 | How to use Insight Profiler 12 | =========================== 13 | 14 | Setup 15 | ----- 16 | 17 | Insight is an instrumented profiler, which means that you need to explicitly place timing events 18 | in your game code and link to Insight DLL. 19 | 20 | To use Insight, put insight.h and insight.lib where your compiler and linker can find them. 21 | Add insight.lib to the linker input and put insight.dll next to your game executable. 22 | 23 | Initialization 24 | -------------- 25 | 26 | Insight Profiler instance must be initialized before any profile events can be captured. 27 | To do this, Insight::initialize() and Insight::terminate() should be called at your game startup 28 | and shutdown respectively. 29 | 30 | Calling initialize() will create profiler GUI window, which uses DirectX9 for displaying 31 | timing data. Because of this, it is recommended that you initialize Insight after creating your 32 | main DirectX device in order for tools like FRAPS and NVidia PerfHUD to work correctly. 33 | Calling terminate() will clean-up all resources used by Insight. 34 | 35 | It is possible to initialize Insight in two modes: Synchronous and Asynchronous (recommended). 36 | 37 | In Asynchronous mode, Insight will create a thread for itself to handle GUI and event buffers. 38 | Because Insight timing is only supposed to be a rough approximation, overhead from the handler 39 | thread can be considered negligible. 40 | 41 | In Synchronous mode, Insight::update() must be called regularly (every frame) by your game. 42 | This may produce slightly more accurate timings at the cost of GUI responsiveness. 43 | 44 | Using profile events 45 | -------------------- 46 | 47 | Use Insight::enter() and Insight::exit() to start or finish a timing event. 48 | Calling enter() expects a profile event name as a char* string. This name string must be 49 | static because Insight stores the pointer instead of copying the contents for efficiency. 50 | 51 | To simplify typical use cases, Insight::Scope class is provided. It will automatically 52 | call enter() when it is instantiated, hold the profile token and then pass it into exit() when 53 | the instance falls out of scope. 54 | 55 | Here is a typical Insight::Scope use example: 56 | 57 | void important_work() 58 | { 59 | Insight::Scope scope_timing("Important work"); 60 | for(int i=0; i 75 | #pragma comment(lib, "insight.lib") 76 | #define INSIGHT_INITIALIZE Insight::initialize(); 77 | #define INSIGHT_TERMINATE Insight::terminate(); 78 | #define INSIGHT_SCOPE(name) Insight::Scope __insight_scope(name); 79 | #else //USE_INSIGHT_PROFILER 80 | #define INSIGHT_INITIALIZE 81 | #define INSIGHT_TERMINATE 82 | #define INSIGHT_SCOPE(name) 83 | #endif //USE_INSIGHT_PROFILER 84 | 85 | 86 | Using GUI window 87 | ---------------- 88 | 89 | Insight Profiler has a simple GUI for displaying timing data in real time. 90 | Horizontal bars represent your game threads and vertical bars represent profile events. 91 | When GUI window is not active, it clears and updates every second. But when it has 92 | focus, the update is paused to allow detailed data inspection. 93 | 94 | Use left mouse button to drag profile events, mouse wheel to zoom and right button to 95 | select a timing sub-range. 96 | 97 | Closing Insight GUI window will also terminate your game process. 98 | 99 | License 100 | ======= 101 | 102 | Copyright (c) 2010 Yuriy O'Donnell 103 | 104 | Permission is hereby granted, free of charge, to any person obtaining a copy 105 | of this software and associated documentation files (the "Software"), to deal 106 | in the Software without restriction, including without limitation the rights 107 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 108 | copies of the Software, and to permit persons to whom the Software is 109 | furnished to do so, subject to the following conditions: 110 | 111 | The above copyright notice and this permission notice shall be included in 112 | all copies or substantial portions of the Software. 113 | 114 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 115 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 116 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 117 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 118 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 119 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 120 | THE SOFTWARE. 121 | -------------------------------------------------------------------------------- /build/vs2002/InsightProfiler.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 7.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "insight", "insight.vcproj", "{1D251D82-D63A-41A3-BA5B-D49984DF809E}" 3 | EndProject 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-single_thread", "test-single_thread.vcproj", "{DC27DD14-B07C-4C29-9C04-0863080C2068}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-single_thread_async", "test-single_thread_async.vcproj", "{435D37F9-0E5C-45F0-9876-8A51F9FAAE26}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-multiple_threads", "test-multiple_threads.vcproj", "{703530D4-FD5B-4B1C-9D1A-5E47944DD31E}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfiguration) = preSolution 12 | ConfigName.0 = Release 13 | ConfigName.1 = Debug 14 | EndGlobalSection 15 | GlobalSection(ProjectDependencies) = postSolution 16 | EndGlobalSection 17 | GlobalSection(ProjectConfiguration) = postSolution 18 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Release.ActiveCfg = Release|Win32 19 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Release.Build.0 = Release|Win32 20 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Debug.ActiveCfg = Debug|Win32 21 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Debug.Build.0 = Debug|Win32 22 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Release.ActiveCfg = Release|Win32 23 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Release.Build.0 = Release|Win32 24 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Debug.ActiveCfg = Debug|Win32 25 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Debug.Build.0 = Debug|Win32 26 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Release.ActiveCfg = Release|Win32 27 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Release.Build.0 = Release|Win32 28 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Debug.ActiveCfg = Debug|Win32 29 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Debug.Build.0 = Debug|Win32 30 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Release.ActiveCfg = Release|Win32 31 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Release.Build.0 = Release|Win32 32 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Debug.ActiveCfg = Debug|Win32 33 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Debug.Build.0 = Debug|Win32 34 | EndGlobalSection 35 | GlobalSection(ExtensibilityGlobals) = postSolution 36 | EndGlobalSection 37 | GlobalSection(ExtensibilityAddIns) = postSolution 38 | EndGlobalSection 39 | EndGlobal 40 | -------------------------------------------------------------------------------- /build/vs2002/insight.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 15 | 22 | 38 | 41 | 55 | 58 | 61 | 64 | 67 | 72 | 75 | 78 | 79 | 86 | 102 | 105 | 118 | 121 | 124 | 127 | 130 | 135 | 138 | 141 | 142 | 143 | 144 | 145 | 146 | 150 | 154 | 157 | 158 | 159 | 163 | 166 | 167 | 170 | 171 | 174 | 175 | 178 | 179 | 182 | 183 | 186 | 187 | 190 | 191 | 194 | 195 | 198 | 199 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | -------------------------------------------------------------------------------- /build/vs2002/test-multiple_threads.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 15 | 22 | 38 | 41 | 55 | 58 | 61 | 64 | 67 | 72 | 75 | 78 | 79 | 86 | 102 | 105 | 118 | 121 | 124 | 127 | 130 | 135 | 138 | 141 | 142 | 143 | 144 | 145 | 146 | 150 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /build/vs2002/test-single_thread.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 15 | 22 | 38 | 41 | 55 | 58 | 61 | 64 | 67 | 72 | 75 | 78 | 79 | 86 | 102 | 105 | 118 | 121 | 124 | 127 | 130 | 135 | 138 | 141 | 142 | 143 | 144 | 145 | 146 | 150 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /build/vs2002/test-single_thread_async.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 15 | 22 | 38 | 41 | 55 | 58 | 61 | 64 | 67 | 72 | 75 | 78 | 79 | 86 | 102 | 105 | 118 | 121 | 124 | 127 | 130 | 135 | 138 | 141 | 142 | 143 | 144 | 145 | 146 | 150 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /build/vs2003/InsightProfiler.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "insight", "insight.vcproj", "{1D251D82-D63A-41A3-BA5B-D49984DF809E}" 3 | EndProject 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-single_thread", "test-single_thread.vcproj", "{DC27DD14-B07C-4C29-9C04-0863080C2068}" 5 | ProjectSection(ProjectDependencies) = postProject 6 | {1D251D82-D63A-41A3-BA5B-D49984DF809E} = {1D251D82-D63A-41A3-BA5B-D49984DF809E} 7 | EndProjectSection 8 | EndProject 9 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-single_thread_async", "test-single_thread_async.vcproj", "{435D37F9-0E5C-45F0-9876-8A51F9FAAE26}" 10 | ProjectSection(ProjectDependencies) = postProject 11 | {1D251D82-D63A-41A3-BA5B-D49984DF809E} = {1D251D82-D63A-41A3-BA5B-D49984DF809E} 12 | EndProjectSection 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-multiple_threads", "test-multiple_threads.vcproj", "{703530D4-FD5B-4B1C-9D1A-5E47944DD31E}" 15 | ProjectSection(ProjectDependencies) = postProject 16 | {1D251D82-D63A-41A3-BA5B-D49984DF809E} = {1D251D82-D63A-41A3-BA5B-D49984DF809E} 17 | EndProjectSection 18 | EndProject 19 | Global 20 | GlobalSection(SolutionConfiguration) = preSolution 21 | Release = Release 22 | Debug = Debug 23 | EndGlobalSection 24 | GlobalSection(ProjectDependencies) = postSolution 25 | EndGlobalSection 26 | GlobalSection(ProjectConfiguration) = postSolution 27 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Release.ActiveCfg = Release|Win32 28 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Release.Build.0 = Release|Win32 29 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Debug.ActiveCfg = Debug|Win32 30 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Debug.Build.0 = Debug|Win32 31 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Release.ActiveCfg = Release|Win32 32 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Release.Build.0 = Release|Win32 33 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Debug.ActiveCfg = Debug|Win32 34 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Debug.Build.0 = Debug|Win32 35 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Release.ActiveCfg = Release|Win32 36 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Release.Build.0 = Release|Win32 37 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Debug.ActiveCfg = Debug|Win32 38 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Debug.Build.0 = Debug|Win32 39 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Release.ActiveCfg = Release|Win32 40 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Release.Build.0 = Release|Win32 41 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Debug.ActiveCfg = Debug|Win32 42 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Debug.Build.0 = Debug|Win32 43 | EndGlobalSection 44 | GlobalSection(ExtensibilityGlobals) = postSolution 45 | EndGlobalSection 46 | GlobalSection(ExtensibilityAddIns) = postSolution 47 | EndGlobalSection 48 | EndGlobal 49 | -------------------------------------------------------------------------------- /build/vs2003/insight.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 15 | 22 | 38 | 41 | 55 | 58 | 61 | 64 | 67 | 72 | 75 | 78 | 81 | 84 | 87 | 88 | 95 | 111 | 114 | 127 | 130 | 133 | 136 | 139 | 144 | 147 | 150 | 153 | 156 | 159 | 160 | 161 | 162 | 163 | 164 | 168 | 172 | 175 | 176 | 177 | 181 | 184 | 185 | 188 | 189 | 192 | 193 | 196 | 197 | 200 | 201 | 204 | 205 | 208 | 209 | 212 | 213 | 216 | 217 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | -------------------------------------------------------------------------------- /build/vs2003/test-multiple_threads.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 15 | 22 | 38 | 41 | 55 | 58 | 61 | 64 | 67 | 72 | 75 | 78 | 81 | 84 | 87 | 88 | 95 | 111 | 114 | 127 | 130 | 133 | 136 | 139 | 144 | 147 | 150 | 153 | 156 | 159 | 160 | 161 | 162 | 163 | 164 | 168 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /build/vs2003/test-single_thread.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 15 | 22 | 38 | 41 | 55 | 58 | 61 | 64 | 67 | 72 | 75 | 78 | 81 | 84 | 87 | 88 | 95 | 111 | 114 | 127 | 130 | 133 | 136 | 139 | 144 | 147 | 150 | 153 | 156 | 159 | 160 | 161 | 162 | 163 | 164 | 168 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /build/vs2003/test-single_thread_async.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 15 | 22 | 38 | 41 | 55 | 58 | 61 | 64 | 67 | 72 | 75 | 78 | 81 | 84 | 87 | 88 | 95 | 111 | 114 | 127 | 130 | 133 | 136 | 139 | 144 | 147 | 150 | 153 | 156 | 159 | 160 | 161 | 162 | 163 | 164 | 168 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /build/vs2005/InsightProfiler.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "insight", "insight.vcproj", "{1D251D82-D63A-41A3-BA5B-D49984DF809E}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-single_thread", "test-single_thread.vcproj", "{DC27DD14-B07C-4C29-9C04-0863080C2068}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {1D251D82-D63A-41A3-BA5B-D49984DF809E} = {1D251D82-D63A-41A3-BA5B-D49984DF809E} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-single_thread_async", "test-single_thread_async.vcproj", "{435D37F9-0E5C-45F0-9876-8A51F9FAAE26}" 12 | ProjectSection(ProjectDependencies) = postProject 13 | {1D251D82-D63A-41A3-BA5B-D49984DF809E} = {1D251D82-D63A-41A3-BA5B-D49984DF809E} 14 | EndProjectSection 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-multiple_threads", "test-multiple_threads.vcproj", "{703530D4-FD5B-4B1C-9D1A-5E47944DD31E}" 17 | ProjectSection(ProjectDependencies) = postProject 18 | {1D251D82-D63A-41A3-BA5B-D49984DF809E} = {1D251D82-D63A-41A3-BA5B-D49984DF809E} 19 | EndProjectSection 20 | EndProject 21 | Global 22 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 23 | Release|Win32 = Release|Win32 24 | Debug|Win32 = Debug|Win32 25 | EndGlobalSection 26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 27 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Release|Win32.ActiveCfg = Release|Win32 28 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Release|Win32.Build.0 = Release|Win32 29 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Debug|Win32.ActiveCfg = Debug|Win32 30 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Debug|Win32.Build.0 = Debug|Win32 31 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Release|Win32.ActiveCfg = Release|Win32 32 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Release|Win32.Build.0 = Release|Win32 33 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Debug|Win32.ActiveCfg = Debug|Win32 34 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Debug|Win32.Build.0 = Debug|Win32 35 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Release|Win32.ActiveCfg = Release|Win32 36 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Release|Win32.Build.0 = Release|Win32 37 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Debug|Win32.ActiveCfg = Debug|Win32 38 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Debug|Win32.Build.0 = Debug|Win32 39 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Release|Win32.ActiveCfg = Release|Win32 40 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Release|Win32.Build.0 = Release|Win32 41 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Debug|Win32.ActiveCfg = Debug|Win32 42 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Debug|Win32.Build.0 = Debug|Win32 43 | EndGlobalSection 44 | GlobalSection(SolutionProperties) = preSolution 45 | HideSolutionNode = FALSE 46 | EndGlobalSection 47 | EndGlobal 48 | -------------------------------------------------------------------------------- /build/vs2005/insight.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 57 | 60 | 65 | 68 | 82 | 85 | 88 | 91 | 94 | 97 | 100 | 103 | 106 | 107 | 114 | 117 | 120 | 123 | 126 | 129 | 146 | 149 | 154 | 157 | 170 | 173 | 176 | 179 | 182 | 185 | 188 | 191 | 194 | 195 | 196 | 197 | 198 | 199 | 203 | 207 | 210 | 211 | 212 | 216 | 219 | 220 | 223 | 224 | 227 | 228 | 231 | 232 | 235 | 236 | 239 | 240 | 243 | 244 | 247 | 248 | 251 | 252 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | -------------------------------------------------------------------------------- /build/vs2005/test-multiple_threads.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 57 | 60 | 65 | 68 | 82 | 85 | 88 | 91 | 94 | 97 | 100 | 103 | 106 | 107 | 114 | 117 | 120 | 123 | 126 | 129 | 146 | 149 | 154 | 157 | 170 | 173 | 176 | 179 | 182 | 185 | 188 | 191 | 194 | 195 | 196 | 197 | 198 | 199 | 203 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | -------------------------------------------------------------------------------- /build/vs2005/test-single_thread.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 57 | 60 | 65 | 68 | 82 | 85 | 88 | 91 | 94 | 97 | 100 | 103 | 106 | 107 | 114 | 117 | 120 | 123 | 126 | 129 | 146 | 149 | 154 | 157 | 170 | 173 | 176 | 179 | 182 | 185 | 188 | 191 | 194 | 195 | 196 | 197 | 198 | 199 | 203 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | -------------------------------------------------------------------------------- /build/vs2005/test-single_thread_async.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 57 | 60 | 65 | 68 | 82 | 85 | 88 | 91 | 94 | 97 | 100 | 103 | 106 | 107 | 114 | 117 | 120 | 123 | 126 | 129 | 146 | 149 | 154 | 157 | 170 | 173 | 176 | 179 | 182 | 185 | 188 | 191 | 194 | 195 | 196 | 197 | 198 | 199 | 203 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | -------------------------------------------------------------------------------- /build/vs2008/InsightProfiler.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "insight", "insight.vcproj", "{1D251D82-D63A-41A3-BA5B-D49984DF809E}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-single_thread", "test-single_thread.vcproj", "{DC27DD14-B07C-4C29-9C04-0863080C2068}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {1D251D82-D63A-41A3-BA5B-D49984DF809E} = {1D251D82-D63A-41A3-BA5B-D49984DF809E} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-single_thread_async", "test-single_thread_async.vcproj", "{435D37F9-0E5C-45F0-9876-8A51F9FAAE26}" 12 | ProjectSection(ProjectDependencies) = postProject 13 | {1D251D82-D63A-41A3-BA5B-D49984DF809E} = {1D251D82-D63A-41A3-BA5B-D49984DF809E} 14 | EndProjectSection 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-multiple_threads", "test-multiple_threads.vcproj", "{703530D4-FD5B-4B1C-9D1A-5E47944DD31E}" 17 | ProjectSection(ProjectDependencies) = postProject 18 | {1D251D82-D63A-41A3-BA5B-D49984DF809E} = {1D251D82-D63A-41A3-BA5B-D49984DF809E} 19 | EndProjectSection 20 | EndProject 21 | Global 22 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 23 | Release|Win32 = Release|Win32 24 | Debug|Win32 = Debug|Win32 25 | EndGlobalSection 26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 27 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Release|Win32.ActiveCfg = Release|Win32 28 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Release|Win32.Build.0 = Release|Win32 29 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Debug|Win32.ActiveCfg = Debug|Win32 30 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Debug|Win32.Build.0 = Debug|Win32 31 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Release|Win32.ActiveCfg = Release|Win32 32 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Release|Win32.Build.0 = Release|Win32 33 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Debug|Win32.ActiveCfg = Debug|Win32 34 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Debug|Win32.Build.0 = Debug|Win32 35 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Release|Win32.ActiveCfg = Release|Win32 36 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Release|Win32.Build.0 = Release|Win32 37 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Debug|Win32.ActiveCfg = Debug|Win32 38 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Debug|Win32.Build.0 = Debug|Win32 39 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Release|Win32.ActiveCfg = Release|Win32 40 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Release|Win32.Build.0 = Release|Win32 41 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Debug|Win32.ActiveCfg = Debug|Win32 42 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Debug|Win32.Build.0 = Debug|Win32 43 | EndGlobalSection 44 | GlobalSection(SolutionProperties) = preSolution 45 | HideSolutionNode = FALSE 46 | EndGlobalSection 47 | EndGlobal 48 | -------------------------------------------------------------------------------- /build/vs2008/insight.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 56 | 59 | 64 | 67 | 81 | 84 | 87 | 90 | 93 | 96 | 99 | 102 | 105 | 106 | 113 | 116 | 119 | 122 | 125 | 128 | 144 | 147 | 152 | 155 | 168 | 171 | 174 | 177 | 180 | 183 | 186 | 189 | 192 | 193 | 194 | 195 | 196 | 197 | 201 | 205 | 208 | 209 | 210 | 214 | 217 | 218 | 221 | 222 | 225 | 226 | 229 | 230 | 233 | 234 | 237 | 238 | 241 | 242 | 245 | 246 | 249 | 250 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | -------------------------------------------------------------------------------- /build/vs2008/test-multiple_threads.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 56 | 59 | 64 | 67 | 81 | 84 | 87 | 90 | 93 | 96 | 99 | 102 | 105 | 106 | 113 | 116 | 119 | 122 | 125 | 128 | 144 | 147 | 152 | 155 | 168 | 171 | 174 | 177 | 180 | 183 | 186 | 189 | 192 | 193 | 194 | 195 | 196 | 197 | 201 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | -------------------------------------------------------------------------------- /build/vs2008/test-single_thread.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 56 | 59 | 64 | 67 | 81 | 84 | 87 | 90 | 93 | 96 | 99 | 102 | 105 | 106 | 113 | 116 | 119 | 122 | 125 | 128 | 144 | 147 | 152 | 155 | 168 | 171 | 174 | 177 | 180 | 183 | 186 | 189 | 192 | 193 | 194 | 195 | 196 | 197 | 201 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | -------------------------------------------------------------------------------- /build/vs2008/test-single_thread_async.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 56 | 59 | 64 | 67 | 81 | 84 | 87 | 90 | 93 | 96 | 99 | 102 | 105 | 106 | 113 | 116 | 119 | 122 | 125 | 128 | 144 | 147 | 152 | 155 | 168 | 171 | 174 | 177 | 180 | 183 | 186 | 189 | 192 | 193 | 194 | 195 | 196 | 197 | 201 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | -------------------------------------------------------------------------------- /build/vs2010/InsightProfiler.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "insight", "insight.vcxproj", "{1D251D82-D63A-41A3-BA5B-D49984DF809E}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-single_thread", "test-single_thread.vcxproj", "{DC27DD14-B07C-4C29-9C04-0863080C2068}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {1D251D82-D63A-41A3-BA5B-D49984DF809E} = {1D251D82-D63A-41A3-BA5B-D49984DF809E} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-single_thread_async", "test-single_thread_async.vcxproj", "{435D37F9-0E5C-45F0-9876-8A51F9FAAE26}" 12 | ProjectSection(ProjectDependencies) = postProject 13 | {1D251D82-D63A-41A3-BA5B-D49984DF809E} = {1D251D82-D63A-41A3-BA5B-D49984DF809E} 14 | EndProjectSection 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-multiple_threads", "test-multiple_threads.vcxproj", "{703530D4-FD5B-4B1C-9D1A-5E47944DD31E}" 17 | ProjectSection(ProjectDependencies) = postProject 18 | {1D251D82-D63A-41A3-BA5B-D49984DF809E} = {1D251D82-D63A-41A3-BA5B-D49984DF809E} 19 | EndProjectSection 20 | EndProject 21 | Global 22 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 23 | Release|Win32 = Release|Win32 24 | Debug|Win32 = Debug|Win32 25 | EndGlobalSection 26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 27 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Release|Win32.ActiveCfg = Release|Win32 28 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Release|Win32.Build.0 = Release|Win32 29 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Debug|Win32.ActiveCfg = Debug|Win32 30 | {1D251D82-D63A-41A3-BA5B-D49984DF809E}.Debug|Win32.Build.0 = Debug|Win32 31 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Release|Win32.ActiveCfg = Release|Win32 32 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Release|Win32.Build.0 = Release|Win32 33 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Debug|Win32.ActiveCfg = Debug|Win32 34 | {DC27DD14-B07C-4C29-9C04-0863080C2068}.Debug|Win32.Build.0 = Debug|Win32 35 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Release|Win32.ActiveCfg = Release|Win32 36 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Release|Win32.Build.0 = Release|Win32 37 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Debug|Win32.ActiveCfg = Debug|Win32 38 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26}.Debug|Win32.Build.0 = Debug|Win32 39 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Release|Win32.ActiveCfg = Release|Win32 40 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Release|Win32.Build.0 = Release|Win32 41 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Debug|Win32.ActiveCfg = Debug|Win32 42 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E}.Debug|Win32.Build.0 = Debug|Win32 43 | EndGlobalSection 44 | GlobalSection(SolutionProperties) = preSolution 45 | HideSolutionNode = FALSE 46 | EndGlobalSection 47 | EndGlobal 48 | -------------------------------------------------------------------------------- /build/vs2010/insight.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Release 6 | Win32 7 | 8 | 9 | Debug 10 | Win32 11 | 12 | 13 | 14 | {1D251D82-D63A-41A3-BA5B-D49984DF809E} 15 | insight 16 | Win32Proj 17 | 18 | 19 | 20 | DynamicLibrary 21 | MultiByte 22 | true 23 | false 24 | 25 | 26 | DynamicLibrary 27 | MultiByte 28 | true 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | <_ProjectFileVersion>10.0.30319.1 42 | ..\..\bin\vs2010_Release_x32\ 43 | ..\..\bin\vs2010_Release_x32\obj\x32\Release\insight\ 44 | insight 45 | false 46 | false 47 | false 48 | ..\..\bin\vs2010_Debug_x32\ 49 | ..\..\bin\vs2010_Debug_x32\obj\x32\Debug\insight\ 50 | insight 51 | false 52 | true 53 | false 54 | 55 | 56 | 57 | MaxSpeed 58 | ..\..;%(AdditionalIncludeDirectories) 59 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;NDEBUG;INSIGHT_DLL;%(PreprocessorDefinitions) 60 | false 61 | true 62 | MultiThreaded 63 | true 64 | 65 | Level4 66 | false 67 | false 68 | Fast 69 | 70 | 71 | 72 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;NDEBUG;INSIGHT_DLL;%(PreprocessorDefinitions) 73 | ..\..;%(AdditionalIncludeDirectories) 74 | 75 | 76 | d3d9.lib;d3dx9.lib;dxerr.lib;%(AdditionalDependencies) 77 | $(OutDir)insight.dll 78 | %(AdditionalLibraryDirectories) 79 | Windows 80 | false 81 | true 82 | true 83 | ..\..\bin\vs2010_Release_x32\insight.lib 84 | MachineX86 85 | 86 | 87 | 88 | 89 | Disabled 90 | ..\..;%(AdditionalIncludeDirectories) 91 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;_DEBUG;INSIGHT_DLL;%(PreprocessorDefinitions) 92 | true 93 | EnableFastChecks 94 | true 95 | MultiThreadedDebug 96 | true 97 | 98 | Level4 99 | false 100 | false 101 | EditAndContinue 102 | 103 | 104 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;_DEBUG;INSIGHT_DLL;%(PreprocessorDefinitions) 105 | ..\..;%(AdditionalIncludeDirectories) 106 | 107 | 108 | d3d9.lib;d3dx9.lib;dxerr.lib;%(AdditionalDependencies) 109 | $(OutDir)insight.dll 110 | %(AdditionalLibraryDirectories) 111 | Windows 112 | true 113 | $(OutDir)insight.pdb 114 | ..\..\bin\vs2010_Debug_x32\insight.lib 115 | MachineX86 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /build/vs2010/insight.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {0592A438-7A9E-D34B-AD13-67268CEA8A50} 6 | 7 | 8 | {466F862C-CCB6-4C40-8D63-B56B01702A5C} 9 | 10 | 11 | {A60A0423-EE53-5E45-928E-6B03F59868FF} 12 | 13 | 14 | 15 | 16 | insight\redist 17 | 18 | 19 | insight\source 20 | 21 | 22 | insight\source 23 | 24 | 25 | insight\source 26 | 27 | 28 | insight\source 29 | 30 | 31 | insight\source 32 | 33 | 34 | insight\source 35 | 36 | 37 | 38 | 39 | insight\source 40 | 41 | 42 | insight\source 43 | 44 | 45 | insight\source 46 | 47 | 48 | insight\source 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /build/vs2010/test-multiple_threads.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Release 6 | Win32 7 | 8 | 9 | Debug 10 | Win32 11 | 12 | 13 | 14 | {703530D4-FD5B-4B1C-9D1A-5E47944DD31E} 15 | test-multiple_threads 16 | Win32Proj 17 | 18 | 19 | 20 | Application 21 | MultiByte 22 | true 23 | false 24 | 25 | 26 | Application 27 | MultiByte 28 | true 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | <_ProjectFileVersion>10.0.30319.1 42 | ..\..\bin\vs2010_Release_x32\ 43 | ..\..\bin\vs2010_Release_x32\obj\x32\Release\test-multiple_threads\ 44 | test-multiple_threads 45 | false 46 | false 47 | ..\..\bin\vs2010_Debug_x32\ 48 | ..\..\bin\vs2010_Debug_x32\obj\x32\Debug\test-multiple_threads\ 49 | test-multiple_threads 50 | true 51 | false 52 | 53 | 54 | 55 | MaxSpeed 56 | ..\..;%(AdditionalIncludeDirectories) 57 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;NDEBUG;%(PreprocessorDefinitions) 58 | false 59 | true 60 | MultiThreaded 61 | true 62 | 63 | Level4 64 | false 65 | false 66 | Fast 67 | 68 | 69 | 70 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;NDEBUG;%(PreprocessorDefinitions) 71 | ..\..;%(AdditionalIncludeDirectories) 72 | 73 | 74 | ..\..\bin\vs2010_Release_x32\insight.lib;%(AdditionalDependencies) 75 | $(OutDir)test-multiple_threads.exe 76 | %(AdditionalLibraryDirectories) 77 | Console 78 | false 79 | true 80 | true 81 | mainCRTStartup 82 | MachineX86 83 | 84 | 85 | 86 | 87 | Disabled 88 | ..\..;%(AdditionalIncludeDirectories) 89 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;_DEBUG;%(PreprocessorDefinitions) 90 | true 91 | EnableFastChecks 92 | true 93 | MultiThreadedDebug 94 | true 95 | 96 | Level4 97 | false 98 | false 99 | EditAndContinue 100 | 101 | 102 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;_DEBUG;%(PreprocessorDefinitions) 103 | ..\..;%(AdditionalIncludeDirectories) 104 | 105 | 106 | ..\..\bin\vs2010_Debug_x32\insight.lib;%(AdditionalDependencies) 107 | $(OutDir)test-multiple_threads.exe 108 | %(AdditionalLibraryDirectories) 109 | Console 110 | true 111 | $(OutDir)test-multiple_threads.pdb 112 | mainCRTStartup 113 | MachineX86 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /build/vs2010/test-multiple_threads.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {89EB3749-1BAB-BC4C-ABA7-36AA4FDBE775} 6 | 7 | 8 | 9 | 10 | tests 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /build/vs2010/test-single_thread.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Release 6 | Win32 7 | 8 | 9 | Debug 10 | Win32 11 | 12 | 13 | 14 | {DC27DD14-B07C-4C29-9C04-0863080C2068} 15 | test-single_thread 16 | Win32Proj 17 | 18 | 19 | 20 | Application 21 | MultiByte 22 | true 23 | false 24 | 25 | 26 | Application 27 | MultiByte 28 | true 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | <_ProjectFileVersion>10.0.30319.1 42 | ..\..\bin\vs2010_Release_x32\ 43 | ..\..\bin\vs2010_Release_x32\obj\x32\Release\test-single_thread\ 44 | test-single_thread 45 | false 46 | false 47 | ..\..\bin\vs2010_Debug_x32\ 48 | ..\..\bin\vs2010_Debug_x32\obj\x32\Debug\test-single_thread\ 49 | test-single_thread 50 | true 51 | false 52 | 53 | 54 | 55 | MaxSpeed 56 | ..\..;%(AdditionalIncludeDirectories) 57 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;NDEBUG;%(PreprocessorDefinitions) 58 | false 59 | true 60 | MultiThreaded 61 | true 62 | 63 | Level4 64 | false 65 | false 66 | Fast 67 | 68 | 69 | 70 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;NDEBUG;%(PreprocessorDefinitions) 71 | ..\..;%(AdditionalIncludeDirectories) 72 | 73 | 74 | ..\..\bin\vs2010_Release_x32\insight.lib;%(AdditionalDependencies) 75 | $(OutDir)test-single_thread.exe 76 | %(AdditionalLibraryDirectories) 77 | Console 78 | false 79 | true 80 | true 81 | mainCRTStartup 82 | MachineX86 83 | 84 | 85 | 86 | 87 | Disabled 88 | ..\..;%(AdditionalIncludeDirectories) 89 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;_DEBUG;%(PreprocessorDefinitions) 90 | true 91 | EnableFastChecks 92 | true 93 | MultiThreadedDebug 94 | true 95 | 96 | Level4 97 | false 98 | false 99 | EditAndContinue 100 | 101 | 102 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;_DEBUG;%(PreprocessorDefinitions) 103 | ..\..;%(AdditionalIncludeDirectories) 104 | 105 | 106 | ..\..\bin\vs2010_Debug_x32\insight.lib;%(AdditionalDependencies) 107 | $(OutDir)test-single_thread.exe 108 | %(AdditionalLibraryDirectories) 109 | Console 110 | true 111 | $(OutDir)test-single_thread.pdb 112 | mainCRTStartup 113 | MachineX86 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /build/vs2010/test-single_thread.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {FDDDB8C2-A592-BE40-8302-D1DD5B039D75} 6 | 7 | 8 | 9 | 10 | tests 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /build/vs2010/test-single_thread_async.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Release 6 | Win32 7 | 8 | 9 | Debug 10 | Win32 11 | 12 | 13 | 14 | {435D37F9-0E5C-45F0-9876-8A51F9FAAE26} 15 | test-single_thread_async 16 | Win32Proj 17 | 18 | 19 | 20 | Application 21 | MultiByte 22 | true 23 | false 24 | 25 | 26 | Application 27 | MultiByte 28 | true 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | <_ProjectFileVersion>10.0.30319.1 42 | ..\..\bin\vs2010_Release_x32\ 43 | ..\..\bin\vs2010_Release_x32\obj\x32\Release\test-single_thread_async\ 44 | test-single_thread_async 45 | false 46 | false 47 | ..\..\bin\vs2010_Debug_x32\ 48 | ..\..\bin\vs2010_Debug_x32\obj\x32\Debug\test-single_thread_async\ 49 | test-single_thread_async 50 | true 51 | false 52 | 53 | 54 | 55 | MaxSpeed 56 | ..\..;%(AdditionalIncludeDirectories) 57 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;NDEBUG;%(PreprocessorDefinitions) 58 | false 59 | true 60 | MultiThreaded 61 | true 62 | 63 | Level4 64 | false 65 | false 66 | Fast 67 | 68 | 69 | 70 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;NDEBUG;%(PreprocessorDefinitions) 71 | ..\..;%(AdditionalIncludeDirectories) 72 | 73 | 74 | ..\..\bin\vs2010_Release_x32\insight.lib;%(AdditionalDependencies) 75 | $(OutDir)test-single_thread_async.exe 76 | %(AdditionalLibraryDirectories) 77 | Console 78 | false 79 | true 80 | true 81 | mainCRTStartup 82 | MachineX86 83 | 84 | 85 | 86 | 87 | Disabled 88 | ..\..;%(AdditionalIncludeDirectories) 89 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;_DEBUG;%(PreprocessorDefinitions) 90 | true 91 | EnableFastChecks 92 | true 93 | MultiThreadedDebug 94 | true 95 | 96 | Level4 97 | false 98 | false 99 | EditAndContinue 100 | 101 | 102 | _HAS_EXCEPTIONS=0;_STATIC_CPPLIB;_DEBUG;%(PreprocessorDefinitions) 103 | ..\..;%(AdditionalIncludeDirectories) 104 | 105 | 106 | ..\..\bin\vs2010_Debug_x32\insight.lib;%(AdditionalDependencies) 107 | $(OutDir)test-single_thread_async.exe 108 | %(AdditionalLibraryDirectories) 109 | Console 110 | true 111 | $(OutDir)test-single_thread_async.pdb 112 | mainCRTStartup 113 | MachineX86 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /build/vs2010/test-single_thread_async.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {CE39CB66-D0DF-484D-8885-08607B7B60E1} 6 | 7 | 8 | 9 | 10 | tests 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /insight/redist/insight.h: -------------------------------------------------------------------------------- 1 | #ifndef __INSIGHT_H__ 2 | #define __INSIGHT_H__ 3 | 4 | #ifdef INSIGHT_DLL 5 | #define INSIGHT_API __declspec( dllexport ) 6 | #else 7 | #define INSIGHT_API __declspec( dllimport ) 8 | #endif //INSIGHT_DLL 9 | 10 | namespace Insight 11 | { 12 | typedef unsigned __int64 cycle_metric; 13 | 14 | struct Token 15 | { 16 | cycle_metric time_enter; 17 | cycle_metric time_exit; 18 | unsigned long thread_id; 19 | const char* name; 20 | }; 21 | 22 | INSIGHT_API void initialize(bool asynchronous=true, bool start_minimized=false); // call this at application startup 23 | INSIGHT_API void terminate(); // call this at application shutdown 24 | 25 | INSIGHT_API void update(); // call this once a frame if using synchronous mode 26 | 27 | INSIGHT_API Token enter(const char* name); // start profile event (enter scope); 'name' must be static 28 | INSIGHT_API void exit(Token& token); // finish profile event (exit scope) 29 | 30 | class Node 31 | { 32 | public: 33 | Node(const char* name) 34 | : m_name(name) 35 | { 36 | } 37 | __forceinline void start() 38 | { 39 | m_token = Insight::enter(m_name); 40 | } 41 | __forceinline void stop() 42 | { 43 | Insight::exit(m_token); 44 | } 45 | __forceinline const char* name() const { return m_name; } 46 | private: 47 | Token m_token; 48 | const char* m_name; 49 | }; 50 | 51 | class Scope 52 | { 53 | public: 54 | explicit __forceinline Scope(const char* name) 55 | { 56 | m_token = Insight::enter(name); 57 | } 58 | explicit __forceinline Scope(const Node& node) 59 | { 60 | m_token = Insight::enter(node.name()); 61 | } 62 | __forceinline ~Scope() 63 | { 64 | Insight::exit(m_token); 65 | } 66 | private: 67 | Token m_token; 68 | }; 69 | 70 | } 71 | 72 | #endif //__INSIGHT_H__ 73 | 74 | -------------------------------------------------------------------------------- /insight/source/insight.cpp: -------------------------------------------------------------------------------- 1 | #include "insight/redist/insight.h" 2 | 3 | #include "insight_utils.h" 4 | #include "insight_gui.h" 5 | #include "insight_backend.h" 6 | 7 | #define NOMINMAX 8 | #include // for GetCurrentThreadId() 9 | #include 10 | 11 | 12 | namespace 13 | { 14 | bool g_asynchronous = false; 15 | } 16 | 17 | namespace Insight 18 | { 19 | 20 | ////////////////////////////////////////////////////////////////////////// 21 | 22 | void initialize(bool asynchronous, bool start_minimized) 23 | { 24 | g_asynchronous = asynchronous; 25 | InsightGui::initialize(asynchronous, start_minimized); 26 | } 27 | 28 | void terminate() 29 | { 30 | InsightGui::terminate(); 31 | } 32 | 33 | void update() 34 | { 35 | InsightGui::update(); 36 | } 37 | 38 | Token enter(const char* name) 39 | { 40 | Token token; 41 | 42 | token.time_enter = __rdtsc(); 43 | token.thread_id = GetCurrentThreadId(); 44 | token.name = name; 45 | 46 | return token; 47 | } 48 | 49 | void exit( Token& token ) 50 | { 51 | token.time_exit = __rdtsc(); 52 | InsightBackend::g_token_buffer.push(token); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /insight/source/insight_backend.cpp: -------------------------------------------------------------------------------- 1 | #include "insight_backend.h" 2 | #include "insight_utils.h" 3 | #include 4 | 5 | namespace InsightBackend 6 | { 7 | TokenBuffer g_token_buffer; 8 | TokenBuffer g_token_back_buffer; 9 | 10 | ////////////////////////////////////////////////////////////////////////// 11 | 12 | void snapshot() 13 | { 14 | long lock_count = g_token_buffer.lock_and_get_size(); 15 | long num_tokens = std::min(long(MAX_PROFILE_TOKENS), lock_count); 16 | memcpy(&g_token_back_buffer, &g_token_buffer, sizeof(g_token_buffer)); 17 | g_token_buffer.flush(); 18 | g_token_back_buffer.pos.set(num_tokens); 19 | } 20 | 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /insight/source/insight_backend.h: -------------------------------------------------------------------------------- 1 | #ifndef __INSIGHT_BACKEND_H__ 2 | #define __INSIGHT_BACKEND_H__ 3 | 4 | #include "insight/redist/insight.h" 5 | #include "insight_utils.h" 6 | 7 | namespace InsightBackend 8 | { 9 | const size_t MAX_PROFILE_TOKENS = 16384; 10 | typedef InsightUtils::Buffer TokenBuffer; 11 | 12 | extern TokenBuffer g_token_buffer; 13 | extern TokenBuffer g_token_back_buffer; 14 | 15 | extern void snapshot(); 16 | } 17 | 18 | #endif // __INSIGHT_BACKEND_H__ 19 | 20 | -------------------------------------------------------------------------------- /insight/source/insight_background_png.h: -------------------------------------------------------------------------------- 1 | #ifndef __INSIGHT_BACKGROUND_PNG_H__ 2 | #define __INSIGHT_BACKGROUND_PNG_H__ 3 | static const unsigned char g_background_png[974] = { 4 | 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 5 | 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x08, 0x03, 0x00, 0x00, 0x00, 0xD7, 0x12, 0x1F, 6 | 0x7A, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xAE, 0xCE, 0x1C, 0xE9, 0x00, 0x00, 7 | 0x00, 0x04, 0x67, 0x41, 0x4D, 0x41, 0x00, 0x00, 0xB1, 0x8F, 0x0B, 0xFC, 0x61, 0x05, 0x00, 0x00, 8 | 0x03, 0x00, 0x50, 0x4C, 0x54, 0x45, 0x08, 0x08, 0x0A, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x11, 0x10, 9 | 0x10, 0x12, 0x11, 0x11, 0x13, 0x12, 0x12, 0x14, 0x1B, 0x1B, 0x1D, 0x22, 0x21, 0x24, 0x26, 0x26, 10 | 0x29, 0x30, 0x2F, 0x33, 0x33, 0x33, 0x37, 0x35, 0x35, 0x39, 0x37, 0x37, 0x3B, 0x45, 0x45, 0x47, 11 | 0x47, 0x47, 0x48, 0x4A, 0x4A, 0x4B, 0x4B, 0x4B, 0x4D, 0x53, 0x53, 0x55, 0x54, 0x54, 0x56, 0x55, 12 | 0x55, 0x57, 0x56, 0x56, 0x58, 0x57, 0x57, 0x59, 0x59, 0x59, 0x5B, 0x5D, 0x5C, 0x5F, 0x5E, 0x5E, 13 | 0x60, 0x60, 0x60, 0x62, 0x61, 0x61, 0x63, 0x62, 0x62, 0x64, 0x65, 0x65, 0x67, 0x00, 0x00, 0x00, 14 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 15 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 16 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 17 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 18 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 19 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 20 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 22 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 29 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 31 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 35 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 36 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 54 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 55 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 56 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCB, 0xC6, 0x23, 0x82, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 57 | 0x59, 0x73, 0x00, 0x00, 0x0E, 0xC3, 0x00, 0x00, 0x0E, 0xC3, 0x01, 0xC7, 0x6F, 0xA8, 0x64, 0x00, 58 | 0x00, 0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6F, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x00, 59 | 0x50, 0x61, 0x69, 0x6E, 0x74, 0x2E, 0x4E, 0x45, 0x54, 0x20, 0x76, 0x33, 0x2E, 0x35, 0x2E, 0x31, 60 | 0x4E, 0xE7, 0x38, 0xF9, 0x00, 0x00, 0x00, 0x32, 0x49, 0x44, 0x41, 0x54, 0x18, 0x57, 0x63, 0x90, 61 | 0x96, 0x92, 0xE4, 0xE1, 0xE2, 0x64, 0x10, 0x11, 0x12, 0x66, 0x63, 0x67, 0x63, 0xE0, 0xE7, 0xE7, 62 | 0x63, 0x62, 0x66, 0x61, 0xE0, 0xE2, 0xE6, 0x96, 0x91, 0x10, 0x67, 0x60, 0xE7, 0xE0, 0x10, 0x15, 63 | 0x14, 0x63, 0x60, 0x65, 0x64, 0xE0, 0xE3, 0x15, 0x00, 0x00, 0x2A, 0x6D, 0x01, 0xDE, 0xD9, 0x23, 64 | 0x2A, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82 65 | }; 66 | #endif // __INSIGHT_BACKGROUND_PNG_H__ 67 | 68 | -------------------------------------------------------------------------------- /insight/source/insight_bar_png.h: -------------------------------------------------------------------------------- 1 | #ifndef __INSIGHT_BAR_PNG_H__ 2 | #define __INSIGHT_BAR_PNG_H__ 3 | static const unsigned char g_bar_png[1072] = { 4 | 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 5 | 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x08, 0x03, 0x00, 0x00, 0x00, 0x28, 0x2D, 0x0F, 6 | 0x53, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xAE, 0xCE, 0x1C, 0xE9, 0x00, 0x00, 7 | 0x00, 0x04, 0x67, 0x41, 0x4D, 0x41, 0x00, 0x00, 0xB1, 0x8F, 0x0B, 0xFC, 0x61, 0x05, 0x00, 0x00, 8 | 0x03, 0x00, 0x50, 0x4C, 0x54, 0x45, 0xAB, 0xAB, 0xAB, 0xB0, 0xB0, 0xB0, 0xB5, 0xB5, 0xB5, 0xB6, 9 | 0xB6, 0xB6, 0xB9, 0xB9, 0xB9, 0xBB, 0xBB, 0xBB, 0xBD, 0xBD, 0xBD, 0xBF, 0xBF, 0xBF, 0xC0, 0xC0, 10 | 0xC0, 0xC2, 0xC2, 0xC2, 0xC3, 0xC3, 0xC3, 0xC4, 0xC4, 0xC4, 0xC5, 0xC5, 0xC5, 0xC7, 0xC7, 0xC7, 11 | 0xC9, 0xC9, 0xC9, 0xCA, 0xCA, 0xCA, 0xCB, 0xCB, 0xCB, 0xCD, 0xCD, 0xCD, 0xD0, 0xD0, 0xD0, 0xD2, 12 | 0xD2, 0xD2, 0xD3, 0xD3, 0xD3, 0xD4, 0xD4, 0xD4, 0xD5, 0xD5, 0xD5, 0xD7, 0xD7, 0xD7, 0xD9, 0xD9, 13 | 0xD9, 0xDA, 0xDA, 0xDA, 0xDE, 0xDE, 0xDE, 0xE0, 0xE0, 0xE0, 0xE1, 0xE1, 0xE1, 0xE2, 0xE2, 0xE2, 14 | 0xE5, 0xE5, 0xE5, 0xE8, 0xE8, 0xE8, 0xE9, 0xE9, 0xE9, 0xEA, 0xEA, 0xEA, 0xEF, 0xEF, 0xEF, 0xF1, 15 | 0xF1, 0xF1, 0xF5, 0xF5, 0xF5, 0xF8, 0xF8, 0xF8, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 16 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 17 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 18 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 19 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 20 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 22 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 29 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 31 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 35 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 36 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 54 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 55 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 56 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x5D, 0xD3, 0x8A, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 57 | 0x59, 0x73, 0x00, 0x00, 0x0E, 0xC3, 0x00, 0x00, 0x0E, 0xC3, 0x01, 0xC7, 0x6F, 0xA8, 0x64, 0x00, 58 | 0x00, 0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6F, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x00, 59 | 0x50, 0x61, 0x69, 0x6E, 0x74, 0x2E, 0x4E, 0x45, 0x54, 0x20, 0x76, 0x33, 0x2E, 0x35, 0x2E, 0x31, 60 | 0x4E, 0xE7, 0x38, 0xF9, 0x00, 0x00, 0x00, 0x94, 0x49, 0x44, 0x41, 0x54, 0x28, 0x53, 0x65, 0x8F, 61 | 0x49, 0x16, 0x83, 0x20, 0x10, 0x05, 0xDB, 0x01, 0x41, 0x44, 0x68, 0xDA, 0x09, 0x08, 0xA2, 0xA2, 62 | 0xE6, 0xFE, 0x47, 0xCC, 0x3E, 0xEC, 0xFF, 0xAB, 0x5F, 0x05, 0x50, 0xD5, 0x6D, 0x27, 0x7A, 0x39, 63 | 0xC8, 0x5E, 0x74, 0x6D, 0x5D, 0x41, 0xD5, 0x30, 0x2E, 0x47, 0x8D, 0x88, 0x7A, 0x94, 0x9C, 0x35, 64 | 0x50, 0x33, 0xA1, 0x8C, 0xA5, 0x69, 0x9E, 0xC8, 0x1A, 0x25, 0x18, 0xB4, 0x5C, 0x21, 0x2D, 0x9B, 65 | 0xF3, 0x6E, 0x5B, 0x08, 0x15, 0x87, 0x4E, 0x1A, 0x5A, 0x7D, 0x88, 0x7B, 0x0C, 0x7E, 0x25, 0x23, 66 | 0x41, 0x8C, 0x76, 0xF1, 0x9F, 0x74, 0x9C, 0x47, 0xFA, 0xF8, 0xC5, 0x8E, 0xD0, 0x6B, 0xDA, 0x42, 67 | 0xBA, 0xF2, 0x9D, 0xAF, 0x14, 0x36, 0xD2, 0x20, 0x71, 0x72, 0xF1, 0xC8, 0xCF, 0xFB, 0xE4, 0x23, 68 | 0xBA, 0x09, 0x61, 0xC0, 0xD9, 0xEF, 0xE7, 0xFD, 0x7E, 0xDF, 0xFB, 0xDC, 0xFD, 0x8C, 0xE5, 0xA2, 69 | 0x60, 0x14, 0x2F, 0x85, 0x47, 0x61, 0x5A, 0xB4, 0xFC, 0xD7, 0xFE, 0x00, 0x8D, 0xEF, 0x12, 0xD9, 70 | 0x71, 0xC5, 0x2D, 0xCA, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82 71 | }; 72 | #endif // __INSIGHT_BAR_PNG_H__ 73 | 74 | -------------------------------------------------------------------------------- /insight/source/insight_graph_d3d9.cpp: -------------------------------------------------------------------------------- 1 | #include "insight/redist/insight.h" 2 | #include "insight_graph_d3d9.h" 3 | #include "insight_background_png.h" 4 | #include "insight_bar_png.h" 5 | 6 | #include 7 | #include 8 | 9 | namespace 10 | { 11 | inline bool check_result( HRESULT hr ) 12 | { 13 | if( FAILED(hr) && hr!=D3DERR_DEVICELOST && hr!=D3DERR_DEVICENOTRESET ) 14 | { 15 | //TODO: Show some kind of error message 16 | return false; 17 | } 18 | else 19 | { 20 | return true; 21 | } 22 | } 23 | } 24 | 25 | namespace InsightGui 26 | { 27 | 28 | const DWORD g_fvf = D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1; 29 | const float g_bar_height = 100.0f; 30 | const float g_thread_height = g_bar_height + 10.0f; 31 | const float g_stack_height = g_thread_height/10.0f; 32 | 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | DWORD ColourManager::calculate_colour(const char* str) 36 | { 37 | if( m_last_string == str ) 38 | { 39 | return m_last_colour; 40 | } 41 | else 42 | { 43 | // this is a "one-at-a-time" hash 44 | DWORD hash = 0x811c9dc5; 45 | for( size_t i=0; str[i]!=0 && i<128; ++i ) 46 | { 47 | hash += str[i]; 48 | hash += hash<<10; 49 | hash ^= hash>>6; 50 | } 51 | hash += hash<<3; 52 | hash ^= hash>>11; 53 | hash += hash<<15; 54 | 55 | DWORD colour = 0xFF000000 | hash; 56 | 57 | m_last_string = str; 58 | m_last_colour = colour; 59 | 60 | return colour; 61 | } 62 | } 63 | 64 | ////////////////////////////////////////////////////////////////////////// 65 | 66 | GraphD3D9::GraphD3D9() 67 | : m_d3d9(NULL) 68 | , m_device(NULL) 69 | , m_device_lost(false) 70 | , m_rect() 71 | , m_zoom(500) 72 | , m_pos_x(250) 73 | , m_pos_y(0) 74 | , m_cursor_x(0) 75 | , m_cursor_y(0) 76 | , m_selection_a(0) 77 | , m_selection_b(0) 78 | , m_min_time(0) 79 | , m_max_time(1) 80 | , m_cycles_per_ms(1) 81 | , m_max_thread_idx(0) 82 | , m_selected(NULL) 83 | { 84 | m_rect.left = 0; 85 | m_rect.top = 0; 86 | m_rect.right = 1; 87 | m_rect.bottom = 1; 88 | D3DXMatrixIdentity(&m_transform); 89 | D3DXMatrixIdentity(&m_transform_inverse); 90 | D3DXMatrixIdentity(&m_transform_bg); 91 | } 92 | 93 | GraphD3D9::~GraphD3D9() 94 | { 95 | 96 | } 97 | 98 | void GraphD3D9::render() 99 | { 100 | // attempt to fix lost device and quit if was not able 101 | bool ok_to_render = handle_device_lost(); 102 | if( ok_to_render == false ) 103 | { 104 | return; 105 | } 106 | 107 | update_viewport(); 108 | 109 | draw_temporary_objects(); 110 | 111 | check_result(m_device->BeginScene()); 112 | 113 | check_result(m_device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xFF111111, 1.0f, 0)); 114 | 115 | size_t vertex_size = sizeof(Vertex); 116 | 117 | //draw background 118 | check_result(m_device->SetTransform(D3DTS_PROJECTION, &m_transform_bg)); 119 | check_result(m_device->SetTexture(0, m_tex_background)); 120 | if( m_bg_vertices.size()/3 > 0 ) 121 | { 122 | check_result(m_device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, m_bg_vertices.size()/3, m_bg_vertices.data, vertex_size)); 123 | } 124 | 125 | check_result(m_device->SetTransform(D3DTS_PROJECTION, &m_transform)); 126 | // draw bars 127 | check_result(m_device->SetTexture(0, m_tex_bar)); 128 | if( m_bar_vertices.size()/3 > 0 ) 129 | { 130 | check_result(m_device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, m_bar_vertices.size()/3, m_bar_vertices.data, vertex_size)); 131 | } 132 | 133 | // draw selection 134 | if( m_tmp_vertices.size()/3 > 0 ) 135 | { 136 | check_result(m_device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, m_tmp_vertices.size()/3, m_tmp_vertices.data, vertex_size)); 137 | } 138 | 139 | check_result(m_device->EndScene()); 140 | 141 | HRESULT hr = m_device->Present(&m_rect, &m_rect, 0, 0); 142 | 143 | if( hr == D3DERR_DEVICELOST ) 144 | { 145 | m_device_lost = true; 146 | } 147 | else 148 | { 149 | check_result(hr); 150 | } 151 | } 152 | 153 | void GraphD3D9::resize( RECT rect ) 154 | { 155 | m_rect = rect; 156 | } 157 | 158 | void GraphD3D9::init( HWND hwnd ) 159 | { 160 | m_hwnd = hwnd; 161 | m_d3d9 = Direct3DCreate9( D3D_SDK_VERSION ); 162 | 163 | D3DDISPLAYMODE dm; 164 | ZeroMemory(&dm, sizeof(dm)); 165 | 166 | D3DPRESENT_PARAMETERS pp; 167 | ZeroMemory(&pp, sizeof(pp)); 168 | 169 | DWORD adapter = D3DADAPTER_DEFAULT; 170 | D3DDEVTYPE type = D3DDEVTYPE_HAL; 171 | 172 | DWORD bb_max_width = 2048; 173 | DWORD bb_max_height = 2048; 174 | 175 | check_result( m_d3d9->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &dm ) ); 176 | 177 | pp.BackBufferWidth = bb_max_width; 178 | pp.BackBufferHeight = bb_max_height; 179 | pp.BackBufferFormat = dm.Format; 180 | pp.BackBufferCount = 1; 181 | 182 | pp.MultiSampleType = D3DMULTISAMPLE_NONE; 183 | pp.MultiSampleQuality = 0; 184 | 185 | pp.SwapEffect = D3DSWAPEFFECT_COPY; 186 | pp.hDeviceWindow = hwnd; 187 | pp.Windowed = TRUE; 188 | pp.EnableAutoDepthStencil = TRUE; 189 | pp.AutoDepthStencilFormat = D3DFMT_D24S8; 190 | pp.Flags = 0; 191 | 192 | pp.FullScreen_RefreshRateInHz = 0; 193 | pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; 194 | 195 | memcpy(&m_present_paramseters, &pp, sizeof(m_present_paramseters)); 196 | 197 | DWORD flags = D3DCREATE_HARDWARE_VERTEXPROCESSING; 198 | 199 | check_result(m_d3d9->CreateDevice(adapter, type, hwnd, flags, &pp, &m_device)); 200 | 201 | check_result(D3DXCreateTextureFromFileInMemoryEx( 202 | m_device, g_background_png, sizeof(g_background_png), 203 | D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, 204 | D3DX_DEFAULT, D3DX_DEFAULT, 0, 0, 0, &m_tex_background)); 205 | 206 | check_result(D3DXCreateTextureFromFileInMemoryEx( 207 | m_device, g_bar_png, sizeof(g_bar_png), 208 | D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, 209 | D3DX_DEFAULT, D3DX_DEFAULT, 0, 0, 0, &m_tex_bar)); 210 | 211 | set_render_states(); 212 | } 213 | 214 | void GraphD3D9::destroy() 215 | { 216 | if(m_tex_background) m_tex_background->Release(); 217 | if(m_tex_bar) m_tex_bar->Release(); 218 | if(m_device) m_device->Release(); 219 | if(m_d3d9) m_d3d9->Release(); 220 | } 221 | 222 | void GraphD3D9::draw_rect( float x1, float y1, float x2, float y2, DWORD colour ) 223 | { 224 | m_bar_vertices.push(Vertex(x1, y1, 0.0f, 0, 0, colour)); 225 | m_bar_vertices.push(Vertex(x2, y1, 0.0f, 1, 0, colour)); 226 | m_bar_vertices.push(Vertex(x2, y2, 0.0f, 1, 1, colour)); 227 | 228 | m_bar_vertices.push(Vertex(x1, y1, 0.0f, 0, 0, colour)); 229 | m_bar_vertices.push(Vertex(x2, y2, 0.0f, 1, 1, colour)); 230 | m_bar_vertices.push(Vertex(x1, y2, 0.0f, 0, 1, colour)); 231 | } 232 | 233 | void GraphD3D9::zoom( float delta_z ) 234 | { 235 | m_zoom -= delta_z * m_zoom * 0.001f; 236 | 237 | if( m_zoom < 0.01f ) m_zoom = 0.01f; 238 | if( m_zoom > 2000.0f ) m_zoom = 2000.0f; 239 | } 240 | 241 | bool GraphD3D9::add_bar( size_t thread_idx, size_t depth, const Insight::Token& t ) 242 | { 243 | m_max_thread_idx = std::max(thread_idx, m_max_thread_idx); 244 | 245 | float start_ms = float(double(t.time_enter - m_min_time) / double(m_cycles_per_ms)); 246 | float stop_ms = float(double(t.time_exit - m_min_time) / double(m_cycles_per_ms)); 247 | 248 | float pos_x1 = start_ms; 249 | float pos_x2 = stop_ms; 250 | 251 | float pos_y1 = float(thread_idx) * g_thread_height + float(depth)*g_stack_height; 252 | float pos_y2 = (pos_y1 + g_bar_height) - float(depth)*g_stack_height; 253 | 254 | DWORD colour = m_colourman.calculate_colour(t.name); 255 | 256 | draw_rect(pos_x1, pos_y1, pos_x2, pos_y2, colour); 257 | 258 | BarInfo bi; 259 | bi.x1 = pos_x1; 260 | bi.x2 = pos_x2; 261 | bi.y1 = pos_y1; 262 | bi.y2 = pos_y2; 263 | bi.thread_idx = thread_idx; 264 | bi.name = t.name; 265 | 266 | m_bars.push(bi); 267 | 268 | return true; 269 | } 270 | 271 | void GraphD3D9::reset() 272 | { 273 | m_bars.reset(); 274 | 275 | m_bar_vertices.reset(); 276 | 277 | m_max_thread_idx = 0; 278 | 279 | m_selected = NULL; 280 | m_tmp_vertices.reset(); 281 | 282 | m_selection_a = 0; 283 | m_selection_b = 0; 284 | } 285 | 286 | void GraphD3D9::set_timeframe( Insight::cycle_metric min_time, Insight::cycle_metric max_time, Insight::cycle_metric cycles_per_ms ) 287 | { 288 | m_min_time = min_time; 289 | m_max_time = max_time; 290 | m_cycles_per_ms = cycles_per_ms; 291 | } 292 | 293 | void GraphD3D9::drag( long x ) 294 | { 295 | float width = float(m_rect.right - m_rect.left); 296 | m_pos_x -= float(x) * (m_zoom/width); 297 | if( m_pos_x < 0 ) m_pos_x = 0; 298 | } 299 | 300 | void GraphD3D9::select( long a, long b ) 301 | { 302 | float unused; 303 | client_to_time(a,0,m_selection_a,unused); 304 | client_to_time(b,0,m_selection_b,unused); 305 | } 306 | 307 | 308 | void GraphD3D9::update_viewport() 309 | { 310 | D3DVIEWPORT9 vp; 311 | 312 | vp.X = m_rect.left; 313 | vp.Y = m_rect.top; 314 | vp.MinZ = 0; 315 | vp.MaxZ = 1; 316 | vp.Width = std::max(LONG(1), std::min(LONG(2048),m_rect.right-m_rect.left) ); 317 | vp.Height = std::max(LONG(1), std::min(LONG(2048),m_rect.bottom-m_rect.top) ); 318 | 319 | check_result(m_device->SetViewport(&vp)); 320 | 321 | D3DXMATRIXA16 mat_tmp; 322 | 323 | D3DXMatrixIdentity(&m_transform); 324 | D3DXMatrixIdentity(&mat_tmp); 325 | 326 | D3DXMatrixScaling(&m_transform, 1.0f, -1.0f, 1.0f); 327 | D3DXMatrixTranslation(&mat_tmp, -0.5f, +0.5f, 0.0f); 328 | D3DXMatrixMultiply(&m_transform, &m_transform, &mat_tmp); 329 | 330 | float x1 = m_pos_x - m_zoom/2; 331 | float x2 = m_pos_x + m_zoom/2; 332 | float y1 = 0; 333 | float y2 = -g_thread_height*float(m_max_thread_idx+1); 334 | 335 | D3DXMatrixOrthoOffCenterLH(&mat_tmp, x1, x2, y2, y1, vp.MinZ, vp.MaxZ); 336 | D3DXMatrixMultiply(&m_transform, &m_transform, &mat_tmp); 337 | 338 | D3DXMatrixInverse(&m_transform_inverse, NULL, &m_transform); 339 | 340 | m_bg_vertices.reset(); 341 | 342 | float u = float(vp.Width)/6; 343 | float v = float(vp.Height)/6; 344 | 345 | float bx1 = -1 - 0.5f/u; 346 | float bx2 = 1 - 0.5f/u; 347 | float by1 = 1 + 0.5f/v; 348 | float by2 = -1 + 0.5f/v; 349 | 350 | DWORD bg_col = 0xFF808080; 351 | 352 | m_bg_vertices.push(Vertex(bx1, by1, 0.0f, 0, 0, bg_col)); 353 | m_bg_vertices.push(Vertex(bx2, by1, 0.0f, u, 0, bg_col)); 354 | m_bg_vertices.push(Vertex(bx2, by2, 0.0f, u, v, bg_col)); 355 | m_bg_vertices.push(Vertex(bx1, by1, 0.0f, 0, 0, bg_col)); 356 | m_bg_vertices.push(Vertex(bx2, by2, 0.0f, u, v, bg_col)); 357 | m_bg_vertices.push(Vertex(bx1, by2, 0.0f, 0, v, bg_col)); 358 | 359 | } 360 | 361 | void GraphD3D9::set_cursor( long cx, long cy ) 362 | { 363 | float w = float(m_rect.right-m_rect.left); 364 | float h = float(m_rect.bottom-m_rect.top); 365 | 366 | float x = (float(cx) / w)*2-1; 367 | float y = (float(cy) / h)*2-1; 368 | 369 | D3DXVECTOR4 v1(x,-y,0,1); 370 | D3DXVECTOR4 v2; 371 | 372 | D3DXVec4Transform(&v2,&v1,&m_transform_inverse); 373 | 374 | m_cursor_x = v2.x; 375 | m_cursor_y = v2.y; 376 | 377 | m_selected = NULL; 378 | for(size_t i=0; i= bi.x1 && m_cursor_x <= bi.x2 && 382 | m_cursor_y >= bi.y1 && m_cursor_y <= bi.y2 ) 383 | { 384 | m_selected = &bi; 385 | } 386 | } 387 | } 388 | 389 | GraphD3D9::BarInfo* GraphD3D9::selected() 390 | { 391 | return m_selected; 392 | } 393 | 394 | bool GraphD3D9::handle_device_lost() 395 | { 396 | if( m_device_lost ) 397 | { 398 | HRESULT hr = m_device->TestCooperativeLevel(); 399 | if( hr == D3D_OK ) 400 | { 401 | m_device_lost = false; 402 | return true; 403 | } 404 | else if( hr == D3DERR_DEVICENOTRESET) 405 | { 406 | if( m_device->Reset(&m_present_paramseters) == D3D_OK ) 407 | { 408 | set_render_states(); 409 | m_device_lost = false; 410 | return true; 411 | } 412 | } 413 | return false; 414 | } 415 | else 416 | { 417 | return true; 418 | } 419 | } 420 | 421 | void GraphD3D9::set_render_states() 422 | { 423 | check_result(m_device->SetRenderState(D3DRS_LIGHTING, FALSE)); 424 | check_result(m_device->SetRenderState(D3DRS_ZENABLE, FALSE)); 425 | check_result(m_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE)); 426 | 427 | check_result(m_device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE)); 428 | check_result(m_device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA)); 429 | check_result(m_device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA)); 430 | 431 | check_result(m_device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE)); 432 | check_result(m_device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE)); 433 | check_result(m_device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE)); 434 | 435 | check_result(m_device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE)); 436 | check_result(m_device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE )); 437 | check_result(m_device->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE )); 438 | 439 | check_result(m_device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR)); 440 | check_result(m_device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR)); 441 | check_result(m_device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR)); 442 | 443 | check_result(m_device->SetFVF(g_fvf)); 444 | } 445 | 446 | void GraphD3D9::draw_temporary_objects() 447 | { 448 | m_tmp_vertices.reset(); 449 | if( m_selected ) 450 | { 451 | float x1 = m_selected->x1; 452 | float x2 = m_selected->x2; 453 | float y1 = m_selected->y1; 454 | float y2 = m_selected->y2; 455 | 456 | m_tmp_vertices.push(Vertex(x1, y1, 0.0f, 0, 0, 0x88FFFFFF)); 457 | m_tmp_vertices.push(Vertex(x2, y1, 0.0f, 1, 0, 0x88FFFFFF)); 458 | m_tmp_vertices.push(Vertex(x2, y2, 0.0f, 1, 1, 0x88FFFFFF)); 459 | 460 | m_tmp_vertices.push(Vertex(x1, y1, 0.0f, 0, 0, 0x88FFFFFF)); 461 | m_tmp_vertices.push(Vertex(x2, y2, 0.0f, 1, 1, 0x88FFFFFF)); 462 | m_tmp_vertices.push(Vertex(x1, y2, 0.0f, 0, 1, 0x88FFFFFF)); 463 | } 464 | 465 | if( m_selection_a!=m_selection_b ) 466 | { 467 | float x1 = m_selection_a; 468 | float x2 = m_selection_b; 469 | float y1 = 0; 470 | float y2 = 10000; 471 | 472 | DWORD col = 0x60FFFFFF; 473 | 474 | m_tmp_vertices.push(Vertex(x1, y1, 0.0f, 0, 0, col)); 475 | m_tmp_vertices.push(Vertex(x2, y1, 0.0f, 1, 0, col)); 476 | m_tmp_vertices.push(Vertex(x2, y2, 0.0f, 1, 1, col)); 477 | 478 | m_tmp_vertices.push(Vertex(x1, y1, 0.0f, 0, 0, col)); 479 | m_tmp_vertices.push(Vertex(x2, y2, 0.0f, 1, 1, col)); 480 | m_tmp_vertices.push(Vertex(x1, y2, 0.0f, 0, 1, col)); 481 | } 482 | } 483 | 484 | void GraphD3D9::client_to_time( long cx, long cy, float& tx, float& ty ) 485 | { 486 | float w = float(m_rect.right-m_rect.left); 487 | float h = float(m_rect.bottom-m_rect.top); 488 | 489 | float x = (float(cx) / w)*2-1; 490 | float y = (float(cy) / h)*2-1; 491 | 492 | D3DXVECTOR4 v1(x,-y,0,1); 493 | D3DXVECTOR4 v2; 494 | 495 | D3DXVec4Transform(&v2,&v1,&m_transform_inverse); 496 | 497 | tx = v2.x; 498 | ty = v2.y; 499 | } 500 | 501 | float GraphD3D9::selection_length() 502 | { 503 | return abs(m_selection_b - m_selection_a); 504 | } 505 | } 506 | 507 | -------------------------------------------------------------------------------- /insight/source/insight_graph_d3d9.h: -------------------------------------------------------------------------------- 1 | #ifndef __INSIGHT_GRAPH_D3D9_H__ 2 | #define __INSIGHT_GRAPH_D3D9_H__ 3 | 4 | #define NOMINMAX 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "insight/redist/insight.h" 13 | #include "insight_utils.h" 14 | 15 | namespace InsightGui 16 | { 17 | 18 | class ColourManager 19 | { 20 | public: 21 | ColourManager() 22 | : m_last_colour(0) 23 | , m_last_string(NULL) 24 | {} 25 | 26 | DWORD calculate_colour(const char* str); 27 | 28 | private: 29 | 30 | DWORD m_last_colour; 31 | const char* m_last_string; 32 | }; 33 | 34 | class GraphD3D9 35 | { 36 | public: 37 | 38 | struct BarInfo 39 | { 40 | const char* name; 41 | float x1,x2,y1,y2; 42 | size_t thread_idx; 43 | }; 44 | 45 | struct Vertex 46 | { 47 | Vertex(){}; 48 | Vertex(float _x, float _y, float _z, float _u, float _v, DWORD _colour) 49 | : x(_x), y(_y), z(_z), u(_u), v(_v), colour(_colour) 50 | {} 51 | float x,y,z; 52 | DWORD colour; 53 | float u,v; 54 | }; 55 | 56 | public: 57 | 58 | GraphD3D9(); 59 | ~GraphD3D9(); 60 | 61 | void init(HWND hwnd); 62 | void destroy(); 63 | bool handle_device_lost(); 64 | void set_render_states(); 65 | 66 | void resize(RECT rect); 67 | void render(); 68 | 69 | void draw_rect(float x1, float y1, float x2, float y2, DWORD colour); 70 | 71 | void set_timeframe(Insight::cycle_metric min_time, Insight::cycle_metric max_time, Insight::cycle_metric cycles_per_ms); 72 | 73 | void zoom(float delta_z); 74 | void drag(long x); 75 | void select(long a, long b); 76 | void set_cursor(long cx, long cy); 77 | 78 | void reset(); 79 | bool add_bar(size_t thread_idx, size_t depth, const Insight::Token& t); 80 | 81 | void update_viewport(); 82 | 83 | BarInfo* selected(); 84 | float selection_length(); 85 | 86 | void draw_temporary_objects(); 87 | 88 | void client_to_time(long cx, long cy, float& tx, float& ty); 89 | 90 | private: 91 | 92 | IDirect3D9* m_d3d9; 93 | IDirect3DDevice9* m_device; 94 | IDirect3DTexture9* m_tex_background; 95 | IDirect3DTexture9* m_tex_bar; 96 | D3DPRESENT_PARAMETERS m_present_paramseters; 97 | bool m_device_lost; 98 | 99 | RECT m_rect; 100 | HWND m_hwnd; 101 | 102 | float m_zoom; 103 | 104 | float m_pos_x; 105 | float m_pos_y; 106 | 107 | Insight::cycle_metric m_min_time; 108 | Insight::cycle_metric m_max_time; 109 | Insight::cycle_metric m_cycles_per_ms; 110 | 111 | static const size_t MAX_BARS=16384; 112 | InsightUtils::Stack m_bars; 113 | InsightUtils::Stack m_bar_vertices; 114 | InsightUtils::Stack m_tmp_vertices; 115 | InsightUtils::Stack m_bg_vertices; 116 | 117 | size_t m_max_thread_idx; 118 | 119 | float m_cursor_x; 120 | float m_cursor_y; 121 | float m_selection_a; 122 | float m_selection_b; 123 | 124 | BarInfo* m_selected; 125 | 126 | D3DXMATRIX m_transform_bg; 127 | D3DXMATRIX m_transform; 128 | D3DXMATRIX m_transform_inverse; 129 | 130 | ColourManager m_colourman; 131 | }; 132 | 133 | } 134 | #endif // __INSIGHT_GRAPH_D3D9_H__ 135 | 136 | -------------------------------------------------------------------------------- /insight/source/insight_gui.cpp: -------------------------------------------------------------------------------- 1 | #include "insight_gui.h" 2 | 3 | #include "insight/redist/insight.h" 4 | #include "insight_graph_d3d9.h" 5 | #include "insight_backend.h" 6 | 7 | #define NOMINMAX 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | #ifndef GET_WHEEL_DELTA_WPARAM 15 | #define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam)) 16 | #endif //GET_WHEEL_DELTA_WPARAM 17 | 18 | #ifndef WM_MOUSEWHEEL 19 | #define WM_MOUSEWHEEL 0x020A 20 | #endif //WM_MOUSEWHEEL 21 | 22 | namespace 23 | { 24 | const size_t MAX_REPORT_TEXT = 2048; 25 | 26 | template 27 | class Text 28 | { 29 | public: 30 | Text() 31 | : m_pos(0) 32 | { 33 | reset(); 34 | } 35 | void reset() 36 | { 37 | m_pos = 0; 38 | memset(m_buffer, 0, SIZE); 39 | } 40 | 41 | void print(const char* str, ...) 42 | { 43 | char buf[1024]; 44 | 45 | va_list ap; 46 | va_start(ap, str); 47 | int len = vsprintf_s(buf, str, ap); 48 | va_end(ap); 49 | 50 | if(m_pos + len < MAX_REPORT_TEXT) 51 | { 52 | memcpy(m_buffer+m_pos, buf, len); 53 | m_pos += len; 54 | } 55 | } 56 | 57 | const char* buffer() const { return m_buffer; } 58 | const size_t length() const { return m_pos; } 59 | 60 | void draw(HDC hdc, RECT rt) 61 | { 62 | FillRect(hdc, &rt, (HBRUSH) (COLOR_WINDOW+1)); 63 | 64 | HGDIOBJ hfnt, hfnt_old; 65 | hfnt = GetStockObject(ANSI_FIXED_FONT); 66 | hfnt_old = SelectObject(hdc, hfnt); 67 | DrawText(hdc, buffer(), length(), &rt, DT_LEFT|DT_EXPANDTABS); 68 | SelectObject(hdc, hfnt_old); 69 | } 70 | 71 | private: 72 | char m_buffer[SIZE]; 73 | size_t m_pos; 74 | }; 75 | 76 | bool g_should_exit = false; 77 | bool g_asynchronous = false; 78 | std::vector g_temporary_strings; 79 | HANDLE g_thread = 0; 80 | Text g_text; 81 | 82 | InsightGui::GraphD3D9 g_graph; 83 | HWND g_hwnd; 84 | 85 | 86 | bool g_dragging; 87 | bool g_selecting; 88 | long g_mouse_down_x; 89 | long g_mouse_down_y; 90 | long g_selection_a; 91 | long g_selection_b; 92 | bool g_paused; 93 | bool g_start_minimized; 94 | 95 | Insight::cycle_metric g_cycles_per_ms = 1; 96 | 97 | ////////////////////////////////////////////////////////////////////////// 98 | 99 | float cycles_to_ms(Insight::cycle_metric cycles) 100 | { 101 | float res = float (double(cycles) / double(g_cycles_per_ms)); 102 | return res; 103 | } 104 | 105 | double get_time_ms() 106 | { 107 | LARGE_INTEGER freq; 108 | LARGE_INTEGER time; 109 | 110 | QueryPerformanceFrequency(&freq); 111 | QueryPerformanceCounter(&time); 112 | 113 | double result = double(1000*time.QuadPart) / double(freq.QuadPart); 114 | 115 | return result; 116 | } 117 | 118 | void update_timing() 119 | { 120 | double curr_time = get_time_ms(); 121 | static double s_prev_time = curr_time; 122 | double elapsed_time = curr_time-s_prev_time; 123 | 124 | Insight::cycle_metric curr_cycles = __rdtsc(); 125 | static Insight::cycle_metric s_prev_cycles = curr_cycles; 126 | Insight::cycle_metric elapsed_cycles = curr_cycles - s_prev_cycles; 127 | 128 | static double time_threshold = 0; 129 | 130 | if( elapsed_time > time_threshold ) // recalculate cycles per second approximately every 5 seconds 131 | { 132 | g_cycles_per_ms = Insight::cycle_metric(elapsed_cycles / elapsed_time); 133 | s_prev_cycles = curr_cycles; 134 | s_prev_time = curr_time; 135 | 136 | if( time_threshold < 60000 ) 137 | { 138 | time_threshold = time_threshold*1.1 + 1; 139 | } 140 | } 141 | } 142 | 143 | 144 | struct TokenSorter 145 | { 146 | bool operator()(const Insight::Token& a, const Insight::Token& b) 147 | { 148 | if( a.thread_id == b.thread_id ) 149 | { 150 | return a.time_enter < b.time_enter; 151 | } 152 | else 153 | { 154 | return a.thread_id < b.thread_id; 155 | } 156 | } 157 | }; 158 | 159 | 160 | void build_report() 161 | { 162 | long num_tokens = InsightBackend::g_token_back_buffer.pos.val; 163 | 164 | if( num_tokens ) 165 | { 166 | std::sort(&InsightBackend::g_token_back_buffer.data[0], &InsightBackend::g_token_back_buffer.data[num_tokens], TokenSorter()); 167 | } 168 | 169 | size_t thread_idx = size_t(-1); 170 | unsigned long curr_thread = unsigned long(-1); 171 | 172 | InsightUtils::Stack call_stack; 173 | 174 | Insight::cycle_metric min_time = Insight::cycle_metric(-1); 175 | Insight::cycle_metric max_time = 0; 176 | for( long i=0; i max_time ) max_time = t.time_exit; 181 | } 182 | g_graph.set_timeframe(min_time, max_time, g_cycles_per_ms); 183 | 184 | for( long i=0; i call_stack.peek().time_exit ) 196 | { 197 | call_stack.pop(); 198 | } 199 | 200 | if( call_stack.size()==0 || t.time_exit < call_stack.peek().time_exit ) 201 | { 202 | call_stack.push(t); 203 | } 204 | 205 | g_graph.add_bar(thread_idx, call_stack.size()-1, t); 206 | } 207 | } 208 | 209 | ////////////////////////////////////////////////////////////////////////// 210 | 211 | LRESULT APIENTRY wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) 212 | { 213 | HDC hdc; 214 | PAINTSTRUCT ps; 215 | RECT client_rect; 216 | 217 | GetClientRect(hwnd, &client_rect); 218 | 219 | RECT text_rect = client_rect; 220 | RECT graph_rect = client_rect; 221 | 222 | graph_rect.bottom = client_rect.bottom - 40; 223 | text_rect.top = graph_rect.bottom; 224 | 225 | bool active = g_hwnd != GetForegroundWindow(); 226 | 227 | switch(msg) 228 | { 229 | case WM_CREATE: 230 | SetTimer(hwnd, WM_TIMER, 1000, NULL); 231 | g_graph.init(hwnd); 232 | return 0; 233 | 234 | case WM_PAINT: 235 | { 236 | hdc = BeginPaint(hwnd, &ps); 237 | g_text.reset(); 238 | 239 | if( g_graph.selection_length()>0 ) 240 | { 241 | g_text.print("Range: %.4f ms\n", g_graph.selection_length()); 242 | } 243 | if( g_graph.selected() ) 244 | { 245 | g_text.print("Selected: %s\n", g_graph.selected()->name); 246 | float duration = g_graph.selected()->x2 - g_graph.selected()->x1; 247 | g_text.print("Duration: %.4f ms\n", duration); 248 | } 249 | if( active==false && g_paused==false ) 250 | { 251 | g_text.print("PAUSED. Change focus to another window to resume.\n"); 252 | } 253 | 254 | g_text.draw(hdc,text_rect); 255 | EndPaint (hwnd, &ps); 256 | 257 | g_graph.render(); 258 | } 259 | return 0; 260 | 261 | case WM_TIMER: 262 | if( active && g_paused==false ) 263 | { 264 | InsightBackend::snapshot(); 265 | 266 | update_timing(); 267 | g_graph.reset(); 268 | g_text.reset(); 269 | build_report(); 270 | } 271 | InvalidateRect(hwnd, &text_rect, false); 272 | return 0; 273 | 274 | case WM_SIZE: 275 | g_graph.resize(graph_rect); 276 | InvalidateRect(hwnd, NULL, false); 277 | return 0; 278 | 279 | case WM_MOUSEWHEEL: 280 | g_graph.zoom(GET_WHEEL_DELTA_WPARAM(wparam)); 281 | InvalidateRect(hwnd, &text_rect, false); 282 | return 0; 283 | 284 | case WM_MOUSEMOVE: 285 | if( g_selecting ) 286 | { 287 | g_selection_b = LOWORD(lparam); 288 | g_graph.select(g_selection_a, g_selection_b); 289 | } 290 | else if( g_dragging ) 291 | { 292 | g_graph.drag(LOWORD(lparam) - g_mouse_down_x); 293 | g_mouse_down_x = LOWORD(lparam); 294 | g_mouse_down_y = HIWORD(lparam); 295 | } 296 | g_graph.set_cursor(LOWORD(lparam), HIWORD(lparam)); 297 | InvalidateRect(hwnd, &text_rect, false); 298 | return 0; 299 | 300 | case WM_LBUTTONDOWN: 301 | g_dragging = true; 302 | g_mouse_down_x = LOWORD(lparam); 303 | g_mouse_down_y = HIWORD(lparam); 304 | return 0; 305 | 306 | case WM_RBUTTONDOWN: 307 | g_selecting = true; 308 | g_selection_a = LOWORD(lparam); 309 | g_selection_b = g_selection_a; 310 | return 0; 311 | 312 | case WM_LBUTTONUP: 313 | g_dragging = false; 314 | return 0; 315 | 316 | case WM_RBUTTONUP: 317 | g_selecting = false; 318 | g_graph.select(g_selection_a, g_selection_b); 319 | InvalidateRect(g_hwnd, 0, FALSE); 320 | return 0; 321 | 322 | case WM_CLOSE: 323 | TerminateProcess(GetCurrentProcess(), 0); 324 | return 0; 325 | 326 | case WM_DESTROY: 327 | g_graph.destroy(); 328 | return 0; 329 | 330 | default: 331 | return (LONG)DefWindowProc(hwnd, msg, wparam, lparam); 332 | } 333 | } 334 | 335 | void start_gui() 336 | { 337 | HINSTANCE hinst = GetModuleHandle(NULL); 338 | 339 | WNDCLASSEX wc; 340 | wc.cbSize = sizeof(WNDCLASSEX); 341 | wc.style = CS_DBLCLKS; 342 | wc.lpfnWndProc = wndproc; 343 | wc.cbClsExtra = 0; 344 | wc.cbWndExtra = 0; 345 | wc.hInstance = hinst; 346 | wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); 347 | wc.hCursor = LoadCursor (NULL, IDC_ARROW); 348 | wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); 349 | wc.lpszMenuName = NULL; 350 | wc.lpszClassName = "INSIGHTPROFILERWC"; 351 | wc.hIconSm = wc.hIcon; 352 | 353 | RegisterClassEx(&wc); 354 | 355 | DWORD window_style = WS_OVERLAPPEDWINDOW; 356 | 357 | g_hwnd = CreateWindow("INSIGHTPROFILERWC", "Insight", window_style, 10, 10, 800, 400, NULL, NULL, hinst, NULL); 358 | 359 | if( g_start_minimized ) 360 | { 361 | ShowWindow(g_hwnd, SW_SHOWNOACTIVATE|SW_SHOWMINIMIZED); 362 | } 363 | else 364 | { 365 | ShowWindow(g_hwnd, SW_SHOWNORMAL); 366 | } 367 | 368 | UpdateWindow(g_hwnd); 369 | } 370 | 371 | bool update_gui_window() 372 | { 373 | bool should_continue = true; 374 | MSG msg; 375 | while( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) 376 | { 377 | TranslateMessage(&msg); 378 | DispatchMessage(&msg); 379 | if( msg.message == WM_QUIT ) 380 | { 381 | should_continue = false; 382 | } 383 | } 384 | 385 | return should_continue; 386 | } 387 | 388 | DWORD WINAPI threadproc(void*) 389 | { 390 | start_gui(); 391 | bool should_continue = true; 392 | while(should_continue) 393 | { 394 | if( g_should_exit ) 395 | { 396 | DestroyWindow(g_hwnd); 397 | break; 398 | } 399 | else 400 | { 401 | should_continue = update_gui_window(); 402 | Sleep(1); 403 | } 404 | } 405 | return 0; 406 | } 407 | } 408 | 409 | namespace InsightGui 410 | { 411 | void initialize(bool asynchronous, bool start_minimized) 412 | { 413 | g_asynchronous = asynchronous; 414 | g_cycles_per_ms = __rdtsc() / Insight::cycle_metric(get_time_ms()); 415 | g_dragging = false; 416 | g_selecting = false; 417 | g_mouse_down_x = 0; 418 | g_mouse_down_y = 0; 419 | 420 | g_selection_a = 0; 421 | g_selection_b = 0; 422 | 423 | g_paused = false; 424 | 425 | g_start_minimized = start_minimized; 426 | 427 | if( g_asynchronous ) 428 | { 429 | g_thread = CreateThread(0, 0, threadproc, 0, 0, 0); 430 | } 431 | else 432 | { 433 | start_gui(); 434 | } 435 | 436 | } 437 | 438 | void terminate() 439 | { 440 | if( g_asynchronous ) 441 | { 442 | g_should_exit = true; 443 | WaitForSingleObject(g_thread, 10000); 444 | CloseHandle(g_thread); 445 | } 446 | else 447 | { 448 | DestroyWindow(g_hwnd); 449 | } 450 | for( size_t i=0; i 5 | 6 | namespace InsightUtils 7 | { 8 | struct AtomicInt 9 | { 10 | inline AtomicInt() : val(0) 11 | {} 12 | 13 | // returns current value 14 | inline long get() 15 | { 16 | return _InterlockedOr(&val, 0); 17 | } 18 | 19 | // sets value to x and returns old value 20 | inline long set(long x) 21 | { 22 | return _InterlockedExchange(&val, x); 23 | } 24 | 25 | // compare and swap 26 | inline long cas(long x, long c) 27 | { 28 | return _InterlockedCompareExchange(&val, x, c); 29 | } 30 | 31 | // increments value and returns old value 32 | inline long inc() 33 | { 34 | return _InterlockedIncrement(&val)-1; 35 | } 36 | 37 | // decrements value and returns old value 38 | inline long dec() 39 | { 40 | return _InterlockedDecrement(&val)+1; 41 | } 42 | 43 | volatile long val; 44 | }; 45 | 46 | ////////////////////////////////////////////////////////////////////////// 47 | 48 | template 49 | class Buffer 50 | { 51 | public: 52 | 53 | inline Buffer() 54 | { 55 | pos.set(0); 56 | } 57 | 58 | inline bool push(const T& v) 59 | { 60 | long idx = pos.inc(); 61 | if( idx < SIZE ) 62 | { 63 | data[idx] = v; 64 | return true; 65 | } 66 | else 67 | { 68 | pos.dec(); 69 | return false; 70 | } 71 | } 72 | 73 | inline long lock_and_get_size() 74 | { 75 | return pos.set(SIZE+1); 76 | } 77 | inline void flush() 78 | { 79 | pos.set(0); 80 | } 81 | 82 | T data[SIZE]; 83 | AtomicInt pos; 84 | 85 | }; 86 | 87 | ////////////////////////////////////////////////////////////////////////// 88 | 89 | template 90 | struct Stack 91 | { 92 | inline Stack() : pos(0) { } 93 | 94 | inline bool push(const T& v) 95 | { 96 | if( pos+1 < SIZE ) 97 | { 98 | data[pos] = v; 99 | ++pos; 100 | return true; 101 | } 102 | else 103 | { 104 | return false; 105 | } 106 | } 107 | inline bool pop(T& v) 108 | { 109 | if( pos > 0 ) 110 | { 111 | v = data[pos]; 112 | --pos; 113 | return true; 114 | } 115 | else 116 | { 117 | return false; 118 | } 119 | } 120 | inline bool pop() 121 | { 122 | if( pos > 0 ) 123 | { 124 | --pos; 125 | return true; 126 | } 127 | else 128 | { 129 | return false; 130 | } 131 | } 132 | 133 | inline const T& peek() const { return data[pos-1]; } 134 | inline size_t size() const { return pos; } 135 | inline size_t max_size() const { return SIZE; } 136 | inline void reset() { pos = 0; } 137 | 138 | inline bool ensure_size( size_t to_size ) 139 | { 140 | if( pos+1 < to_size ) 141 | { 142 | return true; 143 | } 144 | else if( to_size <= SIZE ) 145 | { 146 | pos = to_size; 147 | return true; 148 | } 149 | else 150 | { 151 | return false; 152 | } 153 | } 154 | 155 | inline const T& operator [] (size_t idx) const { return data[idx]; } 156 | inline T& operator [] (size_t idx) { return data[idx]; } 157 | 158 | T data[SIZE]; 159 | size_t pos; 160 | }; 161 | 162 | ////////////////////////////////////////////////////////////////////////// 163 | 164 | } 165 | #endif // __INSIGHT_UTILS_H__ 166 | 167 | -------------------------------------------------------------------------------- /scripts/generate_projects.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | premake4 vs2002 3 | premake4 vs2003 4 | premake4 vs2005 5 | premake4 vs2008 6 | premake4 vs2010 7 | -------------------------------------------------------------------------------- /scripts/premake4.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kayru/insightprofiler/a0a3ca90fd2f5a45023fcf32701b550aaa7384d8/scripts/premake4.exe -------------------------------------------------------------------------------- /scripts/premake4.lua: -------------------------------------------------------------------------------- 1 | solution "InsightProfiler" 2 | language "C++" 3 | configurations { "Release", "Debug" } 4 | platforms { "x32" } 5 | location ( "../build/" .. _ACTION ) 6 | flags {"NoPCH", "NoRTTI", "NoManifest", "ExtraWarnings", "StaticRuntime", "NoExceptions" } 7 | optimization_flags = { "OptimizeSpeed", "FloatFast", "NoPCH", "ExtraWarnings" } 8 | includedirs { ".." } 9 | defines { "_HAS_EXCEPTIONS=0", "_STATIC_CPPLIB" } 10 | 11 | -- CONFIGURATIONS 12 | 13 | configuration "Debug" 14 | defines "_DEBUG" 15 | flags { "Symbols" } 16 | 17 | configuration "Release" 18 | defines "NDEBUG" 19 | flags { optimization_flags } 20 | 21 | -- give each configuration/platform a unique output directory (must happen before projects are defined) 22 | 23 | for _, name in ipairs(configurations()) do 24 | for _, plat in ipairs(platforms()) do 25 | configuration { name, plat } 26 | targetdir ( "../bin/" .. _ACTION .. "_" .. name .. "_" .. plat ) 27 | objdir ( "../bin/" .. _ACTION .. "_" .. name .. "_" .. plat .. "/obj" ) 28 | end 29 | end 30 | 31 | -- SUBPROJECTS 32 | 33 | project "insight" 34 | kind "SharedLib" 35 | uuid "1D251D82-D63A-41a3-BA5B-D49984DF809E" 36 | defines { "INSIGHT_DLL" } 37 | links { "d3d9", "d3dx9", "dxerr" } 38 | files { "../insight/redist/*.h", "../insight/source/*.cpp", "../insight/source/*.h", "../insight/source/*.inl" } 39 | 40 | 41 | project "test-single_thread" 42 | kind "ConsoleApp" 43 | uuid "DC27DD14-B07C-4c29-9C04-0863080C2068" 44 | links { "insight" } 45 | files { "../tests/test-single_thread.cpp" } 46 | 47 | 48 | project "test-single_thread_async" 49 | kind "ConsoleApp" 50 | uuid "435D37F9-0E5C-45f0-9876-8A51F9FAAE26" 51 | links { "insight" } 52 | files { "../tests/test-single_thread_async.cpp" } 53 | 54 | 55 | project "test-multiple_threads" 56 | kind "ConsoleApp" 57 | uuid "703530D4-FD5B-4b1c-9D1A-5E47944DD31E" 58 | links { "insight" } 59 | files { "../tests/test-multiple_threads.cpp" } 60 | -------------------------------------------------------------------------------- /tests/test-multiple_threads.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "insight/redist/insight.h" 5 | 6 | DWORD WINAPI threadproc(void*) 7 | { 8 | for(int i = 0; i<1000000; ++i) 9 | { 10 | Insight::Scope scope_timing("Main loop (sleep 50ms)"); 11 | 12 | for(int i=0; i<10; ++i) 13 | { 14 | Insight::Scope scope_timing("Inner loop (sleep 20ms)"); 15 | Sleep(20); 16 | } 17 | { 18 | Insight::Scope scope_timing("Sleep 50ms"); 19 | Sleep(50); 20 | } 21 | } 22 | 23 | return 0; 24 | } 25 | 26 | int main() 27 | { 28 | Insight::initialize(true); 29 | 30 | static const int NUM_THREADS = 8; 31 | 32 | HANDLE thread_handles[NUM_THREADS]; 33 | 34 | for( int i=0; i 2 | #include 3 | 4 | #include "insight/redist/insight.h" 5 | 6 | int main() 7 | { 8 | Insight::initialize(false); 9 | 10 | for(int i = 0; i<1000000; ++i) 11 | { 12 | Insight::Scope scope_timing("Main loop"); 13 | 14 | for(int i=0; i<10; ++i) 15 | { 16 | Insight::Scope scope_timing("Inner loop"); 17 | { 18 | Insight::Scope scope_timing("Sleep 1ms"); 19 | Sleep(1); 20 | } 21 | } 22 | 23 | { 24 | Insight::Scope scope_timing("Sleep 2ms"); 25 | Sleep(2); 26 | } 27 | 28 | Insight::update(); 29 | } 30 | 31 | Insight::terminate(); 32 | 33 | return 0; 34 | } 35 | 36 | 37 | -------------------------------------------------------------------------------- /tests/test-single_thread_async.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define USE_INSIGHT_PROFILER 5 | 6 | #ifdef USE_INSIGHT_PROFILER 7 | #include "insight/redist/insight.h" 8 | #pragma comment(lib, "insight.lib") 9 | #define INSIGHT_INITIALIZE Insight::initialize(); 10 | #define INSIGHT_TERMINATE Insight::terminate(); 11 | #define INSIGHT_SCOPE(name) Insight::Scope __insight_scope(name); 12 | #else 13 | #define INSIGHT_INITIALIZE 14 | #define INSIGHT_TERMINATE 15 | #define INSIGHT_SCOPE(name) 16 | #endif //RUSH_INSIGHT 17 | 18 | int main() 19 | { 20 | INSIGHT_INITIALIZE; 21 | 22 | for(int i = 0; i<1000000; ++i) 23 | { 24 | INSIGHT_SCOPE("Main loop (sleep 50ms)"); 25 | 26 | for(int i=0; i<10; ++i) 27 | { 28 | INSIGHT_SCOPE("Inner loop (sleep 20ms)"); 29 | Sleep(20); 30 | } 31 | Sleep(50); 32 | } 33 | 34 | INSIGHT_TERMINATE; 35 | 36 | return 0; 37 | } 38 | 39 | 40 | --------------------------------------------------------------------------------