Skip to content

Commit 9895155

Browse files
committed
Fix SPS rolling average for long render passes
Add a hacky fix for when render passes are significantly longer than SPS_AVERAGE_TIME by calculating the average time for a render pass
1 parent d09db86 commit 9895155

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

chunky/src/java/se/llbit/chunky/renderer/DefaultRenderManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,12 @@ private int samplesPerSecond() {
386386
int canvasHeight = bufferedScene.canvasHeight();
387387
long pixelsPerFrame = (long) canvasWidth * canvasHeight;
388388
double renderTime = bufferedScene.renderTime / 1000.0;
389+
390+
// Avoid incorrect output if the average time per render pass were to exceed SPS_AVERAGE_TIME
391+
// Somewhat hacky, as it will break if there is an outlier pass that's >SPS_AVERAGE_TIME, and 0 will be returned
392+
if (renderTime / bufferedScene.spp >= SPS_AVERAGE_TIME)
393+
return (int) ((bufferedScene.spp * pixelsPerFrame) / renderTime);
394+
389395
if (renderTime < SPS_AVERAGE_TIME) {
390396
return (int) ((bufferedScene.spp * pixelsPerFrame) / renderTime);
391397
} else {

0 commit comments

Comments
 (0)