fixed bugs, memory leaks, etc

This commit is contained in:
bbldrizzy committed 2026-10-23 08:36:42 +01:00
1 parent aa4f6b6ddc
commit c3f8f23c1d
124 files changed
+1060 -420

No files matched your search

@@ -10,8 +10,11 @@ import java.util.WeakHashMap;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Stream;
import org.lwjgl.opengl.ARBVertexArrayObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class BufferSource {
private static final Logger LOGGER = LoggerFactory.getLogger(BufferSource.class);
private final WeakHashMap buffersByMode = new WeakHashMap();
private final Set pendingModes = new LinkedHashSet();
public static final boolean ASSERTIONS_DISABLED = !BufferSource.class.desiredAssertionStatus();
@@ -53,6 +56,8 @@ public class BufferSource {
MappedMeshBuilder builder = (MappedMeshBuilder)bufferData.activeBuilder().get();
if (!ASSERTIONS_DISABLED && builder == null) {
throw new AssertionError(MISSING_BUILDER_MESSAGE);
} else if (builder == null) {
return;
} else {
int indexCount = builder.getIndexCount();
int vertexCount = builder.getVertexCount();
@@ -66,11 +71,18 @@ public class BufferSource {
}
public void flush(CameraMatrices context) {
for (DrawPipeline drawMode : (Iterable<DrawPipeline>)(this.pendingModes)) {
this.draw(context, drawMode);
try {
for (DrawPipeline drawMode : (Iterable<DrawPipeline>)(this.pendingModes)) {
try {
this.draw(context, drawMode);
} catch (Throwable throwable) {
LOGGER.error("Failed to draw buffered pipeline", throwable);
}
}
} finally {
this.pendingModes.clear();
}
this.pendingModes.clear();
this.buffersByMode.size();
}