Add profiling of shadow map atlas logic

This commit is contained in:
N8n5h 2021-04-24 20:31:03 -03:00
parent df50ba397e
commit 9247b09c88
2 changed files with 35 additions and 0 deletions

View file

@ -113,6 +113,7 @@ class Inc {
#end
// add new lights to the atlases
#if arm_debug
beginProfile();
// reset data on rejected lights
for (atlas in ShadowMapAtlas.shadowMapAtlases) {
atlas.rejectedLights = [];
@ -212,6 +213,9 @@ class Inc {
tile.freeTile();
}
}
#if arm_debug
endProfile();
#end
#end // rp_shadowmap
}
#else
@ -527,6 +531,21 @@ class Inc {
return null;
#end
}
#if arm_debug
public static var shadowMapAtlasTime = 0.0;
static var startTime = 0.0;
static var callBackSetup = false;
static function setupEndFrameCallback() {
if (!callBackSetup) {
callBackSetup = true;
iron.App.endFrameCallbacks.push(endFrame);
}
}
static function beginProfile() { setupEndFrameCallback(); startTime = kha.Scheduler.realTime(); }
static function endProfile() { shadowMapAtlasTime += kha.Scheduler.realTime() - startTime; }
public static function endFrame() { shadowMapAtlasTime = 0; }
#end
}
#if arm_shadowmap_atlas

View file

@ -68,6 +68,8 @@ class DebugConsole extends Trait {
#if arm_shadowmap_atlas
var lightColorMap: Map<String, Int> = new Map();
var lightColorMapCount = 0;
var smaTime = 0.0;
var smaTimeAvg = 0.0;
#end
public function new(scaleFactor = 1.0, scaleDebugConsole = 1.0, positionDebugConsole = 2, visibleDebugConsole = 1,
@ -483,6 +485,12 @@ class DebugConsole extends Trait {
ui.text("Physics");
ui.text(Math.round(physTimeAvg * 10000) / 10 + " ms", Align.Right);
#if arm_shadowmap_atlas
ui.row(lrow);
ui.text("Shadow Map Atlas (Script)");
ui.text(Math.round(smaTimeAvg * 10000) / 10 + " ms", Align.Right);
#end
ui.unindent();
}
@ -868,6 +876,11 @@ class DebugConsole extends Trait {
animTimeAvg = animTime / frames;
physTimeAvg = physTime / frames;
#if arm_shadowmap_atlas
smaTimeAvg = smaTime / frames;
smaTime = 0;
#end
totalTime = 0;
renderPathTime = 0;
updateTime = 0;
@ -892,6 +905,9 @@ class DebugConsole extends Trait {
#if arm_physics
physTime += armory.trait.physics.PhysicsWorld.physTime;
#end
#if arm_shadowmap_atlas
smaTime += armory.renderpath.Inc.shadowMapAtlasTime;
#end
}
static function roundfp(f: Float, precision = 2): Float {