FIx the context stats

This commit is contained in:
sam 2016-11-04 18:59:30 -07:00
parent f274ef1a59
commit bcef138545
4 changed files with 41 additions and 14 deletions

View file

@ -27,9 +27,7 @@ void GL45Backend::resetInputStage() {
}
void GL45Backend::updateInput() {
if (_input._invalidFormat) {
InputStageState::ActivationCache newActivation;
// Assign the vertex format required

View file

@ -13,6 +13,23 @@
#include "GPULogging.h"
using namespace gpu;
void ContextStats::evalDelta(const ContextStats& begin, const ContextStats& end) {
_ISNumFormatChanges = end._ISNumFormatChanges - begin._ISNumFormatChanges;
_ISNumInputBufferChanges = end._ISNumInputBufferChanges - begin._ISNumInputBufferChanges;
_ISNumIndexBufferChanges = end._ISNumIndexBufferChanges - begin._ISNumIndexBufferChanges;
_RSNumTextureBounded = end._RSNumTextureBounded - begin._RSNumTextureBounded;
_RSAmountTextureMemoryBounded = end._RSAmountTextureMemoryBounded - begin._RSAmountTextureMemoryBounded;
_DSNumAPIDrawcalls = end._DSNumAPIDrawcalls - begin._DSNumAPIDrawcalls;
_DSNumDrawcalls = end._DSNumDrawcalls - begin._DSNumDrawcalls;
_DSNumTriangles= end._DSNumTriangles - begin._DSNumTriangles;
_PSNumSetPipelines = end._PSNumSetPipelines - begin._PSNumSetPipelines;
}
Context::CreateBackend Context::_createBackendCallback = nullptr;
Context::MakeProgram Context::_makeProgramCallback = nullptr;
std::once_flag Context::_initialized;
@ -69,6 +86,10 @@ void Context::consumeFrameUpdates(const FramePointer& frame) const {
}
void Context::executeFrame(const FramePointer& frame) const {
// Grab the stats at the around the frame and delta to have a consistent sampling
ContextStats beginStats;
getStats(beginStats);
// FIXME? probably not necessary, but safe
consumeFrameUpdates(frame);
_backend->setStereoState(frame->stereoState);
@ -79,8 +100,9 @@ void Context::executeFrame(const FramePointer& frame) const {
}
}
// Grab the stats at the end of the frame that just executed so we can have a consistent sampling
getFrameStats(_frameStats);
ContextStats endStats;
getStats(endStats);
_frameStats.evalDelta(beginStats, endStats);
}
bool Context::makeProgram(Shader& shader, const Shader::BindingSet& bindings) {
@ -126,12 +148,16 @@ void Context::downloadFramebuffer(const FramebufferPointer& srcFramebuffer, cons
_backend->downloadFramebuffer(srcFramebuffer, region, destImage);
}
void Context::resetStats() const {
_backend->resetStats();
}
void Context::getStats(ContextStats& stats) const {
_backend->getStats(stats);
}
void Context::getFrameStats(ContextStats& stats) const {
memcpy(&stats, &_frameStats, sizeof(ContextStats));
stats = _frameStats;
}
const Backend::TransformCamera& Backend::TransformCamera::recomputeDerived(const Transform& xformView) const {

View file

@ -45,6 +45,8 @@ public:
ContextStats() {}
ContextStats(const ContextStats& stats) = default;
void evalDelta(const ContextStats& begin, const ContextStats& end);
};
class Backend {
@ -83,6 +85,7 @@ public:
return reinterpret_cast<T*>(object.gpuObject.getGPUObject());
}
void resetStats() const { _stats = ContextStats(); }
void getStats(ContextStats& stats) const { stats = _stats; }
virtual bool isTextureManagementSparseEnabled() const = 0;
@ -124,7 +127,7 @@ protected:
}
friend class Context;
ContextStats _stats;
mutable ContextStats _stats;
StereoState _stereo;
};
@ -202,6 +205,7 @@ public:
void downloadFramebuffer(const FramebufferPointer& srcFramebuffer, const Vec4i& region, QImage& destImage);
// Repporting stats of the context
void resetStats() const;
void getStats(ContextStats& stats) const;
// Same as above but grabbed at every end of a frame

View file

@ -35,22 +35,21 @@ void EngineStats::run(const SceneContextPointer& sceneContext, const RenderConte
config->textureGPUVirtualMemoryUsage = gpu::Texture::getTextureGPUVirtualMemoryUsage();
config->textureGPUTransferCount = gpu::Texture::getTextureGPUTransferCount();
gpu::ContextStats gpuStats(_gpuStats);
renderContext->args->_context->getFrameStats(_gpuStats);
config->frameAPIDrawcallCount = _gpuStats._DSNumAPIDrawcalls - gpuStats._DSNumAPIDrawcalls;
config->frameDrawcallCount = _gpuStats._DSNumDrawcalls - gpuStats._DSNumDrawcalls;
config->frameAPIDrawcallCount = _gpuStats._DSNumAPIDrawcalls;
config->frameDrawcallCount = _gpuStats._DSNumDrawcalls;
config->frameDrawcallRate = config->frameDrawcallCount * frequency;
config->frameTriangleCount = _gpuStats._DSNumTriangles - gpuStats._DSNumTriangles;
config->frameTriangleCount = _gpuStats._DSNumTriangles;
config->frameTriangleRate = config->frameTriangleCount * frequency;
config->frameTextureCount = _gpuStats._RSNumTextureBounded - gpuStats._RSNumTextureBounded;
config->frameTextureCount = _gpuStats._RSNumTextureBounded;
config->frameTextureRate = config->frameTextureCount * frequency;
config->frameTextureMemoryUsage = _gpuStats._RSAmountTextureMemoryBounded - gpuStats._RSAmountTextureMemoryBounded;
config->frameTextureMemoryUsage = _gpuStats._RSAmountTextureMemoryBounded;
config->frameSetPipelineCount = _gpuStats._PSNumSetPipelines - gpuStats._PSNumSetPipelines;
config->frameSetInputFormatCount = _gpuStats._ISNumFormatChanges - gpuStats._ISNumFormatChanges;
config->frameSetPipelineCount = _gpuStats._PSNumSetPipelines;
config->frameSetInputFormatCount = _gpuStats._ISNumFormatChanges;
config->emitDirty();
}