#include "apitracecall.h"
#include "thumbnail.h"
-#include "image.hpp"
+#include "image/image.hpp"
+
+#include "trace_profiler.hpp"
#include <QDebug>
#include <QVariant>
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<QList<ApiTraceError> >();
-
-#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
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;
m_captureThumbnails = enable;
}
-
/**
* Starting point for the retracing thread.
*
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
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;
QList<QImage> thumbnails;
QVariantMap parsedJson;
+ trace::Profile* profile = NULL;
process.setReadChannel(QProcess::StandardOutput);
if (process.waitForReadyRead(-1)) {
bool ok = false;
QJson::Parser jsonParser;
+
+ // Allow Nan/Infinity
+ jsonParser.allowSpecialNumbers(true);
#if 0
parsedJson = jsonParser.parse(&io, &ok).toMap();
#else
unsigned char *scanLine = snapshot.scanLine(y);
qint64 readBytes = io.read((char *) scanLine, rowBytes);
Q_ASSERT(readBytes == rowBytes);
+ (void)readBytes;
}
QImage thumb = thumbnail(snapshot);
}
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();
emit foundThumbnails(thumbnails);
}
+ if (isProfiling() && profile) {
+ emit foundProfile(profile);
+ }
+
if (!errors.isEmpty()) {
emit retraceErrors(errors);
}