Adding the frame gpu and batch timer

This commit is contained in:
samcake 2016-11-04 11:49:52 -07:00
parent 3db1831841
commit 76aa541d4a
5 changed files with 46 additions and 2 deletions

View file

@ -189,6 +189,15 @@ Item {
Column {
id: octreeCol
spacing: 4; x: 4; y: 4;
StatText {
text: " Frame timing:"
}
StatText {
text: " Batch: " + root.batchFrameTime.toFixed(1) + " ms"
}
StatText {
text: " GPU: " + root.gpuFrameTime.toFixed(1) + " ms"
}
StatText {
text: "Triangles: " + root.triangles +
" / Material Switches: " + root.materialSwitches

View file

@ -1240,7 +1240,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
properties["gl_info"] = glInfo;
properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemory());
properties["gpu_free_memory"] = (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemory());
properties["gpu_frame_time"] = (int)(qApp->getRenderEngine()->);
properties["gpu_frame_time"] = (float)(qApp->getGPUContext()->getFrameTimerGPUAverage());
properties["batch_frame_time"] = (float)(qApp->getGPUContext()->getFrameTimerBatchAverage());
properties["ideal_thread_count"] = QThread::idealThreadCount();
auto hmdHeadPose = getHMDSensorPose();

View file

@ -290,6 +290,12 @@ void Stats::updateStats(bool force) {
STAT_UPDATE(sendingMode, sendingModeResult);
}
auto& GPUContext = qApp->getGPUContext();
// Update Frame timing (in ms)
STAT_UPDATE(gpuFrameTime, (float) GPUContext->getFrameTimerGPUAverage());
STAT_UPDATE(batchFrameTime, (float)GPUContext->getFrameTimerBatchAverage());
STAT_UPDATE(gpuBuffers, (int)gpu::Context::getBufferGPUCount());
STAT_UPDATE(gpuBufferMemory, (int)BYTES_TO_MB(gpu::Context::getBufferGPUMemoryUsage()));
STAT_UPDATE(gpuTextures, (int)gpu::Context::getTextureGPUCount());

View file

@ -101,6 +101,8 @@ class Stats : public QQuickItem {
STATS_PROPERTY(int, gpuTextureSparseMemory, 0)
STATS_PROPERTY(int, gpuSparseTextureEnabled, 0)
STATS_PROPERTY(int, gpuFreeMemory, 0)
STATS_PROPERTY(float, gpuFrameTime, 0)
STATS_PROPERTY(float, batchFrameTime, 0)
public:
static Stats* getInstance();
@ -198,6 +200,8 @@ signals:
void gpuTextureSparseMemoryChanged();
void gpuSparseTextureEnabledChanged();
void gpuFreeMemoryChanged();
void gpuFrameTimeChanged();
void batchFrameTimeChanged();
void rectifiedTextureCountChanged();
void decimatedTextureCountChanged();

View file

@ -36,7 +36,7 @@ void Context::beginFrame(const glm::mat4& renderPose) {
_currentFrame->pose = renderPose;
if (!_frameRangeTimer) {
_frameRangeTimer = std::make_shared<RangeTimer>("gpu::Frame");
_frameRangeTimer = std::make_shared<RangeTimer>();
}
}
@ -77,10 +77,18 @@ void Context::executeFrame(const FramePointer& frame) const {
consumeFrameUpdates(frame);
_backend->setStereoState(frame->stereoState);
{
Batch beginBatch;
_frameRangeTimer->begin(beginBatch);
_backend->render(beginBatch);
// Execute the frame rendering commands
for (auto& batch : frame->batches) {
_backend->render(batch);
}
Batch endBatch;
_frameRangeTimer->end(endBatch);
_backend->render(endBatch);
}
}
@ -131,6 +139,20 @@ void Context::getStats(ContextStats& stats) const {
_backend->getStats(stats);
}
double Context::getFrameTimerGPUAverage() const {
if (_frameRangeTimer) {
return _frameRangeTimer->getGPUAverage();
}
return 0.0;
}
double Context::getFrameTimerBatchAverage() const {
if (_frameRangeTimer) {
return _frameRangeTimer->getBatchAverage();
}
return 0.0;
}
const Backend::TransformCamera& Backend::TransformCamera::recomputeDerived(const Transform& xformView) const {
_projectionInverse = glm::inverse(_projection);
@ -357,3 +379,5 @@ void Backend::updateTextureGPUFramebufferMemoryUsage(Resource::Size prevObjectSi
void Backend::updateTextureGPUSparseMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUSparseMemoryUsage(prevObjectSize, newObjectSize); }
void Backend::incrementTextureGPUTransferCount() { Context::incrementTextureGPUTransferCount(); }
void Backend::decrementTextureGPUTransferCount() { Context::decrementTextureGPUTransferCount(); }