fence + getter

This commit is contained in:
mcrcortex
2025-04-08 00:43:02 +10:00
parent 89dfc3c9f2
commit 3569e1d889
4 changed files with 17 additions and 1 deletions

View File

@@ -195,4 +195,8 @@ public class RenderService<T extends AbstractSectionRenderer<J, ?>, J extends Vi
public Viewport<?> getViewport() {
return this.viewportSelector.getViewport();
}
public int getMeshQueueCount() {
return this.renderGen.getTaskCount();
}
}

View File

@@ -137,13 +137,16 @@ public class VoxyRenderSystem {
}
if (false) {
//only increase quality while there are very few mesh queues, this stops,
// e.g. while flying and is rendering alot of low quality chunks
boolean canDecreaseSize = this.renderer.getMeshQueueCount() < 5000;
float CHANGE_PER_SECOND = 30;
//Auto fps targeting
if (MinecraftClient.getInstance().getCurrentFps() < 45) {
VoxyConfig.CONFIG.subDivisionSize = Math.min(VoxyConfig.CONFIG.subDivisionSize + CHANGE_PER_SECOND / Math.max(1f, MinecraftClient.getInstance().getCurrentFps()), 256);
}
if (55 < MinecraftClient.getInstance().getCurrentFps()) {
if (55 < MinecraftClient.getInstance().getCurrentFps() && canDecreaseSize) {
VoxyConfig.CONFIG.subDivisionSize = Math.max(VoxyConfig.CONFIG.subDivisionSize - CHANGE_PER_SECOND / Math.max(1f, MinecraftClient.getInstance().getCurrentFps()), 30);
}
}

View File

@@ -213,4 +213,8 @@ public class RenderGenerationService {
public void addDebugData(List<String> debug) {
debug.add("RSSQ: " + this.taskQueue.size());//render section service queue
}
public int getTaskCount() {
return this.taskQueue.size();
}
}

View File

@@ -6,6 +6,7 @@ import me.cortex.voxy.common.util.VolatileHolder;
import me.cortex.voxy.common.world.other.Mapper;
import org.jetbrains.annotations.Nullable;
import java.lang.invoke.VarHandle;
import java.util.Arrays;
import java.util.concurrent.locks.ReentrantLock;
@@ -58,6 +59,7 @@ public class ActiveSectionTracker {
lock.lock();
{
VarHandle.fullFence();
holder = cache.get(key);
if (holder == null) {
holder = new VolatileHolder<>();
@@ -70,6 +72,7 @@ public class ActiveSectionTracker {
lock.unlock();
return section;
}
VarHandle.fullFence();
}
lock.unlock();
@@ -136,6 +139,7 @@ public class ActiveSectionTracker {
final var lock = this.locks[index];
lock.lock();
{
VarHandle.fullFence();
if (section.trySetFreed()) {
var cached = cache.remove(section.key);
var obj = cached.obj;
@@ -144,6 +148,7 @@ public class ActiveSectionTracker {
}
sec = section;
}
VarHandle.fullFence();
}
lock.unlock();