Skip to content

Commit

Permalink
retrace: Set Windows timer resolution period to minimum.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfonseca committed May 21, 2015
1 parent deb1d68 commit 1a0bd52
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion retrace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if (NOT ANDROID AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries (retrace_common rt)
endif ()
if (WIN32)
target_link_libraries (retrace_common dxerr)
target_link_libraries (retrace_common dxerr winmm)
endif ()


Expand Down
16 changes: 16 additions & 0 deletions retrace/retrace_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,16 @@ int main(int argc, char **argv)
}
#endif

#ifdef _WIN32
// Set Windows timer resolution to the minimum period supported by the
// system
TIMECAPS tc;
MMRESULT mmRes = timeGetDevCaps(&tc, sizeof tc);
if (mmRes == MMSYSERR_NOERROR) {
mmRes = timeBeginPeriod(tc.wPeriodMin);
}
#endif

retrace::setUp();
if (retrace::profiling) {
retrace::profiler.setup(retrace::profilingCpuTimes, retrace::profilingGpuTimes, retrace::profilingPixelsDrawn, retrace::profilingMemoryUsage);
Expand All @@ -884,6 +894,12 @@ int main(int argc, char **argv)
// XXX: X often hangs on XCloseDisplay
//retrace::cleanUp();

#ifdef _WIN32
if (mmRes == MMSYSERR_NOERROR) {
timeEndPeriod(tc.wPeriodMin);
}
#endif

return 0;
}

0 comments on commit 1a0bd52

Please sign in to comment.