Skip to content

Commit 9d355aa

Browse files
committed
fix chunks flickering for a single frame when unloading, log size of allocation on error
1 parent a7455cb commit 9d355aa

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/main/java/me/cortex/voxy/client/core/RenderResourceReuse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ static GlBuffer getOrCreateGeometryBuffer() {
8282
error = glGetError();
8383
if (error != GL_NO_ERROR) {
8484
buffer.free();
85-
throw new IllegalStateException("Unable to allocate geometry buffer using workaround, got gl error " + error);
85+
throw new IllegalStateException("Unable to allocate geometry buffer using workaround, got gl error " + error + ". Failed to allocate buffer of size "+capacity);
8686
}
8787
} else {
88-
throw new IllegalStateException("Unable to allocate geometry buffer, got gl error " + error);
88+
throw new IllegalStateException("Unable to allocate geometry buffer, got gl error " + error + ". Failed to allocate buffer of size "+capacity);
8989
}
9090
}
9191
String extra = "";

src/main/java/me/cortex/voxy/client/mixin/sodium/MixinVisibleChunkCollector.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
import me.cortex.voxy.client.core.IVoxyRenderSystemHolder;
44
import me.cortex.voxy.commonImpl.VoxyCommon;
55
import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer;
6+
import net.caffeinemc.mods.sodium.client.render.chunk.LocalSectionIndex;
7+
import net.caffeinemc.mods.sodium.client.render.chunk.RenderSectionFlags;
68
import net.caffeinemc.mods.sodium.client.render.chunk.lists.VisibleChunkCollector;
79
import net.caffeinemc.mods.sodium.client.render.chunk.region.RenderRegion;
810
import net.caffeinemc.mods.sodium.client.render.chunk.region.RenderRegionManager;
911
import net.minecraft.core.SectionPos;
1012
import org.spongepowered.asm.mixin.Mixin;
13+
import org.spongepowered.asm.mixin.Unique;
1114
import org.spongepowered.asm.mixin.injection.At;
1215
import org.spongepowered.asm.mixin.injection.Inject;
1316
import org.spongepowered.asm.mixin.injection.Redirect;
@@ -28,9 +31,15 @@ public class MixinVisibleChunkCollector {
2831
private RenderRegion voxy$injectVisibleSectionGather(RenderRegionManager instance, int x, int y, int z) {
2932
var region = instance.getForChunk(x,y,z);
3033
var vrs = IVoxyRenderSystemHolder.getNullable();
31-
if (vrs != null && region != null) {
34+
if (vrs != null && voxy$shouldUseForChunkBound(region, LocalSectionIndex.pack(x, y, z))) {
3235
vrs.visbleSectionStream.put(SectionPos.asLong(x,y,z));
3336
}
3437
return region;
3538
}
39+
40+
@Unique
41+
private static boolean voxy$shouldUseForChunkBound(RenderRegion region, int localIndex) {
42+
if (region == null) return false;
43+
return (region.getSectionFlags(localIndex)&RenderSectionFlags.MASK_IS_BUILT)!=0;
44+
}
3645
}

0 commit comments

Comments
 (0)