Respect 'debugFrames' subsystem config option
This commit is contained in:
parent
7a7da3729c
commit
10e3b26ac0
2 changed files with 17 additions and 6 deletions
|
@ -23,6 +23,7 @@ import de.staropensource.engine.base.implementable.Configuration;
|
||||||
import de.staropensource.engine.base.utility.PropertiesReader;
|
import de.staropensource.engine.base.utility.PropertiesReader;
|
||||||
import de.staropensource.engine.windowing.event.RenderingErrorEvent;
|
import de.staropensource.engine.windowing.event.RenderingErrorEvent;
|
||||||
import de.staropensource.engine.windowing.event.WindowingErrorEvent;
|
import de.staropensource.engine.windowing.event.WindowingErrorEvent;
|
||||||
|
import de.staropensource.engine.windowing.implementable.api.ApiManagementClass;
|
||||||
import de.staropensource.engine.windowing.type.window.VsyncMode;
|
import de.staropensource.engine.windowing.type.window.VsyncMode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -90,8 +91,11 @@ public final class WindowingSubsystemConfiguration extends Configuration {
|
||||||
private boolean debugInput;
|
private boolean debugInput;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If enabled, will log the delta time average and FPS count
|
* If enabled, will log the delta time average
|
||||||
* to the console every second.
|
* and FPS count to the console every second.
|
||||||
|
* <p>
|
||||||
|
* Is applied during rendering thread startup
|
||||||
|
* and will not be applied after.
|
||||||
*
|
*
|
||||||
* @since v1-alpha2
|
* @since v1-alpha2
|
||||||
* -- GETTER --
|
* -- GETTER --
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package de.staropensource.engine.windowing.implementable.api;
|
package de.staropensource.engine.windowing.implementable.api;
|
||||||
|
|
||||||
|
import de.staropensource.engine.base.EngineConfiguration;
|
||||||
import de.staropensource.engine.base.logging.LoggerInstance;
|
import de.staropensource.engine.base.logging.LoggerInstance;
|
||||||
import de.staropensource.engine.base.utility.Math;
|
import de.staropensource.engine.base.utility.Math;
|
||||||
import de.staropensource.engine.base.utility.Miscellaneous;
|
import de.staropensource.engine.base.utility.Miscellaneous;
|
||||||
|
@ -94,9 +95,15 @@ public abstract class ApiManagementClass {
|
||||||
long renderTime; // Amount of time spent rendering
|
long renderTime; // Amount of time spent rendering
|
||||||
long sleepDuration; // Time spent sleeping the thread
|
long sleepDuration; // Time spent sleeping the thread
|
||||||
LinkedList<Long> splitDeltaTime = new LinkedList<>(); // Used for calculating the delta time (render time average over one second)
|
LinkedList<Long> splitDeltaTime = new LinkedList<>(); // Used for calculating the delta time (render time average over one second)
|
||||||
long reportDuration = System.currentTimeMillis(); // Used for determining when to report frame count and delta time
|
long reportDuration = System.currentTimeMillis() + 1000; // Used for determining when to report frame count and delta time
|
||||||
double deltaTime; // Contains the average render time over one second (delta time)
|
double deltaTime; // Contains the average render time over one second (delta time)
|
||||||
|
|
||||||
|
// Check if delta time and frame count shall be printed to console.
|
||||||
|
// Unless this code is ran 292 billion years into the future,
|
||||||
|
// this should sufficiently disable the reporting feature.
|
||||||
|
if (WindowingSubsystemConfiguration.getInstance().isDebugFrames())
|
||||||
|
reportDuration = Long.MAX_VALUE;
|
||||||
|
|
||||||
// Run while the 'output' is empty
|
// Run while the 'output' is empty
|
||||||
while (output.get().isEmpty()) {
|
while (output.get().isEmpty()) {
|
||||||
renderTime = Miscellaneous.measureExecutionTime(() -> {
|
renderTime = Miscellaneous.measureExecutionTime(() -> {
|
||||||
|
@ -121,11 +128,11 @@ public abstract class ApiManagementClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate delta time and frame count every second
|
// Calculate delta time and frame count every second
|
||||||
if (System.currentTimeMillis() >= reportDuration + 1000) {
|
if (System.currentTimeMillis() >= reportDuration) {
|
||||||
deltaTime = Math.getMeanLong(splitDeltaTime); // Calculate delta time
|
deltaTime = Math.getMeanLong(splitDeltaTime); // Calculate delta time
|
||||||
logger.info("Delta time average: " + deltaTime + " | Frames/s: " + 1000 / deltaTime); // Print delta time and frame count to console
|
logger.diag("Delta time average: " + deltaTime + " | Frames/s: " + 1000 / deltaTime); // Print delta time and frame count to console
|
||||||
|
|
||||||
reportDuration = System.currentTimeMillis(); // Update 'reportDuration'
|
reportDuration = System.currentTimeMillis() + 1000; // Update 'reportDuration'
|
||||||
splitDeltaTime.clear(); // Clear 'splitDeltaTime' list
|
splitDeltaTime.clear(); // Clear 'splitDeltaTime' list
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue