From 70616d381a191a0260bdb85f3a47070b4c9bf7c3 Mon Sep 17 00:00:00 2001 From: PepperCode1 <44146161+PepperCode1@users.noreply.github.com> Date: Sat, 13 Aug 2022 13:54:52 -0700 Subject: [PATCH 1/2] Fix crash with Rubidium when using batching - Backport fix from 1.18/next - Downgrade and lock ForgeGradle version to fix build - Update Forge to match 1.18/next - Bump version --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + build.gradle | 2 +- gradle.properties | 6 +++--- .../jozufozu/flywheel/backend/instancing/DrawBuffer.java | 5 ++++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 0f414bd42..9e92efbb5 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -59,6 +59,7 @@ body: label: Mod Version description: The version of the mod you were using when the bug occured options: + - "0.6.5" - "0.6.4" - "0.6.3" - "0.6.2" diff --git a/build.gradle b/build.gradle index c2f7e6bc0..586d9cd02 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { maven { url = 'https://maven.parchmentmc.org' } } dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: "${forgegradle_version}", changing: true + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: "${forgegradle_version}", changing: false classpath "org.spongepowered:mixingradle:${mixingradle_version}" classpath "org.parchmentmc:librarian:${librarian_version}" } diff --git a/gradle.properties b/gradle.properties index 67b6f3ee8..e9ca1f061 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,14 +2,14 @@ org.gradle.jvmargs = -Xmx3G org.gradle.daemon = false # mod version info -mod_version = 0.6.4 +mod_version = 0.6.5 artifact_minecraft_version = 1.18.2 minecraft_version = 1.18.2 -forge_version = 40.1.60 +forge_version = 40.1.68 # build dependency versions -forgegradle_version = 5.1.+ +forgegradle_version = 5.1.53 mixingradle_version = 0.7-SNAPSHOT mixin_version = 0.8.5 librarian_version = 1.+ diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/DrawBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/DrawBuffer.java index 4166c1e59..2725674db 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/DrawBuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/DrawBuffer.java @@ -39,7 +39,10 @@ public class DrawBuffer { VertexFormat format = parent.format(); - int byteSize = format.getVertexSize() * vertexCount; + // Add one extra vertex to uphold the vanilla assumption that BufferBuilders have at least + // enough buffer space for one more vertex. Rubidium checks for this extra space when popNextBuffer + // is called and reallocates the buffer if there is not space for one more vertex. + int byteSize = format.getVertexSize() * (vertexCount + 1); if (backingBuffer == null) { backingBuffer = MemoryTracker.create(byteSize); From 832c94f2ba6c587b1f2fb996d148a56090396536 Mon Sep 17 00:00:00 2001 From: PepperCode1 <44146161+PepperCode1@users.noreply.github.com> Date: Tue, 16 Aug 2022 10:41:35 -0700 Subject: [PATCH 2/2] 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 --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + .../com/jozufozu/flywheel/backend/instancing/DrawBuffer.java | 3 +++ .../java/com/jozufozu/flywheel/mixin/RenderTypeMixin.java | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 9e92efbb5..ccdb88cfd 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -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" diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/DrawBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/DrawBuffer.java index 2725674db..f9c6ab051 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/DrawBuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/DrawBuffer.java @@ -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; } diff --git a/src/main/java/com/jozufozu/flywheel/mixin/RenderTypeMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/RenderTypeMixin.java index c3a3d7b5d..d31b71899 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/RenderTypeMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/RenderTypeMixin.java @@ -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; } }