From 797cb94b4fd015a6ca361bcefad7a5be825ab46a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 3 Jun 2017 19:24:54 +0200 Subject: [PATCH] - Add stat shadowmap to get performance for the upload part of the shadow maps --- src/gl/dynlights/gl_shadowmap.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/gl/dynlights/gl_shadowmap.cpp b/src/gl/dynlights/gl_shadowmap.cpp index 609e09e64..81ed1af73 100644 --- a/src/gl/dynlights/gl_shadowmap.cpp +++ b/src/gl/dynlights/gl_shadowmap.cpp @@ -33,6 +33,7 @@ #include "gl/shaders/gl_shadowmapshader.h" #include "r_state.h" #include "g_levellocals.h" +#include "stats.h" /* The 1D shadow maps are stored in a 1024x1024 texture as float depth values (R32F). @@ -67,11 +68,31 @@ as on the CPU, except everything uses indexes as pointers are not allowed in GLSL. */ +namespace +{ + cycle_t UpdateCycles; + int LightsProcessed; + int LightsShadowmapped; +} + +ADD_STAT(shadowmap) +{ + FString out; + out.Format("upload=%04.2f ms lights=%d shadowmapped=%d", UpdateCycles.TimeMS(), LightsProcessed, LightsShadowmapped); + return out; +} + void FShadowMap::Update() { + UpdateCycles.Reset(); + LightsProcessed = 0; + LightsShadowmapped = 0; + if (!IsEnabled()) return; + UpdateCycles.Clock(); + UploadAABBTree(); UploadLights(); @@ -98,6 +119,8 @@ void FShadowMap::Update() GLRenderer->mBuffers->BindShadowMapTexture(16); FGLDebug::PopGroup(); + + UpdateCycles.Unclock(); } bool FShadowMap::ShadowTest(ADynamicLight *light, const DVector3 &pos) @@ -133,8 +156,11 @@ void FShadowMap::UploadLights() TThinkerIterator it(STAT_DLIGHT); while (auto light = it.Next()) { + LightsProcessed++; if (light->shadowmapped) { + LightsShadowmapped++; + mLightToShadowmap[light] = lightindex >> 2; mLights[lightindex] = light->X();