Buffer built

- Remove BufferBuilderExtension and mixin.
- Missed these in earlier commits.
This commit is contained in:
Jozufozu 2023-12-24 12:21:55 -08:00
parent 02321c52ef
commit 588bb4dda3
3 changed files with 0 additions and 94 deletions

View File

@ -1,27 +0,0 @@
package com.jozufozu.flywheel.extension;
import java.nio.ByteBuffer;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.VertexFormat;
/**
* Duck interface used on {@link BufferBuilder} to provide lower level access to the backing memory.
*
* @see com.jozufozu.flywheel.mixin.BufferBuilderMixin
*/
public interface BufferBuilderExtension {
/**
* Frees the internal ByteBuffer, if it exists.
*/
void flywheel$freeBuffer();
/**
* Prepares the BufferBuilder for drawing the contents of the given buffer.
* @param buffer The buffer to draw.
* @param format The format of the buffer.
* @param vertexCount The number of vertices in the buffer.
*/
void flywheel$injectForRender(ByteBuffer buffer, VertexFormat format, int vertexCount);
}

View File

@ -1,66 +0,0 @@
package com.jozufozu.flywheel.mixin;
import java.nio.ByteBuffer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.system.MemoryUtil;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import com.jozufozu.flywheel.extension.BufferBuilderExtension;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.blaze3d.vertex.VertexFormatElement;
@Mixin(BufferBuilder.class)
abstract class BufferBuilderMixin implements BufferBuilderExtension {
@Shadow
private ByteBuffer buffer;
@Shadow
private int vertices;
@Shadow
@Nullable
private VertexFormatElement currentElement;
@Shadow
private int elementIndex;
@Shadow
private VertexFormat format;
@Shadow
private VertexFormat.Mode mode;
@Shadow
private boolean building;
@Shadow
private int nextElementByte;
@Override
public void flywheel$freeBuffer() {
if (buffer != null) {
// The buffer is created using MemoryTracker, which uses a non-default allocator.
// The same allocator must be used here to free the buffer.
MemoryUtil.getAllocator(false).free(MemoryUtil.memAddress0(buffer));
buffer = null;
}
}
@Override
public void flywheel$injectForRender(@NotNull ByteBuffer buffer, @NotNull VertexFormat format, int vertexCount) {
building = true;
mode = VertexFormat.Mode.QUADS;
this.buffer = buffer;
this.format = format;
vertices = vertexCount;
currentElement = format.getElements().get(0);
elementIndex = 0;
nextElementByte = vertexCount * format.getVertexSize();
}
}

View File

@ -6,7 +6,6 @@
"refmap": "flywheel.refmap.json",
"client": [
"BlockEntityTypeMixin",
"BufferBuilderMixin",
"ClientLevelMixin",
"EntityTypeMixin",
"FogUpdateMixin",