Further try to improve stuttering (it did not go well)

This commit is contained in:
mcrcortex
2025-04-27 00:30:47 +10:00
parent 65480c5e9f
commit a5361eaad2
2 changed files with 23 additions and 19 deletions

View File

@@ -37,24 +37,6 @@ public class ModelBakerySubsystem {
}
public void tick() {
//There should be a method to access the frame time IIRC, if the user framecap is unlimited lock it to like 60 fps for computation
int BUDGET = 16;//TODO: make this computed based on the remaining free time in a frame (and like div by 2 to reduce overhead) (with a min of 1)
for (int i = 0; i < BUDGET && !this.blockIdQueue.isEmpty(); i++) {
int blockId = -1;
synchronized (this.blockIdQueue) {
if (!this.blockIdQueue.isEmpty()) {
blockId = this.blockIdQueue.removeFirstInt();
VarHandle.fullFence();//Ensure memory coherancy
} else {
break;
}
}
if (blockId != -1) {
this.factory.addEntry(blockId);
}
}
//Upload all biomes
while (!this.biomeQueue.isEmpty()) {
var biome = this.biomeQueue.poll();
@@ -62,6 +44,28 @@ public class ModelBakerySubsystem {
this.factory.addBiome(biome.id, biomeReg.get(Identifier.of(biome.biome)));
}
//There should be a method to access the frame time IIRC, if the user framecap is unlimited lock it to like 60 fps for computation
int BUDGET = 10;//TODO: make this computed based on the remaining free time in a frame (and like div by 2 to reduce overhead) (with a min of 1)
if (!this.blockIdQueue.isEmpty()) {
int[] est = new int[Math.min(this.blockIdQueue.size(), BUDGET)];
int i = 0;
synchronized (this.blockIdQueue) {
for (;i < est.length && !this.blockIdQueue.isEmpty(); i++) {
int blockId = this.blockIdQueue.removeFirstInt();
if (blockId == -1) {
i--;
continue;
}
est[i] = blockId;
}
}
for (int j = 0; j < i; j++) {
this.factory.addEntry(est[j]);
}
}
//Submit is effectively free if nothing is submitted
this.textureDownStream.submit();

View File

@@ -363,7 +363,7 @@ public class RenderDataFactory45 {
{
int idx = index + (pidx*32);
int shift = skipAmount * 32;
int shift = skipAmount * 32 * 2;
//Flip data with respect to facing direction
int iA = idx * 2 + (facingForward == 1 ? 0 : shift);