Also export GPU markers to CSV
This commit is contained in:
parent
58f509d953
commit
c425e7e153
@ -29,6 +29,29 @@
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
|
||||
static const char* GPU_Phase[Q_LAST] =
|
||||
{
|
||||
"Solid Pass 1",
|
||||
"Shadows",
|
||||
"RH",
|
||||
"GI",
|
||||
"Env Map",
|
||||
"SunLight",
|
||||
"PointLights",
|
||||
"SSAO",
|
||||
"Solid Pass 2",
|
||||
"Transparent",
|
||||
"Particles",
|
||||
"Displacement",
|
||||
"Depth of Field",
|
||||
"Godrays",
|
||||
"Bloom",
|
||||
"Tonemap",
|
||||
"Motion Blur",
|
||||
"MLAA",
|
||||
"GUI",
|
||||
};
|
||||
|
||||
Profiler profiler;
|
||||
|
||||
// Unit is in pencentage of the screen dimensions
|
||||
@ -77,6 +100,7 @@ Profiler::Profiler()
|
||||
m_freeze_state = UNFROZEN;
|
||||
m_capture_report = false;
|
||||
m_first_capture_sweep = true;
|
||||
m_first_gpu_capture_sweep = true;
|
||||
m_capture_report_buffer = NULL;
|
||||
}
|
||||
|
||||
@ -93,9 +117,11 @@ void Profiler::setCaptureReport(bool captureReport)
|
||||
{
|
||||
m_capture_report = true;
|
||||
m_first_capture_sweep = true;
|
||||
m_first_gpu_capture_sweep = true;
|
||||
// TODO: a 20 MB hardcoded buffer for now. That should amply suffice for
|
||||
// all reasonable purposes. But it's not too clean to hardcode
|
||||
m_capture_report_buffer = new StringBuffer(20 * 1024 * 1024);
|
||||
m_gpu_capture_report_buffer = new StringBuffer(20 * 1024 * 1024);
|
||||
}
|
||||
else if (m_capture_report && !captureReport)
|
||||
{
|
||||
@ -105,9 +131,19 @@ void Profiler::setCaptureReport(bool captureReport)
|
||||
const char* str = m_capture_report_buffer->getRawBuffer();
|
||||
filewriter.write(str, strlen(str));
|
||||
}
|
||||
{
|
||||
std::ofstream filewriter(file_manager->getUserConfigFile("profiling_gpu.csv").c_str(), std::ios::out | std::ios::binary);
|
||||
const char* str = m_gpu_capture_report_buffer->getRawBuffer();
|
||||
filewriter.write(str, strlen(str));
|
||||
}
|
||||
|
||||
m_capture_report = false;
|
||||
|
||||
delete m_capture_report_buffer;
|
||||
m_capture_report_buffer = NULL;
|
||||
|
||||
delete m_gpu_capture_report_buffer;
|
||||
m_gpu_capture_report_buffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -355,6 +391,20 @@ void Profiler::draw()
|
||||
hovered_gpu_marker = (QueryPerf)i;
|
||||
hovered_gpu_marker_elapsed = irr_driver->getGPUTimer(i).elapsedTimeus();
|
||||
}
|
||||
|
||||
if (m_capture_report)
|
||||
{
|
||||
if (m_first_gpu_capture_sweep)
|
||||
m_gpu_capture_report_buffer->getStdStream() << GPU_Phase[i] << ";";
|
||||
else
|
||||
m_gpu_capture_report_buffer->getStdStream() << elapsed << ";";
|
||||
}
|
||||
}
|
||||
|
||||
if (m_capture_report)
|
||||
{
|
||||
m_gpu_capture_report_buffer->getStdStream() << "\n";
|
||||
m_first_gpu_capture_sweep = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -389,30 +439,8 @@ void Profiler::draw()
|
||||
|
||||
if (hovered_gpu_marker != Q_LAST)
|
||||
{
|
||||
static const char *Phase[Q_LAST] =
|
||||
{
|
||||
"Solid Pass 1",
|
||||
"Shadows",
|
||||
"RH",
|
||||
"GI",
|
||||
"Env Map",
|
||||
"SunLight",
|
||||
"PointLights",
|
||||
"SSAO",
|
||||
"Solid Pass 2",
|
||||
"Transparent",
|
||||
"Particles",
|
||||
"Displacement",
|
||||
"Depth of Field",
|
||||
"Godrays",
|
||||
"Bloom",
|
||||
"Tonemap",
|
||||
"Motion Blur",
|
||||
"MLAA",
|
||||
"GUI",
|
||||
};
|
||||
std::ostringstream oss;
|
||||
oss << Phase[hovered_gpu_marker] << " : " << hovered_gpu_marker_elapsed << " us";
|
||||
oss << GPU_Phase[hovered_gpu_marker] << " : " << hovered_gpu_marker_elapsed << " us";
|
||||
font->draw(oss.str().c_str(), GPU_MARKERS_NAMES_POS, video::SColor(0xFF, 0xFF, 0x00, 0x00));
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,9 @@ private:
|
||||
|
||||
bool m_capture_report;
|
||||
bool m_first_capture_sweep;
|
||||
bool m_first_gpu_capture_sweep;
|
||||
StringBuffer* m_capture_report_buffer;
|
||||
StringBuffer* m_gpu_capture_report_buffer;
|
||||
|
||||
public:
|
||||
Profiler();
|
||||
|
Loading…
x
Reference in New Issue
Block a user