Lazily instantiate DrawBuffers

- Iris/Oculus create wrapper RenderTypes whose DrawBuffers are never
used. Creating the DrawBuffer on retrieval solves this inefficiency.
- Add 1.18.2 as a Minecraft version to the issue template
This commit is contained in:
PepperCode1 2022-08-16 10:41:35 -07:00
parent 70616d381a
commit 832c94f2ba
3 changed files with 8 additions and 1 deletions

View file

@ -90,6 +90,7 @@ body:
label: Minecraft Version
description: The version of Minecraft you were using when the bug occured
options:
- "1.18.2"
- "1.18.1"
- "1.18"
- "1.17.1"

View file

@ -2,6 +2,8 @@ package com.jozufozu.flywheel.backend.instancing;
import java.nio.ByteBuffer;
import org.jetbrains.annotations.ApiStatus;
import com.jozufozu.flywheel.backend.model.BufferBuilderExtension;
import com.jozufozu.flywheel.backend.model.DirectVertexConsumer;
import com.mojang.blaze3d.platform.MemoryTracker;
@ -20,6 +22,7 @@ public class DrawBuffer {
private ByteBuffer backingBuffer;
private int expectedVertices;
@ApiStatus.Internal
public DrawBuffer(RenderType parent) {
this.parent = parent;
}

View file

@ -14,11 +14,14 @@ import net.minecraft.client.renderer.RenderType;
public class RenderTypeMixin implements RenderTypeExtension {
@Unique
private final DrawBuffer flywheel$drawBuffer = new DrawBuffer((RenderType) (Object) this);
private DrawBuffer flywheel$drawBuffer;
@Override
@Nonnull
public DrawBuffer flywheel$getDrawBuffer() {
if (flywheel$drawBuffer == null) {
flywheel$drawBuffer = new DrawBuffer((RenderType) (Object) this);
}
return flywheel$drawBuffer;
}
}