Pausing your Application

Introduction

GPU PerfStudio supports two ways to pause your application. GPU PerfStudio can capture all of the graphics API calls that your app makes using a technique called Frame Capture. Frame Capture records the API's function calls in a frame and plays them back after the capture is taken.

Or, GPU PerfStudio can use a time based pause on applications that measure time using QueryPerformanceCounter, timeGetTime or GetTickCount. Using the time based pause method the 3D application appears to be paused but this is technically not true, the application is rendering the same frame over and over. This method of pausing the application is achieved because 3D applications use the system timers to update the animation, so, by changing the rate of these timers we can change the speed of the animation. In particular, pausing the timers allows us to freeze the animation and do things like stepping backwards in the Frame Debugger or performing complex measurements in the Frame Profiler. This way of forcing the application to render the same frame may cause problems in some cases.

If your application uses RDTSC you should use GPU PerfStudio's Frame Capture mode.

The default setting for GPU PerfStudio is is to use time-based pause. You have to manually activate Frame Capture (see below).

Using Frame Capture

Frame Capture can be enabled by selecting the "Frame Capture on Pause" option in the General tab of the Settings window. When the application is next paused the graphics API calls will be captured and will start to play in the server. You will be able to step through the draw calls and use all of PerfStudio's other features. If you are working with a DX11 multithreaded application using command lists you will need to select Flatten CommandLists in order to see the draw calls in the frame debugger. Frame capture is only required when analyzing games where each frame is rendered in a different way (for example with multithreaded rendering). For games that do not do this, Frame Capture can be disabled.

Using the Time Spoofing Controls

Regardless of whether you are using Frame Capture or Time-based Pause, you can control how GPU PerfStudio spoofs time returned by the various time functions. Note that, without any time spoofing, if a game has been paused for a minute, when unpaused, the game will think the last frame took one minute to render. If the game is a racing game the physics engine will think the car went straight for a minute and the scene after unpausing will be totally different than when the game was paused. To prevent this from happening, GPU PerfStudio can spoof the values returned by the time functions:

How Time Spoofing Works

Most modern games are time-based, meaning that the position of objects within the game can be given by the following formula:

where 's' is the position of the object, 'v' is the object's velocity and 't' is the absolute time. Usually, applications use QueryPerformanceCounter to get 't'. By spoofing the return value of this function, GPU PerfStudio can get the application to appear to freeze, run slower, or even run faster. By returning the same value over and over for 't', GPU PerfStudio can appear to freeze the application, though, in reality, the application is simply rendering the objects in the same position for each frame.

SettingsGeneral.png

Troubleshooting and Recommendations

Make sure you are not enforcing a frame rate limiter, pausing will make your application believe it is running infinitely fast, this will cause the frame rate limiter to introduce huge delays that will cause the slowdown. Make sure you disable the frame rate limiter when you run with GPU PerfStudio.

When GPU PerfStudio pauses your application, it forces the timing functions to always return the same value. Make sure you are not dividing by the difference between these timing values or you will get a division by zero exception. A quick work around is to set the 'Time spoofing on pause' option to 'Slow motion' in the Client Settings dialog. This will cause the timers to run very slowly so lapses will be different from zero. The best fix is to handle the division by zero case in the animation engine.

Another alternative is to try using GPU PerfStudio's Frame Capture mode.

A few applications think that when a frame got rendered very quickly is because they are minimized and hence they stop rendering. Check that this is not the case. Setting the 'Time spoofing on pause' option to 'Slow motion' in the Client Settings dialog may help.

Your application is probably frame-based. GPU PerfStudio cannot pause frame-based application; you will have to make the application time-based or have a pause mode in your engine. In the latter case, you can try setting the 'Time spoofing on pause' option to 'None'. Another alternative is to try using GPU PerfStudio's Frame Capture mode.

The objects that are moving are probably being animated in a frame-based manner. This will cause the speed of their animation to depend on the CPU or GPU speed of the computer. The animation may run fine on your machine, but it may be different on faster or slower machines. You will have to make these animations time-based if you would like to debug them with GPU PerfStudio. Another alternative is to try using GPU PerfStudio's Frame Capture mode.

If your application has its own pause mode, where it will render the exact same draw calls for each frame, you can set the 'Time spoofing on pause' option to 'None' in order to avoid overriding the time values. Applications which have a frame rate limiter may crash, hang or render too slowly with Time spoofing set to 'Freeze' or 'Slow motion', however, the 'None' option prevents GPU PerfStudio from interfering with the time values, so you should not have these issues.

Try using GPU PerfStudio's Frame Capture mode. RDTSC does not work well on multi-core systems (http://msdn.microsoft.com/en-us/library/ee417693(v=vs.85).aspx) and is not as precise as QueryPerformanceCounter. It is recommended that you switch your application to using QueryPerformanceCounter if you would like to use GPU PerfStudio. Alternatively, if your application supports a pause mode, you can set the 'Time spoofing on pause' option to 'None'.