X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=gui%2Fretracer.cpp;h=2928ed63f321f31e34667e2448e1b8f765f2fdbf;hb=ebe01ce9942e570f23b40793e97cf02b6f3616ee;hp=bbe638ca0fc0635f41e10ff9ffdbcf225f0bd0a5;hpb=af41e568fc908277d84a01ed56bbefe4db334241;p=apitrace diff --git a/gui/retracer.cpp b/gui/retracer.cpp index bbe638c..2928ed6 100644 --- a/gui/retracer.cpp +++ b/gui/retracer.cpp @@ -3,7 +3,9 @@ #include "apitracecall.h" #include "thumbnail.h" -#include "image.hpp" +#include "image/image.hpp" + +#include "trace_profiler.hpp" #include #include @@ -129,22 +131,12 @@ Retracer::Retracer(QObject *parent) m_benchmarking(false), m_doubleBuffered(true), m_captureState(false), - m_captureCall(0) + m_captureCall(0), + m_profileGpu(false), + m_profileCpu(false), + m_profilePixels(false) { qRegisterMetaType >(); - -#ifdef Q_OS_WIN - QString format = QLatin1String("%1;"); -#else - QString format = QLatin1String("%1:"); -#endif - QString buildPath = format.arg(APITRACE_BINARY_DIR); - m_processEnvironment = QProcessEnvironment::systemEnvironment(); - m_processEnvironment.insert("PATH", buildPath + - m_processEnvironment.value("PATH")); - - qputenv("PATH", - m_processEnvironment.value("PATH").toLatin1()); } QString Retracer::fileName() const @@ -182,6 +174,33 @@ void Retracer::setDoubleBuffered(bool db) m_doubleBuffered = db; } +bool Retracer::isProfilingGpu() const +{ + return m_profileGpu; +} + +bool Retracer::isProfilingCpu() const +{ + return m_profileCpu; +} + +bool Retracer::isProfilingPixels() const +{ + return m_profilePixels; +} + +bool Retracer::isProfiling() const +{ + return m_profileGpu || m_profileCpu || m_profilePixels; +} + +void Retracer::setProfiling(bool gpu, bool cpu, bool pixels) +{ + m_profileGpu = gpu; + m_profileCpu = cpu; + m_profilePixels = pixels; +} + void Retracer::setCaptureAtCallNumber(qlonglong num) { m_captureCall = num; @@ -212,7 +231,6 @@ void Retracer::setCaptureThumbnails(bool enable) m_captureThumbnails = enable; } - /** * Starting point for the retracing thread. * @@ -240,9 +258,7 @@ void Retracer::run() case trace::API_D3D7: case trace::API_D3D8: case trace::API_D3D9: - case trace::API_D3D10: - case trace::API_D3D10_1: - case trace::API_D3D11: + case trace::API_DXGI: #ifdef Q_OS_WIN prog = QLatin1String("d3dretrace"); #else @@ -255,20 +271,34 @@ void Retracer::run() return; } - if (m_doubleBuffered) { - arguments << QLatin1String("-db"); - } else { - arguments << QLatin1String("-sb"); - } - if (m_captureState) { arguments << QLatin1String("-D"); arguments << QString::number(m_captureCall); } else if (m_captureThumbnails) { arguments << QLatin1String("-s"); // emit snapshots arguments << QLatin1String("-"); // emit to stdout - } else if (m_benchmarking) { - arguments << QLatin1String("-b"); + } else if (isProfiling()) { + if (m_profileGpu) { + arguments << QLatin1String("--pgpu"); + } + + if (m_profileCpu) { + arguments << QLatin1String("--pcpu"); + } + + if (m_profilePixels) { + arguments << QLatin1String("--ppd"); + } + } else { + if (m_doubleBuffered) { + arguments << QLatin1String("--db"); + } else { + arguments << QLatin1String("--sb"); + } + + if (m_benchmarking) { + arguments << QLatin1String("-b"); + } } arguments << m_fileName; @@ -291,6 +321,7 @@ void Retracer::run() QList thumbnails; QVariantMap parsedJson; + trace::Profile* profile = NULL; process.setReadChannel(QProcess::StandardOutput); if (process.waitForReadyRead(-1)) { @@ -307,6 +338,9 @@ void Retracer::run() bool ok = false; QJson::Parser jsonParser; + + // Allow Nan/Infinity + jsonParser.allowSpecialNumbers(true); #if 0 parsedJson = jsonParser.parse(&io, &ok).toMap(); #else @@ -362,6 +396,7 @@ void Retracer::run() unsigned char *scanLine = snapshot.scanLine(y); qint64 readBytes = io.read((char *) scanLine, rowBytes); Q_ASSERT(readBytes == rowBytes); + (void)readBytes; } QImage thumb = thumbnail(snapshot); @@ -369,7 +404,20 @@ void Retracer::run() } Q_ASSERT(process.state() != QProcess::Running); + } else if (isProfiling()) { + profile = new trace::Profile(); + + while (!io.atEnd()) { + char line[256]; + qint64 lineLength; + + lineLength = io.readLine(line, 256); + if (lineLength == -1) + break; + + trace::Profiler::parseLine(line, profile); + } } else { QByteArray output; output = process.readAllStandardOutput(); @@ -431,6 +479,10 @@ void Retracer::run() emit foundThumbnails(thumbnails); } + if (isProfiling() && profile) { + emit foundProfile(profile); + } + if (!errors.isEmpty()) { emit retraceErrors(errors); }