Separate shadow map atlas logic and rendering time

This commit is contained in:
N8n5h 2021-04-24 21:48:24 -03:00
parent 9247b09c88
commit 41c6924231
2 changed files with 34 additions and 14 deletions

View file

@ -113,7 +113,7 @@ class Inc {
#end
// add new lights to the atlases
#if arm_debug
beginProfile();
beginShadowsLogicProfile();
// reset data on rejected lights
for (atlas in ShadowMapAtlas.shadowMapAtlases) {
atlas.rejectedLights = [];
@ -175,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
@ -191,6 +194,9 @@ class Inc {
path.drawMeshesStream("shadowmap");
});
#if arm_debug
endShadowsRenderProfile();
#end
path.currentFace = -1;
}
@ -214,7 +220,7 @@ class Inc {
}
}
#if arm_debug
endProfile();
endShadowsLogicProfile();
#end
#end // rp_shadowmap
}
@ -533,8 +539,10 @@ class Inc {
}
#if arm_debug
public static var shadowMapAtlasTime = 0.0;
static var startTime = 0.0;
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) {
@ -542,9 +550,11 @@ class Inc {
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; }
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
}

View file

@ -68,8 +68,10 @@ 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;
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,
@ -487,8 +489,12 @@ class DebugConsole extends Trait {
#if arm_shadowmap_atlas
ui.row(lrow);
ui.text("Shadow Map Atlas (Script)");
ui.text(Math.round(smaTimeAvg * 10000) / 10 + " ms", Align.Right);
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();
@ -877,8 +883,11 @@ class DebugConsole extends Trait {
physTimeAvg = physTime / frames;
#if arm_shadowmap_atlas
smaTimeAvg = smaTime / frames;
smaTime = 0;
smaLogicTimeAvg = smaLogicTime / frames;
smaLogicTime = 0;
smaRenderTimeAvg = smaRenderTime / frames;
smaRenderTime = 0;
#end
totalTime = 0;
@ -906,7 +915,8 @@ class DebugConsole extends Trait {
physTime += armory.trait.physics.PhysicsWorld.physTime;
#end
#if arm_shadowmap_atlas
smaTime += armory.renderpath.Inc.shadowMapAtlasTime;
smaLogicTime += armory.renderpath.Inc.shadowsLogicTime;
smaRenderTime += armory.renderpath.Inc.shadowsRenderTime;
#end
}