apitrace: Changes to 'upstream'
.gitignore | 11
CMakeLists.txt | 454 -
DEVELOPMENT.markdown | 9
INSTALL.markdown | 50
NEWS.markdown | 22
README.markdown | 218
TODO.markdown | 129
cgltrace.py | 68
cli/CMakeLists.txt | 5
cli/cli.hpp | 1
cli/cli_diff.cpp | 80
cli/cli_diff_images.cpp | 25
cli/cli_diff_state.cpp | 38
cli/cli_dump.cpp | 25
cli/cli_dump_images.cpp | 145
cli/cli_main.cpp | 1
cli/cli_pickle.cpp | 132
cli/cli_repack.cpp | 35
cli/cli_trace.cpp | 83
cli/cli_trim.cpp | 72
cmake/.gitignore | 1
cmake/FindDirectX.cmake | 194
cmake/toolchain/android.toolchain.cmake | 1110 ++
codegen.py | 81
common/formatter.hpp | 83
common/image.hpp | 4
common/image_png.cpp | 7
common/image_pnm.cpp | 51
common/json.hpp | 342
common/os_binary.hpp | 1
common/os_posix.cpp | 23
common/os_process.hpp | 24
common/os_string.hpp | 97
common/os_time.hpp | 21
common/os_win32.cpp | 15
common/pickle.hpp | 18
common/trace_api.hpp | 13
common/trace_dump.cpp | 28
common/trace_file_zlib.cpp | 10
common/trace_format.hpp | 4
common/trace_model.cpp | 13
common/trace_model.hpp | 46
common/trace_parser.cpp | 50
common/trace_parser.hpp | 5
common/trace_parser_flags.cpp | 32
common/trace_profiler.cpp | 201
common/trace_profiler.hpp | 122
common/trace_resource.cpp | 93
common/trace_resource.hpp | 5
common/trace_tools_trace.cpp | 138
common/trace_writer.cpp | 8
common/trace_writer.hpp | 5
common/trace_writer_local.cpp | 6
common/trace_writer_local.hpp | 2
common/trace_writer_model.cpp | 9
compat.h | 81
d3d10trace.py | 45
d3d8trace.py | 54
d3d9imports.hpp | 83
d3d9trace.py | 94
d3dshader.cpp | 96
d3dshader.hpp | 38
ddrawtrace.py | 81
dispatch.py | 115
dispatch/.gitignore | 1
dispatch/CMakeLists.txt | 55
dispatch/__init__.py | 1
dispatch/compat.h | 748 +
dispatch/d3d10_1imports.hpp | 43
dispatch/d3d10imports.hpp | 43
dispatch/d3d11imports.hpp | 43
dispatch/d3d9imports.hpp | 99
dispatch/d3derr.hpp | 63
dispatch/dispatch.py | 124
dispatch/eglimports.hpp | 94
dispatch/glimports.hpp | 122
dispatch/glproc.py | 544 +
dispatch/glproc_egl.cpp | 151
dispatch/glproc_gl.cpp | 230
dlltrace.py | 69
eglimports.hpp | 126
egltrace.py | 190
glcaps.cpp | 177
glimports.hpp | 162
glproc.py | 540 -
glproc_egl.cpp | 101
glproc_gl.cpp | 230
glretrace.hpp | 69
glretrace.py | 400
glretrace_cgl.cpp | 125
glretrace_egl.cpp | 274
glretrace_glx.cpp | 260
glretrace_main.cpp | 391
glretrace_wgl.cpp | 309
glsize.hpp | 786 -
glstate.cpp | 1445 ---
glstate.hpp | 61
glstate.py | 498 -
gltrace.hpp | 49
gltrace.py | 939 --
glws.cpp | 62
glws.hpp | 170
glws_cocoa.mm | 270
glws_egl_xlib.cpp | 441 -
glws_glx.cpp | 377
glws_wgl.cpp | 282
glxtrace.py | 161
gui/CMakeLists.txt | 15
gui/apicalldelegate.cpp | 59
gui/apisurface.cpp | 3
gui/apitrace.cpp | 74
gui/apitrace.h | 23
gui/apitracecall.cpp | 28
gui/apitracecall.h | 6
gui/apitracemodel.cpp | 23
gui/apitracemodel.h | 2
gui/imageviewer.cpp | 88
gui/imageviewer.h | 5
gui/main.cpp | 3
gui/mainwindow.cpp | 222
gui/mainwindow.h | 29
gui/profiledialog.cpp | 83
gui/profiledialog.h | 34
gui/profiletablemodel.cpp | 272
gui/profiletablemodel.h | 65
gui/retracer.cpp | 540 -
gui/retracer.h | 74
gui/saverthread.cpp | 14
gui/settingsdialog.cpp | 11
gui/settingsdialog.h | 2
gui/thumbnail.h | 13
gui/timelinewidget.cpp | 883 ++
gui/timelinewidget.h | 119
gui/tracedialog.cpp | 17
gui/tracedialog.h | 1
gui/traceloader.cpp | 43
gui/traceloader.h | 5
gui/traceprocess.cpp | 12
gui/traceprocess.h | 2
gui/trimprocess.cpp | 120
gui/trimprocess.h | 45
gui/ui/imageviewer.ui | 69
gui/ui/mainwindow.ui | 56
gui/ui/profiledialog.ui | 276
gui/ui/profilereplaydialog.ui | 112
gui/ui/settings.ui | 23
gui/ui/tracedialog.ui | 14
helpers/d3dsize.hpp | 379
helpers/eglsize.cpp | 217
helpers/eglsize.hpp | 57
helpers/glsize.hpp | 809 +
retrace.cpp | 136
retrace.hpp | 152
retrace.py | 316
retrace/.gitignore | 2
retrace/CMakeLists.txt | 161
retrace/d3dretrace.hpp | 63
retrace/d3dretrace.py | 113
retrace/d3dretrace_main.cpp | 94
retrace/d3dretrace_ws.cpp | 151
retrace/d3dstate.cpp | 45
retrace/d3dstate.hpp | 55
retrace/d3dstate_images.cpp | 100
retrace/dllretrace.py | 70
retrace/glretrace.hpp | 98
retrace/glretrace.py | 527 +
retrace/glretrace_cgl.cpp | 117
retrace/glretrace_egl.cpp | 267
retrace/glretrace_glx.cpp | 222
retrace/glretrace_main.cpp | 444 +
retrace/glretrace_wgl.cpp | 293
retrace/glretrace_ws.cpp | 193
retrace/glstate.cpp | 155
retrace/glstate.hpp | 54
retrace/glstate_images.cpp | 1189 ++
retrace/glstate_internal.hpp | 73
retrace/glstate_params.py | 527 +
retrace/glstate_shaders.cpp | 742 +
retrace/glws.cpp | 59
retrace/glws.hpp | 167
retrace/glws_cocoa.mm | 270
retrace/glws_egl_xlib.cpp | 484 +
retrace/glws_glx.cpp | 377
retrace/glws_wgl.cpp | 352
retrace/json.hpp | 369
retrace/retrace.cpp | 119
retrace/retrace.hpp | 241
retrace/retrace.py | 510 +
retrace/retrace_main.cpp | 320
retrace/retrace_stdc.cpp | 71
retrace/retrace_swizzle.cpp | 274
retrace/retrace_swizzle.hpp | 102
retrace_stdc.cpp | 238
scripts/highlight.py | 81
scripts/profileshader.py | 84
scripts/retracediff.py | 4
scripts/snapdiff.py | 49
scripts/tracediff.py | 215
scripts/tracediff.sh | 59
scripts/tracediff2.py | 341
scripts/unpickle.py | 216
specs/__init__.py | 28
specs/cglapi.py | 4
specs/d3d.py | 56
specs/d3d10.def | 6
specs/d3d10.py | 386
specs/d3d10_1.def | 6
specs/d3d10_1.py | 101
specs/d3d10effect.py | 384
specs/d3d10misc.py | 48
specs/d3d10sdklayers.py | 620 +
specs/d3d10shader.py | 175
specs/d3d11.py | 1236 ++
specs/d3d11_1.py | 180
specs/d3d11sdklayers.py | 890 ++
specs/d3d11shader.py | 186
specs/d3d8.def | 4
specs/d3d8.py | 67
specs/d3d9.def | 12
specs/d3d9.py | 289
specs/d3d9caps.py | 11
specs/d3d9types.py | 85
specs/d3dcommon.py | 701 +
specs/ddraw.def | 23
specs/ddraw.py | 67
specs/dxgi.py | 292
specs/dxgiformat.py | 2
specs/dxgitype.py | 28
specs/eglapi.py | 8
specs/glapi.py | 946 +-
specs/glesapi.py | 66
specs/glparams.py | 582 +
specs/gltypes.py | 27
specs/glxapi.py | 34
specs/opengl32.def | 371
specs/scripts/cdecl.py | 139
specs/scripts/glspec.py | 12
specs/stdapi.py | 370
specs/wglapi.py | 14
specs/winapi.py | 78
thirdparty/glext/.gitignore | 1
thirdparty/glext/GL/Makefile | 11
thirdparty/glext/GL/glext.h |11490 --------------------------
thirdparty/glext/GL/glext.sed | 19
thirdparty/glext/GL/glxext.h | 993 --
thirdparty/glext/GL/wglext.h | 929 --
thirdparty/khr/EGL/egl.h | 329
thirdparty/khr/EGL/eglext.h | 335
thirdparty/khr/GLES/glext.h | 1073 --
thirdparty/khr/GLES2/gl2ext.h | 1138 --
thirdparty/khronos/.gitignore | 1
thirdparty/khronos/EGL/egl.h | 329
thirdparty/khronos/EGL/eglext.h | 464 +
thirdparty/khronos/EGL/eglplatform.h | 131
thirdparty/khronos/EGL/eglplatform.patch | 27
thirdparty/khronos/GL/gl.h | 1957 ++++
thirdparty/khronos/GL/glext.h |12804 ++++++++++++++++++++++++++++++
thirdparty/khronos/GL/glext.patch | 22
thirdparty/khronos/GL/glx.h | 325
thirdparty/khronos/GL/glxext.h | 1001 ++
thirdparty/khronos/GL/wglext.h | 943 ++
thirdparty/khronos/GLES/gl.h | 770 +
thirdparty/khronos/GLES/glext.h | 1192 ++
thirdparty/khronos/GLES/glext.patch | 19
thirdparty/khronos/GLES/glplatform.h | 30
thirdparty/khronos/GLES2/gl2.h | 620 +
thirdparty/khronos/GLES2/gl2ext.h | 1525 +++
thirdparty/khronos/GLES2/gl2platform.h | 30
thirdparty/khronos/KHR/khrplatform.h | 269
thirdparty/khronos/Makefile | 42
thirdparty/khronos/README.markdown | 12
thirdparty/less.patch | 100
thirdparty/less/CMakeLists.txt | 36
thirdparty/less/COPYING | 674 +
thirdparty/less/INSTALL | 186
thirdparty/less/LICENSE | 27
thirdparty/less/NEWS | 820 +
thirdparty/less/README | 236
thirdparty/less/brac.c | 101
thirdparty/less/ch.c | 933 ++
thirdparty/less/charset.c | 1173 ++
thirdparty/less/charset.h | 19
thirdparty/less/cmd.h | 133
thirdparty/less/cmdbuf.c | 1503 +++
thirdparty/less/command.c | 1763 ++++
thirdparty/less/cvt.c | 120
thirdparty/less/decode.c | 841 +
thirdparty/less/defines.h.in | 426
thirdparty/less/defines.wn | 347
thirdparty/less/edit.c | 818 +
thirdparty/less/filename.c | 1081 ++
thirdparty/less/forwback.c | 424
thirdparty/less/funcs.h | 291
thirdparty/less/help.c | 236
thirdparty/less/ifile.c | 346
thirdparty/less/input.c | 458 +
thirdparty/less/jump.c | 309
thirdparty/less/less.h | 504 +
thirdparty/less/less.hlp | 231
thirdparty/less/lessecho.c | 272
thirdparty/less/lesskey.c | 873 ++
thirdparty/less/lesskey.h | 40
thirdparty/less/lglob.h | 95
thirdparty/less/line.c | 1244 ++
thirdparty/less/linenum.c | 471 +
thirdparty/less/lsystem.c | 376
thirdparty/less/main.c | 414
thirdparty/less/mark.c | 258
thirdparty/less/mkhelp.c | 69
thirdparty/less/optfunc.c | 707 +
thirdparty/less/option.c | 702 +
thirdparty/less/option.h | 67
thirdparty/less/opttbl.c | 599 +
thirdparty/less/os.c | 364
thirdparty/less/output.c | 601 +
thirdparty/less/pattern.c | 322
thirdparty/less/pattern.h | 48
thirdparty/less/pckeys.h | 34
thirdparty/less/position.c | 232
thirdparty/less/position.h | 19
thirdparty/less/prompt.c | 587 +
thirdparty/less/regexp.c | 1250 ++
thirdparty/less/regexp.h | 34
thirdparty/less/screen.c | 2502 +++++
thirdparty/less/scrsize.c | 104
thirdparty/less/search.c | 1211 ++
thirdparty/less/signal.c | 257
thirdparty/less/tags.c | 757 +
thirdparty/less/ttyin.c | 178
thirdparty/less/version.c | 748 +
thirdparty/libpng/ANNOUNCE | 60
thirdparty/libpng/CHANGES | 559 +
thirdparty/libpng/LICENSE | 4
thirdparty/libpng/README | 13
thirdparty/libpng/libpng.txt | 3352 -------
thirdparty/libpng/png.c | 900 +-
thirdparty/libpng/png.h | 477 -
thirdparty/libpng/pngconf.h | 117
thirdparty/libpng/pngerror.c | 278
thirdparty/libpng/pngget.c | 120
thirdparty/libpng/pnginfo.h | 1
thirdparty/libpng/pnglibconf.h | 20
thirdparty/libpng/pngmem.c | 37
thirdparty/libpng/pngpread.c | 267
thirdparty/libpng/pngpriv.h | 669 +
thirdparty/libpng/pngread.c | 501 -
thirdparty/libpng/pngrtran.c | 2468 +++--
thirdparty/libpng/pngrutil.c | 1482 ++-
thirdparty/libpng/pngset.c | 109
thirdparty/libpng/pngstruct.h | 90
thirdparty/libpng/pngtrans.c | 16
thirdparty/libpng/pngwrite.c | 240
thirdparty/libpng/pngwtran.c | 30
thirdparty/libpng/pngwutil.c | 570 -
thirdparty/msvc/.gitignore | 1
thirdparty/msvc/Makefile | 10
thirdparty/snappy/ChangeLog | 422
thirdparty/snappy/NEWS | 31
thirdparty/snappy/README | 4
thirdparty/snappy/format_description.txt | 6
thirdparty/snappy/framing_format.txt | 124
thirdparty/snappy/snappy-sinksource.cc | 1
thirdparty/snappy/snappy-sinksource.h | 1
thirdparty/snappy/snappy-stubs-internal.h | 62
thirdparty/snappy/snappy-stubs-public.h | 2
thirdparty/snappy/snappy-test.cc | 2
thirdparty/snappy/snappy-test.h | 2
thirdparty/snappy/snappy.cc | 197
thirdparty/snappy/snappy.h | 4
thirdparty/snappy/snappy_unittest.cc | 18
thirdparty/zlib/CMakeLists.txt | 2
thirdparty/zlib/ChangeLog | 141
thirdparty/zlib/README | 24
thirdparty/zlib/adler32.c | 68
thirdparty/zlib/crc32.c | 31
thirdparty/zlib/crc32.h | 2
thirdparty/zlib/deflate.c | 259
thirdparty/zlib/deflate.h | 10
thirdparty/zlib/example.c | 565 -
thirdparty/zlib/gzguts.h | 80
thirdparty/zlib/gzlib.c | 77
thirdparty/zlib/gzread.c | 417
thirdparty/zlib/gzwrite.c | 150
thirdparty/zlib/infback.c | 14
thirdparty/zlib/inffixed.h | 6
thirdparty/zlib/inflate.c | 71
thirdparty/zlib/inftrees.c | 46
thirdparty/zlib/minigzip.c | 440 -
thirdparty/zlib/trees.c | 40
thirdparty/zlib/zconf.h | 146
thirdparty/zlib/zlib.h | 279
thirdparty/zlib/zutil.c | 31
thirdparty/zlib/zutil.h | 92
trace.py | 589 -
wgltrace.py | 83
wrappers/.gitignore | 12
wrappers/CMakeLists.txt | 403
wrappers/cgltrace.py | 107
wrappers/d3d10.def | 31
wrappers/d3d10_1.def | 6
wrappers/d3d10_1trace.py | 40
wrappers/d3d10shader.cpp | 115
wrappers/d3d10shader.hpp | 38
wrappers/d3d10trace.py | 52
wrappers/d3d11.def | 9
wrappers/d3d11trace.py | 48
wrappers/d3d8.def | 4
wrappers/d3d8trace.py | 54
wrappers/d3d9.def | 12
wrappers/d3d9shader.cpp | 105
wrappers/d3d9shader.hpp | 38
wrappers/d3d9trace.py | 95
wrappers/ddraw.def | 23
wrappers/ddrawtrace.py | 70
wrappers/dlltrace.py | 69
wrappers/egltrace.py | 281
wrappers/glcaps.cpp | 226
wrappers/gltrace.hpp | 90
wrappers/gltrace.py | 1029 ++
wrappers/gltrace_state.cpp | 156
wrappers/glxtrace.py | 177
wrappers/opengl32.def | 371
wrappers/trace.cpp | 115
wrappers/trace.hpp | 56
wrappers/trace.py | 709 +
wrappers/wgltrace.py | 103
426 files changed, 91960 insertions(+), 39335 deletions(-)
New commits:
commit 56ad11c7849c7e6ca0ad66558cb1a99c58d4cd3d
Author: James Benton <jbenton@vmware.com>
Date: Thu Aug 16 13:44:19 2012 +0100
Improve profiling.
Remove frame_begin from profile output.
Change frame_end to no longer record times.
Profile non-draw calls for CPU only.
Resynchronise gpu time every frame to account for drift.
Improve performance of profile gui.
Add seperate CPU view to timeline widget.
diff --git a/common/trace_profiler.cpp b/common/trace_profiler.cpp
index 403c260..642ba6e 100644
--- a/common/trace_profiler.cpp
+++ b/common/trace_profiler.cpp
@@ -24,16 +24,16 @@
**************************************************************************/
#include "trace_profiler.hpp"
+#include "os_time.hpp"
#include <iostream>
#include <string.h>
-#include <assert.h>
#include <sstream>
-#include "os_time.hpp"
namespace trace {
Profiler::Profiler()
: baseGpuTime(0),
baseCpuTime(0),
+ minCpuTime(1000),
cpuTimes(false),
gpuTimes(true),
pixelsDrawn(false)
@@ -50,14 +50,26 @@ void Profiler::setup(bool cpuTimes_, bool gpuTimes_, bool pixelsDrawn_)
gpuTimes = gpuTimes_;
pixelsDrawn = pixelsDrawn_;
- std::cout << "# frame_begin no gpu_start cpu_start" << std::endl;
- std::cout << "# frame_end no gpu_end gpu_dura cpu_end cpu_dura" << std::endl;
std::cout << "# call no gpu_start gpu_dura cpu_start cpu_dura pixels program name" << std::endl;
}
-void Profiler::setBaseTimes(int64_t gpuStart, int64_t cpuStart)
+int64_t Profiler::getBaseCpuTime()
+{
+ return baseCpuTime;
+}
+
+int64_t Profiler::getBaseGpuTime()
+{
+ return baseGpuTime;
+}
+
+void Profiler::setBaseCpuTime(int64_t cpuStart)
{
baseCpuTime = cpuStart;
+}
+
+void Profiler::setBaseGpuTime(int64_t gpuStart)
+{
baseGpuTime = gpuStart;
}
@@ -84,6 +96,10 @@ void Profiler::addCall(unsigned no,
double cpuTimeScale = 1.0E9 / os::timeFrequency;
cpuStart = (cpuStart - baseCpuTime) * cpuTimeScale;
cpuDuration = cpuDuration * cpuTimeScale;
+
+ if (cpuDuration < minCpuTime) {
+ return;
+ }
} else {
cpuStart = 0;
cpuDuration = 0;
@@ -105,108 +121,81 @@ void Profiler::addCall(unsigned no,
<< std::endl;
}
-void Profiler::addFrameStart(unsigned no, int64_t gpuStart, int64_t cpuStart)
-{
- lastFrame.no = no;
- lastFrame.gpuStart = gpuStart;
- lastFrame.cpuStart = cpuStart;
-
- if (gpuTimes) {
- gpuStart = gpuStart - baseGpuTime;
- } else {
- gpuStart = 0;
- }
-
- if (cpuTimes) {
- double cpuTimeScale = 1.0E9 / os::timeFrequency;
- cpuStart = (cpuStart - baseCpuTime) * cpuTimeScale;
- } else {
- cpuStart = 0;
- }
-
- std::cout << "frame_begin"
- << " " << no
- << " " << gpuStart
- << " " << cpuStart
- << std::endl;
-}
-
-void Profiler::addFrameEnd(int64_t gpuEnd, int64_t cpuEnd)
+void Profiler::addFrameEnd()
{
- int64_t gpuDuration, cpuDuration;
-
- if (gpuTimes) {
- gpuDuration = gpuEnd - lastFrame.gpuStart;
- gpuEnd = gpuEnd - baseGpuTime;
- } else {
- gpuEnd = 0;
- gpuDuration = 0;
- }
-
- if (cpuTimes) {
- double cpuTimeScale = 1.0E9 / os::timeFrequency;
- cpuDuration = (cpuEnd - lastFrame.cpuStart) * cpuTimeScale;
- cpuEnd = (cpuEnd - baseCpuTime) * cpuTimeScale;
- } else {
- cpuEnd = 0;
- cpuDuration = 0;
- }
-
- std::cout << "frame_end"
- << " " << lastFrame.no
- << " " << gpuEnd
- << " " << gpuDuration
- << " " << cpuEnd
- << " " << cpuDuration
- << std::endl;
+ std::cout << "frame_end" << std::endl;
}
void Profiler::parseLine(const char* in, Profile* profile)
{
std::stringstream line(in, std::ios_base::in);
std::string type;
+ static int64_t lastGpuTime;
+ static int64_t lastCpuTime;
- if (in[0] == '#' || strlen(in) < 12)
+ if (in[0] == '#' || strlen(in) < 4)
return;
+ if (profile->programs.size() == 0 && profile->cpuCalls.size() == 0 && profile->frames.size() == 0) {
+ lastGpuTime = 0;
+ lastCpuTime = 0;
+ }
+
line >> type;
if (type.compare("call") == 0) {
- assert(profile->frames.size());
- Profile::Call call;
-
- line >> call.no
- >> call.gpuStart
- >> call.gpuDuration
- >> call.cpuStart
- >> call.cpuDuration
- >> call.pixels
- >> call.program
- >> call.name;
-
- if (call.pixels >= 0) {
- profile->frames.back().calls.push_back(call);
+ Profile::DrawCall draw;
+ unsigned program;
+
+ line >> draw.no
+ >> draw.gpuStart
+ >> draw.gpuDuration
+ >> draw.cpuStart
+ >> draw.cpuDuration
+ >> draw.pixels
+ >> program
+ >> draw.name;
+
+ if (lastGpuTime < draw.gpuStart + draw.gpuDuration) {
+ lastGpuTime = draw.gpuStart + draw.gpuDuration;
}
- } else if (type.compare("frame_begin") == 0) {
- Profile::Frame frame;
- frame.gpuDuration = 0;
- frame.cpuDuration = 0;
- line >> frame.no
- >> frame.gpuStart
- >> frame.cpuStart;
+ if (lastCpuTime < draw.cpuStart + draw.cpuDuration) {
+ lastCpuTime = draw.cpuStart + draw.cpuDuration;
+ }
- profile->frames.push_back(frame);
+ if (draw.pixels >= 0) {
+ if (profile->programs.size() <= program) {
+ profile->programs.resize(program + 1);
+ }
+
+ profile->programs[program].cpuTotal += draw.cpuDuration;
+ profile->programs[program].gpuTotal += draw.gpuDuration;
+ profile->programs[program].pixelTotal += draw.pixels;
+ profile->programs[program].drawCalls.push_back(draw);
+ }
+
+ Profile::CpuCall call;
+ call.no = draw.no;
+ call.name = draw.name;
+ call.cpuStart = draw.cpuStart;
+ call.cpuDuration = draw.cpuDuration;
+ profile->cpuCalls.push_back(call);
} else if (type.compare("frame_end") == 0) {
- assert(profile->frames.size());
- Profile::Frame& frame = profile->frames.back();
- int64_t skipi64;
-
- line >> frame.no
- >> skipi64
- >> frame.gpuDuration
- >> skipi64
- >> frame.cpuDuration;
+ Profile::Frame frame;
+ frame.no = profile->frames.size();
+
+ if (frame.no == 0) {
+ frame.gpuStart = 0;
+ frame.cpuStart = 0;
+ } else {
+ frame.gpuStart = profile->frames.back().gpuStart + profile->frames.back().gpuDuration;
+ frame.cpuStart = profile->frames.back().cpuStart + profile->frames.back().cpuDuration;
+ }
+
+ frame.gpuDuration = lastGpuTime - frame.gpuStart;
+ frame.cpuDuration = lastCpuTime - frame.cpuStart;
+ profile->frames.push_back(frame);
}
}
}
diff --git a/common/trace_profiler.hpp b/common/trace_profiler.hpp
index dc3c4be..42fd032 100644
--- a/common/trace_profiler.hpp
+++ b/common/trace_profiler.hpp
@@ -34,34 +34,51 @@ namespace trace
{
struct Profile {
- struct Call {
+ struct CpuCall {
unsigned no;
+
+ int64_t cpuStart;
+ int64_t cpuDuration;
+
+ std::string name;
+ };
+
+ struct DrawCall {
+ unsigned no;
+
int64_t gpuStart;
int64_t gpuDuration;
+
int64_t cpuStart;
int64_t cpuDuration;
+
int64_t pixels;
- unsigned program;
- std::string name;
- typedef std::vector<Call>::iterator iterator;
- typedef std::vector<Call>::const_iterator const_iterator;
+ std::string name;
};
struct Frame {
unsigned no;
+
int64_t gpuStart;
int64_t gpuDuration;
+
int64_t cpuStart;
int64_t cpuDuration;
+ };
- std::vector<Call> calls;
+ struct Program {
+ Program() : gpuTotal(0), cpuTotal(0), pixelTotal(0) {}
- typedef std::vector<Frame>::iterator iterator;
- typedef std::vector<Frame>::const_iterator const_iterator;
+ uint64_t gpuTotal;
+ uint64_t cpuTotal;
+ uint64_t pixelTotal;
+ std::vector<DrawCall> drawCalls;
};
std::vector<Frame> frames;
+ std::vector<Program> programs;
+ std::vector<CpuCall> cpuCalls;
};
class Profiler
@@ -71,11 +88,6 @@ public:
~Profiler();
void setup(bool cpuTimes_, bool gpuTimes_, bool pixelsDrawn_);
- void setBaseTimes(int64_t gpuStart, int64_t cpuStart);
- bool hasBaseTimes();
-
- void addFrameStart(unsigned no, int64_t gpuStart, int64_t cpuStart);
- void addFrameEnd(int64_t gpuEnd, int64_t cpuEnd);
void addCall(unsigned no,
const char* name,
@@ -84,21 +96,26 @@ public:
int64_t gpuStart, int64_t gpuDuration,
int64_t cpuStart, int64_t cpuDuration);
+ void addFrameEnd();
+
+ bool hasBaseTimes();
+
+ void setBaseCpuTime(int64_t cpuStart);
+ void setBaseGpuTime(int64_t gpuStart);
+
+ int64_t getBaseCpuTime();
+ int64_t getBaseGpuTime();
+
static void parseLine(const char* line, Profile* profile);
private:
int64_t baseGpuTime;
int64_t baseCpuTime;
+ int64_t minCpuTime;
bool cpuTimes;
bool gpuTimes;
bool pixelsDrawn;
-
- struct {
- unsigned no;
- int64_t gpuStart;
- int64_t cpuStart;
- } lastFrame;
};
}
diff --git a/gui/profiledialog.cpp b/gui/profiledialog.cpp
index 5568b54..d0a55a3 100644
--- a/gui/profiledialog.cpp
+++ b/gui/profiledialog.cpp
@@ -22,7 +22,7 @@ ProfileDialog::~ProfileDialog()
void ProfileDialog::tableDoubleClicked(const QModelIndex& index)
{
ProfileTableModel* model = (ProfileTableModel*)m_table->model();
- const trace::Profile::Call* call = model->getJumpCall(index);
+ const trace::Profile::DrawCall* call = model->getJumpCall(index);
if (call) {
emit jumpToCall(call->no);
diff --git a/gui/profiletablemodel.cpp b/gui/profiletablemodel.cpp
index 8da07e0..649dae0 100644
--- a/gui/profiletablemodel.cpp
+++ b/gui/profiletablemodel.cpp
@@ -1,7 +1,9 @@
#include "profiletablemodel.h"
-typedef trace::Profile::Call Call;
typedef trace::Profile::Frame Frame;
+typedef trace::Profile::Program Program;
+typedef trace::Profile::CpuCall CpuCall;
+typedef trace::Profile::DrawCall DrawCall;
enum {
COLUMN_PROGRAM,
@@ -38,8 +40,8 @@ ProfileTableModel::ProfileTableModel(QObject *parent)
void ProfileTableModel::setProfile(trace::Profile* profile)
{
m_profile = profile;
- m_timeMin = m_profile->frames.front().gpuStart;
- m_timeMax = m_profile->frames.back().gpuStart + m_profile->frames.back().gpuDuration;
+ m_timeMin = m_profile->frames.front().cpuStart;
+ m_timeMax = m_profile->frames.back().cpuStart + m_profile->frames.back().cpuDuration;
updateModel();
}
@@ -59,8 +61,8 @@ void ProfileTableModel::setTimeSelection(int64_t start, int64_t end)
void ProfileTableModel::updateModel()
{
if (m_timeMin == m_timeMax) {
- m_timeMin = m_profile->frames.front().gpuStart;
- m_timeMax = m_profile->frames.back().gpuStart + m_profile->frames.back().gpuDuration;
+ m_timeMin = m_profile->frames.front().cpuStart;
+ m_timeMax = m_profile->frames.back().cpuStart + m_profile->frames.back().cpuDuration;
}
for (QList<ProfileTableRow>::iterator itr = m_rowData.begin(); itr != m_rowData.end(); ++itr) {
@@ -75,39 +77,25 @@ void ProfileTableModel::updateModel()
row.longestPixel = NULL;
}
- for (Frame::const_iterator itr = m_profile->frames.begin(); itr != m_profile->frames.end(); ++itr) {
- const Frame& frame = *itr;
+ for (std::vector<Program>::const_iterator itr = m_profile->programs.begin(); itr != m_profile->programs.end(); ++itr) {
+ ProfileTableRow* row = getRow(itr - m_profile->programs.begin());
+ const Program& program = *itr;
- if (frame.gpuStart > m_timeMax) {
- break;
- }
-
- if ((frame.gpuStart + frame.gpuDuration) < m_timeMin) {
- continue;
- }
-
- for (Call::const_iterator jtr = frame.calls.begin(); jtr != frame.calls.end(); ++jtr) {
- const Call& call = *jtr;
+ for (std::vector<DrawCall>::const_iterator jtr = program.drawCalls.begin(); jtr != program.drawCalls.end(); ++jtr) {
+ const DrawCall& call = *jtr;
- if (call.gpuStart > m_timeMax) {
+ if (call.cpuStart > m_timeMax) {
break;
}
- if ((call.gpuStart + call.gpuDuration) < m_timeMin) {
+ if (call.cpuStart + call.cpuDuration < m_timeMin) {
continue;
}
- ProfileTableRow* row = getRow(call.program);
- if (!row) {
- m_rowData.append(ProfileTableRow());
- row = &m_rowData.back();
- }
-
row->uses++;
- row->program = call.program;
+ row->pixels += call.pixels;
row->gpuTime += call.gpuDuration;
row->cpuTime += call.cpuDuration;
- row->pixels += call.pixels;
if (!row->longestGpu || row->longestGpu->gpuDuration < call.gpuDuration) {
row->longestGpu = &call;
@@ -128,7 +116,7 @@ void ProfileTableModel::updateModel()
/**
* Get the appropriate call associated with an item in the table
*/
-const Call* ProfileTableModel::getJumpCall(const QModelIndex & index) const {
+const DrawCall* ProfileTableModel::getJumpCall(const QModelIndex & index) const {
const ProfileTableRow& row = m_rowData[index.row()];
switch(index.column()) {
@@ -153,7 +141,8 @@ ProfileTableRow* ProfileTableModel::getRow(unsigned program) {
return &*itr;
}
- return NULL;
+ m_rowData.append(ProfileTableRow(program));
+ return &m_rowData.back();
}
diff --git a/gui/profiletablemodel.h b/gui/profiletablemodel.h
index fe7979a..6cca74d 100644
--- a/gui/profiletablemodel.h
+++ b/gui/profiletablemodel.h
@@ -6,8 +6,8 @@
struct ProfileTableRow
{
- ProfileTableRow()
- : program(0),
+ ProfileTableRow(unsigned no)
+ : program(no),
uses(0),
gpuTime(0),
cpuTime(0),
@@ -24,9 +24,9 @@ struct ProfileTableRow
qulonglong cpuTime;
qulonglong pixels;
- const trace::Profile::Call* longestGpu;
- const trace::Profile::Call* longestCpu;
- const trace::Profile::Call* longestPixel;
+ const trace::Profile::DrawCall* longestGpu;
+ const trace::Profile::DrawCall* longestCpu;
+ const trace::Profile::DrawCall* longestPixel;
};
class ProfileTableModel : public QAbstractTableModel
@@ -39,7 +39,7 @@ public:
void setProfile(trace::Profile* profile);
void setTimeSelection(int64_t start, int64_t end);
- const trace::Profile::Call* getJumpCall(const QModelIndex & index) const;
+ const trace::Profile::DrawCall* getJumpCall(const QModelIndex & index) const;
virtual int rowCount(const QModelIndex & parent) const;
virtual int columnCount(const QModelIndex & parent) const;
diff --git a/gui/timelinewidget.cpp b/gui/timelinewidget.cpp
index 92c971f..d9f1b58 100644
--- a/gui/timelinewidget.cpp
+++ b/gui/timelinewidget.cpp
@@ -9,8 +9,10 @@
#include <QWheelEvent>
#include <QApplication>
-typedef trace::Profile::Call Call;
typedef trace::Profile::Frame Frame;
+typedef trace::Profile::Program Program;
+typedef trace::Profile::CpuCall CpuCall;
+typedef trace::Profile::DrawCall DrawCall;
TimelineWidget::TimelineWidget(QWidget *parent)
: QWidget(parent),
@@ -19,16 +21,18 @@ TimelineWidget::TimelineWidget(QWidget *parent)
m_timeSelectionEnd(0),
m_rowHeight(20),
m_axisWidth(50),
- m_axisHeight(20),
+ m_axisHeight(30),
+ m_axisLine(QColor(240, 240, 240)),
m_axisBorder(Qt::black),
- m_axisBackground(Qt::lightGray),
+ m_axisForeground(Qt::black),
+ m_axisBackground(QColor(210, 210, 210)),
m_itemBorder(Qt::red),
m_itemForeground(Qt::cyan),
m_itemBackground(Qt::red),
- m_selectionBorder(QColor(50, 50, 255)),
- m_selectionBackground(QColor(245, 245, 255)),
- m_zoomBorder(Qt::green),
- m_zoomBackground(QColor(100, 255, 100, 80))
+ m_selectionBorder(Qt::green),
+ m_selectionBackground(QColor(100, 255, 100, 8)),
+ m_zoomBorder(QColor(255, 0, 255)),
+ m_zoomBackground(QColor(255, 0, 255, 30))
{
setBackgroundRole(QPalette::Base);
setAutoFillBackground(true);
@@ -111,18 +115,54 @@ int64_t TimelineWidget::positionToTime(int pos)
/**
- * Return the item at position
+ * Binary Search for a time in start+durations
*/
-const VisibleItem* TimelineWidget::itemAtPosition(const QPoint& pos)
+template<typename val_ty, int64_t val_ty::* mem_ptr_start, int64_t val_ty::* mem_ptr_dura>
+typename std::vector<val_ty>::const_iterator binarySearchTimespan(
+ typename std::vector<val_ty>::const_iterator begin,
+ typename std::vector<val_ty>::const_iterator end,
+ int64_t time)
{
- foreach (const VisibleItem& item, m_visibleItems) {
- if (pos.x() < item.rect.left() || pos.y() < item.rect.top())
- continue;
+ int lower = 0;
+ int upper = end - begin;
+ int pos = (lower + upper) / 2;
+ typename std::vector<val_ty>::const_iterator itr = begin + pos;
+
Reply to: