fence + getter
This commit is contained in:
@@ -195,4 +195,8 @@ public class RenderService<T extends AbstractSectionRenderer<J, ?>, J extends Vi
|
|||||||
public Viewport<?> getViewport() {
|
public Viewport<?> getViewport() {
|
||||||
return this.viewportSelector.getViewport();
|
return this.viewportSelector.getViewport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMeshQueueCount() {
|
||||||
|
return this.renderGen.getTaskCount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,13 +137,16 @@ public class VoxyRenderSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (false) {
|
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;
|
float CHANGE_PER_SECOND = 30;
|
||||||
//Auto fps targeting
|
//Auto fps targeting
|
||||||
if (MinecraftClient.getInstance().getCurrentFps() < 45) {
|
if (MinecraftClient.getInstance().getCurrentFps() < 45) {
|
||||||
VoxyConfig.CONFIG.subDivisionSize = Math.min(VoxyConfig.CONFIG.subDivisionSize + CHANGE_PER_SECOND / Math.max(1f, MinecraftClient.getInstance().getCurrentFps()), 256);
|
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);
|
VoxyConfig.CONFIG.subDivisionSize = Math.max(VoxyConfig.CONFIG.subDivisionSize - CHANGE_PER_SECOND / Math.max(1f, MinecraftClient.getInstance().getCurrentFps()), 30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,4 +213,8 @@ public class RenderGenerationService {
|
|||||||
public void addDebugData(List<String> debug) {
|
public void addDebugData(List<String> debug) {
|
||||||
debug.add("RSSQ: " + this.taskQueue.size());//render section service queue
|
debug.add("RSSQ: " + this.taskQueue.size());//render section service queue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTaskCount() {
|
||||||
|
return this.taskQueue.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import me.cortex.voxy.common.util.VolatileHolder;
|
|||||||
import me.cortex.voxy.common.world.other.Mapper;
|
import me.cortex.voxy.common.world.other.Mapper;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.lang.invoke.VarHandle;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@ public class ActiveSectionTracker {
|
|||||||
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
{
|
{
|
||||||
|
VarHandle.fullFence();
|
||||||
holder = cache.get(key);
|
holder = cache.get(key);
|
||||||
if (holder == null) {
|
if (holder == null) {
|
||||||
holder = new VolatileHolder<>();
|
holder = new VolatileHolder<>();
|
||||||
@@ -70,6 +72,7 @@ public class ActiveSectionTracker {
|
|||||||
lock.unlock();
|
lock.unlock();
|
||||||
return section;
|
return section;
|
||||||
}
|
}
|
||||||
|
VarHandle.fullFence();
|
||||||
}
|
}
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
@@ -136,6 +139,7 @@ public class ActiveSectionTracker {
|
|||||||
final var lock = this.locks[index];
|
final var lock = this.locks[index];
|
||||||
lock.lock();
|
lock.lock();
|
||||||
{
|
{
|
||||||
|
VarHandle.fullFence();
|
||||||
if (section.trySetFreed()) {
|
if (section.trySetFreed()) {
|
||||||
var cached = cache.remove(section.key);
|
var cached = cache.remove(section.key);
|
||||||
var obj = cached.obj;
|
var obj = cached.obj;
|
||||||
@@ -144,6 +148,7 @@ public class ActiveSectionTracker {
|
|||||||
}
|
}
|
||||||
sec = section;
|
sec = section;
|
||||||
}
|
}
|
||||||
|
VarHandle.fullFence();
|
||||||
}
|
}
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user