- Add stat shadowmap to get performance for the upload part of the shadow maps

This commit is contained in:
Magnus Norddahl 2017-06-03 19:24:54 +02:00
parent 7edb75d299
commit 797cb94b4f
1 changed files with 26 additions and 0 deletions

View File

@ -33,6 +33,7 @@
#include "gl/shaders/gl_shadowmapshader.h" #include "gl/shaders/gl_shadowmapshader.h"
#include "r_state.h" #include "r_state.h"
#include "g_levellocals.h" #include "g_levellocals.h"
#include "stats.h"
/* /*
The 1D shadow maps are stored in a 1024x1024 texture as float depth values (R32F). 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. 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() void FShadowMap::Update()
{ {
UpdateCycles.Reset();
LightsProcessed = 0;
LightsShadowmapped = 0;
if (!IsEnabled()) if (!IsEnabled())
return; return;
UpdateCycles.Clock();
UploadAABBTree(); UploadAABBTree();
UploadLights(); UploadLights();
@ -98,6 +119,8 @@ void FShadowMap::Update()
GLRenderer->mBuffers->BindShadowMapTexture(16); GLRenderer->mBuffers->BindShadowMapTexture(16);
FGLDebug::PopGroup(); FGLDebug::PopGroup();
UpdateCycles.Unclock();
} }
bool FShadowMap::ShadowTest(ADynamicLight *light, const DVector3 &pos) bool FShadowMap::ShadowTest(ADynamicLight *light, const DVector3 &pos)
@ -133,8 +156,11 @@ void FShadowMap::UploadLights()
TThinkerIterator<ADynamicLight> it(STAT_DLIGHT); TThinkerIterator<ADynamicLight> it(STAT_DLIGHT);
while (auto light = it.Next()) while (auto light = it.Next())
{ {
LightsProcessed++;
if (light->shadowmapped) if (light->shadowmapped)
{ {
LightsShadowmapped++;
mLightToShadowmap[light] = lightindex >> 2; mLightToShadowmap[light] = lightindex >> 2;
mLights[lightindex] = light->X(); mLights[lightindex] = light->X();