Merge pull request #2168 from N8n5h/debug-console-atlas

Add profiling of shadow map atlas logic to debug console
This commit is contained in:
Lubos Lenco 2021-04-25 09:35:52 +02:00 committed by GitHub
commit a4e9ad945b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 0 deletions

View file

@ -113,6 +113,7 @@ class Inc {
#end
// add new lights to the atlases
#if arm_debug
beginShadowsLogicProfile();
// reset data on rejected lights
for (atlas in ShadowMapAtlas.shadowMapAtlases) {
atlas.rejectedLights = [];
@ -174,6 +175,9 @@ class Inc {
var face = 0;
var faces = ShadowMapTile.tilesLightType(tile.light.data.raw.type);
#if arm_debug
beginShadowsRenderProfile();
#end
tile.forEachTileLinked(function (lTile) {
if (faces > 1) {
#if arm_csm
@ -190,6 +194,9 @@ class Inc {
path.drawMeshesStream("shadowmap");
});
#if arm_debug
endShadowsRenderProfile();
#end
path.currentFace = -1;
}
@ -212,6 +219,9 @@ class Inc {
tile.freeTile();
}
}
#if arm_debug
endShadowsLogicProfile();
#end
#end // rp_shadowmap
}
#else
@ -527,6 +537,25 @@ class Inc {
return null;
#end
}
#if arm_debug
public static var shadowsLogicTime = 0.0;
public static var shadowsRenderTime = 0.0;
static var startShadowsLogicTime = 0.0;
static var startShadowsRenderTime = 0.0;
static var callBackSetup = false;
static function setupEndFrameCallback() {
if (!callBackSetup) {
callBackSetup = true;
iron.App.endFrameCallbacks.push(endFrame);
}
}
static function beginShadowsLogicProfile() { setupEndFrameCallback(); startShadowsLogicTime = kha.Scheduler.realTime(); }
static function beginShadowsRenderProfile() { startShadowsRenderTime = kha.Scheduler.realTime(); }
static function endShadowsLogicProfile() { shadowsLogicTime += kha.Scheduler.realTime() - startShadowsLogicTime - shadowsRenderTime; }
static function endShadowsRenderProfile() { shadowsRenderTime += kha.Scheduler.realTime() - startShadowsRenderTime; }
public static function endFrame() { shadowsLogicTime = 0; shadowsRenderTime = 0; }
#end
}
#if arm_shadowmap_atlas

View file

@ -68,6 +68,10 @@ class DebugConsole extends Trait {
#if arm_shadowmap_atlas
var lightColorMap: Map<String, Int> = new Map();
var lightColorMapCount = 0;
var smaLogicTime = 0.0;
var smaLogicTimeAvg = 0.0;
var smaRenderTime = 0.0;
var smaRenderTimeAvg = 0.0;
#end
public function new(scaleFactor = 1.0, scaleDebugConsole = 1.0, positionDebugConsole = 2, visibleDebugConsole = 1,
@ -483,6 +487,16 @@ 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 (Logic)");
ui.text(Math.round(smaLogicTimeAvg * 10000) / 10 + " ms", Align.Right);
ui.row(lrow);
ui.text("Shadow Map Atlas (Render)");
ui.text(Math.round(smaRenderTimeAvg * 10000) / 10 + " ms", Align.Right);
#end
ui.unindent();
}
@ -868,6 +882,14 @@ class DebugConsole extends Trait {
animTimeAvg = animTime / frames;
physTimeAvg = physTime / frames;
#if arm_shadowmap_atlas
smaLogicTimeAvg = smaLogicTime / frames;
smaLogicTime = 0;
smaRenderTimeAvg = smaRenderTime / frames;
smaRenderTime = 0;
#end
totalTime = 0;
renderPathTime = 0;
updateTime = 0;
@ -892,6 +914,10 @@ class DebugConsole extends Trait {
#if arm_physics
physTime += armory.trait.physics.PhysicsWorld.physTime;
#end
#if arm_shadowmap_atlas
smaLogicTime += armory.renderpath.Inc.shadowsLogicTime;
smaRenderTime += armory.renderpath.Inc.shadowsRenderTime;
#end
}
static function roundfp(f: Float, precision = 2): Float {