]> git.cworth.org Git - apitrace/blobdiff - retrace/glretrace_main.cpp
Rescale/rebase the times just before writing it.
[apitrace] / retrace / glretrace_main.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 3199763..9972f3b
@@ -120,7 +120,7 @@ getGpuTimestamp() {
 static GLuint64
 getCpuTimestamp() {
     if (retrace::profilingCpuTimes) {
-        return os::getTime() * (1.0E9 / os::timeFrequency);
+        return os::getTime();
     } else {
         return 0;
     }
@@ -181,14 +181,24 @@ beginProfile(trace::Call &call) {
     if (firstFrame) {
         /* Check for extension support */
         const char* extensions = (const char*)glGetString(GL_EXTENSIONS);
+        GLint bits;
 
         supportsTimestamp = glws::checkExtension("GL_ARB_timer_query", extensions);
         supportsElapsed   = glws::checkExtension("GL_EXT_timer_query", extensions) || supportsTimestamp;
         supportsOcclusion = glws::checkExtension("GL_ARB_occlusion_query", extensions);
 
-        if (retrace::profilingGpuTimes && !supportsTimestamp && !supportsElapsed) {
-            std::cout << "Error: Cannot run profile, GL_EXT_timer_query extension is not supported." << std::endl;
-            exit(-1);
+        if (retrace::profilingGpuTimes) {
+            if (!supportsTimestamp && !supportsElapsed) {
+                std::cout << "Error: Cannot run profile, GL_EXT_timer_query extension is not supported." << std::endl;
+                exit(-1);
+            }
+
+            glGetQueryiv(GL_TIME_ELAPSED, GL_QUERY_COUNTER_BITS, &bits);
+
+            if (!bits) {
+                std::cout << "Error: Cannot run profile, GL_QUERY_COUNTER_BITS == 0." << std::endl;
+                exit(-1);
+            }
         }
 
         if (retrace::profilingPixelsDrawn && !supportsOcclusion) {
@@ -232,7 +242,7 @@ void
 endProfile(trace::Call &call) {
     if (retrace::profilingCpuTimes) {
         CallQuery& query = callQueries.back();
-        query.duration = (os::getTime() - query.start) * (1.0E9 / os::timeFrequency);
+        query.duration = os::getTime() - query.start;
     }
 
     if (retrace::profilingGpuTimes && supportsElapsed) {