mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 04:15:14 -04:00
render stats: show draw time
This commit is contained in:
parent
c587cf76de
commit
70f762128e
@ -94,7 +94,7 @@ class DebugHUDElement(guiRenderer: GUIRenderer) : Element(guiRenderer), Layouted
|
|||||||
val layout = RowLayout(guiRenderer)
|
val layout = RowLayout(guiRenderer)
|
||||||
layout.margin = Vec4(2)
|
layout.margin = Vec4(2)
|
||||||
layout += TextElement(guiRenderer, TextComponent(RunConfiguration.APPLICATION_NAME, ChatColors.RED))
|
layout += TextElement(guiRenderer, TextComponent(RunConfiguration.APPLICATION_NAME, ChatColors.RED))
|
||||||
layout += AutoTextElement(guiRenderer, 1) { "FPS §d${context.renderStats.smoothAvgFPS.rounded10}§r; t=§d${context.renderStats.avgFrameTime.avg.formatNanos()}" }
|
layout += AutoTextElement(guiRenderer, 1) { "FPS §d${context.renderStats.smoothAvgFPS.rounded10}§r; t=§d${context.renderStats.avgDrawTime.avg.formatNanos().replace('µ', 'u')}" } // rendering of µ eventually broken
|
||||||
context.renderer[ChunkRenderer]?.apply {
|
context.renderer[ChunkRenderer]?.apply {
|
||||||
layout += AutoTextElement(guiRenderer, 1) { "C v=${visible.sizeString}, l=${loaded.size.format()}, cQ=${culledQueue.size.format()}, q=${meshingQueue.size.format()}, pT=${meshingQueue.tasks.size.format()}/${meshingQueue.tasks.max.format()}, lQ=${loadingQueue.size.format()}/${meshingQueue.maxMeshesToLoad.format()}, w=${connection.world.chunks.chunks.size.format()}" }
|
layout += AutoTextElement(guiRenderer, 1) { "C v=${visible.sizeString}, l=${loaded.size.format()}, cQ=${culledQueue.size.format()}, q=${meshingQueue.size.format()}, pT=${meshingQueue.tasks.size.format()}/${meshingQueue.tasks.max.format()}, lQ=${loadingQueue.size.format()}/${meshingQueue.maxMeshesToLoad.format()}, w=${connection.world.chunks.chunks.size.format()}" }
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2021 Moritz Zwerger
|
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -16,6 +16,7 @@ package de.bixilon.minosoft.gui.rendering.stats
|
|||||||
import de.bixilon.kutil.avg.Average
|
import de.bixilon.kutil.avg.Average
|
||||||
|
|
||||||
interface AbstractRenderStats {
|
interface AbstractRenderStats {
|
||||||
|
val avgDrawTime: Average<Long>
|
||||||
val avgFrameTime: Average<Long>
|
val avgFrameTime: Average<Long>
|
||||||
|
|
||||||
val avgFPS: Double
|
val avgFPS: Double
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -18,7 +18,6 @@ import de.bixilon.kutil.avg.Average
|
|||||||
import de.bixilon.kutil.avg.LongAverage
|
import de.bixilon.kutil.avg.LongAverage
|
||||||
import de.bixilon.kutil.random.RandomUtil.nextFloat
|
import de.bixilon.kutil.random.RandomUtil.nextFloat
|
||||||
import de.bixilon.kutil.random.RandomUtil.nextInt
|
import de.bixilon.kutil.random.RandomUtil.nextInt
|
||||||
import de.bixilon.kutil.time.TimeUtil
|
|
||||||
import de.bixilon.kutil.time.TimeUtil.millis
|
import de.bixilon.kutil.time.TimeUtil.millis
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@ -30,6 +29,7 @@ class ExperimentalRenderStats : AbstractRenderStats {
|
|||||||
private val baseJitter = random.nextInt(0, 20)
|
private val baseJitter = random.nextInt(0, 20)
|
||||||
|
|
||||||
override val avgFrameTime: Average<Long> = LongAverage(Long.MAX_VALUE)
|
override val avgFrameTime: Average<Long> = LongAverage(Long.MAX_VALUE)
|
||||||
|
override val avgDrawTime: Average<Long> = LongAverage(Long.MAX_VALUE)
|
||||||
|
|
||||||
private var lastSmoothFPSCalculationTime = 0L
|
private var lastSmoothFPSCalculationTime = 0L
|
||||||
override var smoothAvgFPS: Double = 0.0
|
override var smoothAvgFPS: Double = 0.0
|
||||||
@ -61,6 +61,7 @@ class ExperimentalRenderStats : AbstractRenderStats {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
avgFrameTime.add(5000000L) // ToDo: Add real stats
|
avgFrameTime.add(5000000L) // ToDo: Add real stats
|
||||||
|
avgFrameTime.add(5000000L) // ToDo: Add real stats
|
||||||
}
|
}
|
||||||
|
|
||||||
override val totalFrames: Long
|
override val totalFrames: Long
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -14,10 +14,10 @@
|
|||||||
package de.bixilon.minosoft.gui.rendering.stats
|
package de.bixilon.minosoft.gui.rendering.stats
|
||||||
|
|
||||||
import de.bixilon.kutil.avg.LongAverage
|
import de.bixilon.kutil.avg.LongAverage
|
||||||
import de.bixilon.kutil.time.TimeUtil
|
|
||||||
import de.bixilon.kutil.time.TimeUtil.millis
|
import de.bixilon.kutil.time.TimeUtil.millis
|
||||||
|
|
||||||
class RenderStats : AbstractRenderStats {
|
class RenderStats : AbstractRenderStats {
|
||||||
|
override val avgDrawTime: LongAverage = LongAverage(1L * 1000000000L, Long.MAX_VALUE) // 1 second * SECOND_SCALE
|
||||||
override val avgFrameTime: LongAverage = LongAverage(1L * 1000000000L, Long.MAX_VALUE) // 1 second * SECOND_SCALE
|
override val avgFrameTime: LongAverage = LongAverage(1L * 1000000000L, Long.MAX_VALUE) // 1 second * SECOND_SCALE
|
||||||
override var totalFrames: Long = 0L
|
override var totalFrames: Long = 0L
|
||||||
private set
|
private set
|
||||||
@ -56,7 +56,13 @@ class RenderStats : AbstractRenderStats {
|
|||||||
|
|
||||||
avgFrameTime += delta
|
avgFrameTime += delta
|
||||||
|
|
||||||
|
|
||||||
totalFrames++
|
totalFrames++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun endDraw() {
|
||||||
|
val time = System.nanoTime()
|
||||||
|
val delta = time - lastFrameStartTime
|
||||||
|
|
||||||
|
avgDrawTime += delta
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user