mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:38:02 +02:00
FIx the context stats
This commit is contained in:
parent
f274ef1a59
commit
bcef138545
4 changed files with 41 additions and 14 deletions
|
@ -27,9 +27,7 @@ void GL45Backend::resetInputStage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL45Backend::updateInput() {
|
void GL45Backend::updateInput() {
|
||||||
|
|
||||||
if (_input._invalidFormat) {
|
if (_input._invalidFormat) {
|
||||||
|
|
||||||
InputStageState::ActivationCache newActivation;
|
InputStageState::ActivationCache newActivation;
|
||||||
|
|
||||||
// Assign the vertex format required
|
// Assign the vertex format required
|
||||||
|
|
|
@ -13,6 +13,23 @@
|
||||||
#include "GPULogging.h"
|
#include "GPULogging.h"
|
||||||
using namespace gpu;
|
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::CreateBackend Context::_createBackendCallback = nullptr;
|
||||||
Context::MakeProgram Context::_makeProgramCallback = nullptr;
|
Context::MakeProgram Context::_makeProgramCallback = nullptr;
|
||||||
std::once_flag Context::_initialized;
|
std::once_flag Context::_initialized;
|
||||||
|
@ -69,6 +86,10 @@ void Context::consumeFrameUpdates(const FramePointer& frame) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Context::executeFrame(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
|
// FIXME? probably not necessary, but safe
|
||||||
consumeFrameUpdates(frame);
|
consumeFrameUpdates(frame);
|
||||||
_backend->setStereoState(frame->stereoState);
|
_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
|
ContextStats endStats;
|
||||||
getFrameStats(_frameStats);
|
getStats(endStats);
|
||||||
|
_frameStats.evalDelta(beginStats, endStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Context::makeProgram(Shader& shader, const Shader::BindingSet& bindings) {
|
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);
|
_backend->downloadFramebuffer(srcFramebuffer, region, destImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Context::resetStats() const {
|
||||||
|
_backend->resetStats();
|
||||||
|
}
|
||||||
|
|
||||||
void Context::getStats(ContextStats& stats) const {
|
void Context::getStats(ContextStats& stats) const {
|
||||||
_backend->getStats(stats);
|
_backend->getStats(stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Context::getFrameStats(ContextStats& stats) const {
|
void Context::getFrameStats(ContextStats& stats) const {
|
||||||
memcpy(&stats, &_frameStats, sizeof(ContextStats));
|
stats = _frameStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Backend::TransformCamera& Backend::TransformCamera::recomputeDerived(const Transform& xformView) const {
|
const Backend::TransformCamera& Backend::TransformCamera::recomputeDerived(const Transform& xformView) const {
|
||||||
|
|
|
@ -45,6 +45,8 @@ public:
|
||||||
|
|
||||||
ContextStats() {}
|
ContextStats() {}
|
||||||
ContextStats(const ContextStats& stats) = default;
|
ContextStats(const ContextStats& stats) = default;
|
||||||
|
|
||||||
|
void evalDelta(const ContextStats& begin, const ContextStats& end);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Backend {
|
class Backend {
|
||||||
|
@ -83,6 +85,7 @@ public:
|
||||||
return reinterpret_cast<T*>(object.gpuObject.getGPUObject());
|
return reinterpret_cast<T*>(object.gpuObject.getGPUObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void resetStats() const { _stats = ContextStats(); }
|
||||||
void getStats(ContextStats& stats) const { stats = _stats; }
|
void getStats(ContextStats& stats) const { stats = _stats; }
|
||||||
|
|
||||||
virtual bool isTextureManagementSparseEnabled() const = 0;
|
virtual bool isTextureManagementSparseEnabled() const = 0;
|
||||||
|
@ -124,7 +127,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
friend class Context;
|
friend class Context;
|
||||||
ContextStats _stats;
|
mutable ContextStats _stats;
|
||||||
StereoState _stereo;
|
StereoState _stereo;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -202,6 +205,7 @@ public:
|
||||||
void downloadFramebuffer(const FramebufferPointer& srcFramebuffer, const Vec4i& region, QImage& destImage);
|
void downloadFramebuffer(const FramebufferPointer& srcFramebuffer, const Vec4i& region, QImage& destImage);
|
||||||
|
|
||||||
// Repporting stats of the context
|
// Repporting stats of the context
|
||||||
|
void resetStats() const;
|
||||||
void getStats(ContextStats& stats) const;
|
void getStats(ContextStats& stats) const;
|
||||||
|
|
||||||
// Same as above but grabbed at every end of a frame
|
// Same as above but grabbed at every end of a frame
|
||||||
|
|
|
@ -35,22 +35,21 @@ void EngineStats::run(const SceneContextPointer& sceneContext, const RenderConte
|
||||||
config->textureGPUVirtualMemoryUsage = gpu::Texture::getTextureGPUVirtualMemoryUsage();
|
config->textureGPUVirtualMemoryUsage = gpu::Texture::getTextureGPUVirtualMemoryUsage();
|
||||||
config->textureGPUTransferCount = gpu::Texture::getTextureGPUTransferCount();
|
config->textureGPUTransferCount = gpu::Texture::getTextureGPUTransferCount();
|
||||||
|
|
||||||
gpu::ContextStats gpuStats(_gpuStats);
|
|
||||||
renderContext->args->_context->getFrameStats(_gpuStats);
|
renderContext->args->_context->getFrameStats(_gpuStats);
|
||||||
|
|
||||||
config->frameAPIDrawcallCount = _gpuStats._DSNumAPIDrawcalls - gpuStats._DSNumAPIDrawcalls;
|
config->frameAPIDrawcallCount = _gpuStats._DSNumAPIDrawcalls;
|
||||||
config->frameDrawcallCount = _gpuStats._DSNumDrawcalls - gpuStats._DSNumDrawcalls;
|
config->frameDrawcallCount = _gpuStats._DSNumDrawcalls;
|
||||||
config->frameDrawcallRate = config->frameDrawcallCount * frequency;
|
config->frameDrawcallRate = config->frameDrawcallCount * frequency;
|
||||||
|
|
||||||
config->frameTriangleCount = _gpuStats._DSNumTriangles - gpuStats._DSNumTriangles;
|
config->frameTriangleCount = _gpuStats._DSNumTriangles;
|
||||||
config->frameTriangleRate = config->frameTriangleCount * frequency;
|
config->frameTriangleRate = config->frameTriangleCount * frequency;
|
||||||
|
|
||||||
config->frameTextureCount = _gpuStats._RSNumTextureBounded - gpuStats._RSNumTextureBounded;
|
config->frameTextureCount = _gpuStats._RSNumTextureBounded;
|
||||||
config->frameTextureRate = config->frameTextureCount * frequency;
|
config->frameTextureRate = config->frameTextureCount * frequency;
|
||||||
config->frameTextureMemoryUsage = _gpuStats._RSAmountTextureMemoryBounded - gpuStats._RSAmountTextureMemoryBounded;
|
config->frameTextureMemoryUsage = _gpuStats._RSAmountTextureMemoryBounded;
|
||||||
|
|
||||||
config->frameSetPipelineCount = _gpuStats._PSNumSetPipelines - gpuStats._PSNumSetPipelines;
|
config->frameSetPipelineCount = _gpuStats._PSNumSetPipelines;
|
||||||
config->frameSetInputFormatCount = _gpuStats._ISNumFormatChanges - gpuStats._ISNumFormatChanges;
|
config->frameSetInputFormatCount = _gpuStats._ISNumFormatChanges;
|
||||||
|
|
||||||
config->emitDirty();
|
config->emitDirty();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue