A fix and a refactor

- ModelPools no longer undbind their buffer during construction, as state should be maintained externally
 - Call BufferUploader#reset at the end of renderChunkLayer to partially fix crash rendering contraptions
 - Remove Engine#getName, it was replaced by FlwEngine
This commit is contained in:
Jozufozu 2022-01-17 16:19:18 -08:00
parent 139c95ebc1
commit c37158efd6
5 changed files with 8 additions and 11 deletions

View File

@ -3,5 +3,4 @@ package com.jozufozu.flywheel.backend.instancing;
import com.jozufozu.flywheel.api.MaterialManager;
public interface Engine extends RenderDispatcher, MaterialManager {
String getName();
}

View File

@ -70,8 +70,4 @@ public class BatchingEngine implements Engine {
}
@Override
public String getName() {
return "Batching";
}
}

View File

@ -160,11 +160,6 @@ public class InstancingEngine<P extends WorldProgram> implements Engine {
}
}
@Override
public String getName() {
return "GL33 Instanced Arrays";
}
@FunctionalInterface
public interface OriginShiftListener {
void onOriginShift();

View File

@ -31,6 +31,12 @@ public class ModelPool implements ModelAllocator {
private boolean dirty;
private boolean anyToRemove;
/**
* Create a new model pool.
*
* @param vertexType The vertex type of the models that will be stored in the pool.
* @param initialSize The initial size of the pool, in vertices.
*/
public ModelPool(VertexType vertexType, int initialSize) {
this.vertexType = vertexType;
int stride = vertexType.getStride();
@ -40,7 +46,6 @@ public class ModelPool implements ModelAllocator {
vbo.bind();
vbo.ensureCapacity((long) stride * initialSize);
vbo.setGrowthMargin(stride * 64);
vbo.unbind();
}
/**

View File

@ -16,6 +16,7 @@ import com.jozufozu.flywheel.core.crumbling.CrumblingRenderer;
import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
import com.jozufozu.flywheel.event.RenderLayerEvent;
import com.mojang.blaze3d.vertex.BufferUploader;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
@ -73,6 +74,7 @@ public class LevelRendererMixin {
flywheel$renderLayer(type, stack, camX, camY, camZ);
}
flywheel$LayerRendered = false;
BufferUploader.reset();
}
@Unique