- startTime = OS::GetTime();
- Trace::Call *call;
-
- while ((call = parser.parse_call())) {
- const char *name = call->name();
-
- if (retrace::verbosity >= 1) {
- std::cout << *call;
- std::cout.flush();
+ retrace::Retracer retracer;
+
+ retracer.addCallbacks(gl_callbacks);
+ retracer.addCallbacks(glx_callbacks);
+ retracer.addCallbacks(wgl_callbacks);
+ retracer.addCallbacks(cgl_callbacks);
+ retracer.addCallbacks(egl_callbacks);
+
+ startTime = os::getTime();
+ trace::Call *call;
+
+ while ((call = retrace::parser.parse_call())) {
+ bool swapRenderTarget = call->flags & trace::CALL_FLAG_SWAP_RENDERTARGET;
+ bool doSnapshot =
+ snapshot_frequency.contains(*call) ||
+ compare_frequency.contains(*call)
+ ;
+
+ // For calls which cause rendertargets to be swaped, we take the
+ // snapshot _before_ swapping the rendertargets.
+ if (doSnapshot && swapRenderTarget) {
+ if (call->flags & trace::CALL_FLAG_END_FRAME) {
+ // For swapbuffers/presents we still use this call number,
+ // spite not have been executed yet.
+ snapshot(call->no);
+ } else {
+ // Whereas for ordinate fbo/rendertarget changes we use the
+ // previous call's number.
+ snapshot(call->no - 1);
+ }