]> git.cworth.org Git - apitrace/blobdiff - retrace/glretrace_main.cpp
Update news for new nomenclature.
[apitrace] / retrace / glretrace_main.cpp
index b8ef2623a87931dba4c7cb4225b6cfa3a43ca774..f369b33b7316c0f2c7ce7181268ba2c8736bbcaa 100755 (executable)
@@ -42,6 +42,7 @@ namespace glretrace {
 
 bool insideList = false;
 bool insideGlBeginEnd = false;
+bool supportsARBShaderObjects = false;
 
 enum {
     GPU_START = 0,
@@ -137,31 +138,6 @@ getTimeFrequency(void) {
     }
 }
 
-static void
-getCurrentTimes(int64_t& cpuTime, int64_t& gpuTime) {
-    GLuint query = 0;
-
-    if (retrace::profilingGpuTimes && supportsTimestamp) {
-        glGenQueries(1, &query);
-        glQueryCounter(query, GL_TIMESTAMP);
-        GLint64 timestamp = 0;
-        glGetQueryObjecti64vEXT(query, GL_QUERY_RESULT, &timestamp);
-        gpuTime = timestamp;
-    } else {
-        gpuTime = 0;
-    }
-
-    if (retrace::profilingCpuTimes) {
-        cpuTime = getCurrentTime();
-    } else {
-        cpuTime = 0;
-    }
-
-    if (retrace::profilingGpuTimes && supportsTimestamp) {
-        glDeleteQueries(1, &query);
-    }
-}
-
 static void
 completeCallQuery(CallQuery& query) {
     /* Get call start and duration */
@@ -271,6 +247,7 @@ initContext() {
     supportsElapsed     = currentContext->hasExtension("GL_EXT_timer_query") || supportsTimestamp;
     supportsOcclusion   = currentContext->hasExtension("GL_ARB_occlusion_query");
     supportsDebugOutput = currentContext->hasExtension("GL_ARB_debug_output");
+    supportsARBShaderObjects = currentContext->hasExtension("GL_ARB_shader_objects");
 
     /* Check for timer query support */
     if (retrace::profilingGpuTimes) {
@@ -307,11 +284,9 @@ initContext() {
     /* Sync the gpu and cpu start times */
     if (retrace::profilingCpuTimes || retrace::profilingGpuTimes) {
         if (!retrace::profiler.hasBaseTimes()) {
-            GLint64 gpuTime, cpuTime;
-
-            getCurrentTimes(cpuTime, gpuTime);
-            retrace::profiler.setBaseCpuTime(cpuTime);
-            retrace::profiler.setBaseGpuTime(gpuTime);
+            GLint64 currentTime = getCurrentTime();
+            retrace::profiler.setBaseCpuTime(currentTime);
+            retrace::profiler.setBaseGpuTime(currentTime);
         }
     }
 }
@@ -322,26 +297,6 @@ frame_complete(trace::Call &call) {
         /* Complete any remaining queries */
         flushQueries();
 
-        /* GPU time drifts due to being relative times, not absolute and can be
-         * affected by the gpu switch between processes.
-         *
-         * To attempt to compensate we resynchronise on frame end however there is
-         * still noticeable drift within a single frame which we do not account for.
-         */
-        if (retrace::profilingCpuTimes || retrace::profilingGpuTimes) {
-            int64_t cpuTime, gpuTime, error;
-
-            getCurrentTimes(cpuTime, gpuTime);
-            cpuTime = cpuTime - retrace::profiler.getBaseCpuTime();
-            gpuTime = gpuTime - retrace::profiler.getBaseGpuTime();
-            error   = gpuTime - cpuTime * (1.0E9 / getTimeFrequency());
-            std::cerr << "error = " << error << "\n";
-
-            if (0) {
-                retrace::profiler.setBaseGpuTime(retrace::profiler.getBaseGpuTime() + error);
-            }
-        }
-
         /* Indicate end of current frame */
         retrace::profiler.addFrameEnd();
     }