From a919bdf56e6f8a55471e9a7b27c41dcf5daf1fc6 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Tue, 5 May 2026 08:38:14 +0200 Subject: [PATCH 1/2] Build: Port to 26.2-snapshot-5 --- api/UniversalCraft.api | 10 ++-- .../gg/essential/universal/UGraphics.java | 8 +-- .../essential/universal/render/URenderPass.kt | 40 ++++++++++++--- .../universal/render/URenderPipeline.kt | 51 +++++++++++++++++-- .../universal/vertex/UBuiltBuffer.kt | 2 +- versions/26.2-fabric/gradle.properties | 2 +- 6 files changed, 92 insertions(+), 21 deletions(-) diff --git a/api/UniversalCraft.api b/api/UniversalCraft.api index f71d0081..c10c82e4 100644 --- a/api/UniversalCraft.api +++ b/api/UniversalCraft.api @@ -110,7 +110,7 @@ public class gg/essential/universal/UGraphics { @1.17.1-forge,1.18.1-forge,1.19.2-forge,1.19.3-forge,1.19.4-forge,1.20.1-forge,1.20.2-forge,1.20.4-forge,1.20.4-neoforge,1.20.6-forge,1.20.6-neoforge,1.21-forge,1.21-neoforge,1.21.11-fabric,1.21.3-forge,1.21.3-neoforge,1.21.4-forge,1.21.4-neoforge,1.21.5-fabric,1.21.5-forge,1.21.5-neoforge,1.21.6-fabric,1.21.7-fabric,1.21.7-forge,1.21.7-neoforge,1.21.9-fabric,26.1-fabric,26.2-fabric public fun begin (ILcom/mojang/blaze3d/vertex/VertexFormat;)Lgg/essential/universal/UGraphics; public fun begin (ILgg/essential/universal/UGraphics$CommonVertexFormats;)Lgg/essential/universal/UGraphics; - @26.1-fabric,26.2-fabric + @26.1-fabric public fun beginRenderLayer (Lnet/minecraft/client/renderer/rendertype/RenderType;)Lgg/essential/universal/UGraphics; @1.16.2-fabric,1.17.1-fabric,1.18.1-fabric,1.19-fabric,1.19.1-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric public fun begin (ILnet/minecraft/client/render/VertexFormat;)Lgg/essential/universal/UGraphics; @@ -1262,7 +1262,9 @@ public final class gg/essential/universal/render/URenderPipeline$ColorLogic : ja } public final class gg/essential/universal/render/URenderPipeline$Companion { - @26.1-fabric,26.2-fabric + @26.2-fabric + public final fun builder (Lnet/minecraft/resources/Identifier;Lgg/essential/universal/UGraphics$DrawMode;Lcom/mojang/blaze3d/vertex/VertexFormat;Lnet/minecraft/resources/Identifier;Lnet/minecraft/resources/Identifier;Ljava/util/List;)Lgg/essential/universal/render/URenderPipeline$Builder; + @26.1-fabric public final fun builder (Lnet/minecraft/resources/Identifier;Lgg/essential/universal/UGraphics$DrawMode;Lcom/mojang/blaze3d/vertex/VertexFormat;Lnet/minecraft/resources/Identifier;Lnet/minecraft/resources/Identifier;Ljava/util/List;Ljava/util/Map;)Lgg/essential/universal/render/URenderPipeline$Builder; @1.21.5-forge,1.21.5-neoforge,1.21.7-forge,1.21.7-neoforge public final fun builder (Lnet/minecraft/resources/ResourceLocation;Lgg/essential/universal/UGraphics$DrawMode;Lcom/mojang/blaze3d/vertex/VertexFormat;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Ljava/util/List;Ljava/util/Map;)Lgg/essential/universal/render/URenderPipeline$Builder; @@ -1607,7 +1609,7 @@ public final class gg/essential/universal/vertex/UBufferBuilder$Companion { public abstract interface class gg/essential/universal/vertex/UBuiltBuffer : java/lang/AutoCloseable { public static final field Companion Lgg/essential/universal/vertex/UBuiltBuffer$Companion; public fun draw (Lgg/essential/universal/render/URenderPipeline;Lkotlin/jvm/functions/Function1;)V - @26.1-fabric,26.2-fabric + @26.1-fabric public fun draw (Lnet/minecraft/client/renderer/rendertype/RenderType;)V @1.16.2-forge,1.17.1-forge,1.18.1-forge,1.19.2-forge,1.19.3-forge,1.19.4-forge,1.20.1-forge,1.20.2-forge,1.20.4-forge,1.20.4-neoforge,1.20.6-forge,1.20.6-neoforge,1.21-forge,1.21-neoforge,1.21.3-forge,1.21.3-neoforge,1.21.4-forge,1.21.4-neoforge,1.21.5-forge,1.21.5-neoforge,1.21.7-forge,1.21.7-neoforge public fun draw (Lnet/minecraft/client/renderer/RenderType;)V @@ -1615,7 +1617,7 @@ public abstract interface class gg/essential/universal/vertex/UBuiltBuffer : jav public fun draw (Lnet/minecraft/client/render/RenderLayer;)V public static synthetic fun draw$default (Lgg/essential/universal/vertex/UBuiltBuffer;Lgg/essential/universal/render/URenderPipeline;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V public fun drawAndClose (Lgg/essential/universal/render/URenderPipeline;Lkotlin/jvm/functions/Function1;)V - @26.1-fabric,26.2-fabric + @26.1-fabric public fun drawAndClose (Lnet/minecraft/client/renderer/rendertype/RenderType;)V @1.16.2-forge,1.17.1-forge,1.18.1-forge,1.19.2-forge,1.19.3-forge,1.19.4-forge,1.20.1-forge,1.20.2-forge,1.20.4-forge,1.20.4-neoforge,1.20.6-forge,1.20.6-neoforge,1.21-forge,1.21-neoforge,1.21.3-forge,1.21.3-neoforge,1.21.4-forge,1.21.4-neoforge,1.21.5-forge,1.21.5-neoforge,1.21.7-forge,1.21.7-neoforge public fun drawAndClose (Lnet/minecraft/client/renderer/RenderType;)V diff --git a/src/main/java/gg/essential/universal/UGraphics.java b/src/main/java/gg/essential/universal/UGraphics.java index ce696c8a..65921148 100644 --- a/src/main/java/gg/essential/universal/UGraphics.java +++ b/src/main/java/gg/essential/universal/UGraphics.java @@ -124,7 +124,9 @@ //$$ import net.minecraft.util.text.StringTextComponent; //$$ import net.minecraft.util.text.ITextProperties; //$$ import net.minecraft.client.renderer.RenderType; +//#if MC < 1.21.6 //$$ import net.minecraft.client.renderer.IRenderTypeBuffer; +//#endif //$$ import java.util.ArrayList; //$$ import java.util.Optional; //#else @@ -1307,7 +1309,7 @@ public UGraphics beginWithDefaultShader(DrawMode mode, VertexFormat format) { return beginWithActiveShader(mode, format); } - //#if MC>=11600 + //#if MC>=11600 && MC < 26.2 //$$ private RenderType renderLayer; //$$ public UGraphics beginRenderLayer(RenderType renderLayer) { //$$ this.renderLayer = renderLayer; @@ -1340,7 +1342,7 @@ public void drawDirect() { //$$ BuiltBuffer builtBuffer = instance.endNullable(); //$$ if (builtBuffer == null) return; //#endif - //#if MC>=11600 + //#if MC>=11600 && MC < 26.2 //$$ if (renderLayer != null) { //#if MC>=12100 //$$ renderLayer.draw(builtBuffer); @@ -1374,7 +1376,7 @@ public void drawSorted(int cameraX, int cameraY, int cameraZ) { //$$ builtBuffer.sortQuads(ALLOCATOR, RenderSystem.getVertexSorting()); //#endif //#endif - //#if MC>=11600 + //#if MC>=11600 && MC < 26.2 //$$ if (renderLayer != null) { //#if MC>=12100 //$$ renderLayer.draw(builtBuffer); diff --git a/src/main/kotlin/gg/essential/universal/render/URenderPass.kt b/src/main/kotlin/gg/essential/universal/render/URenderPass.kt index bdc24df2..6d7de5ae 100644 --- a/src/main/kotlin/gg/essential/universal/render/URenderPass.kt +++ b/src/main/kotlin/gg/essential/universal/render/URenderPass.kt @@ -5,6 +5,11 @@ import gg.essential.universal.vertex.UBuiltBufferInternal //#if STANDALONE //#else +//#if MC >= 26.2 +//$$ import com.mojang.blaze3d.vertex.VertexFormat +//$$ import java.nio.ByteBuffer +//#endif + //#if MC>=12111 //$$ import com.mojang.blaze3d.textures.AddressMode //$$ import com.mojang.blaze3d.textures.FilterMode @@ -58,6 +63,10 @@ internal class URenderPass : AutoCloseable { private val pipeline: URenderPipeline, private val builtBuffer: UBuiltBufferInternal, ) : DrawCallBuilder { + //#if MC>=12106 && !STANDALONE + //$$ private val tmpBuffers = mutableListOf() + //#endif + //#if MC>=12105 && !STANDALONE //$$ val mc: RenderPass //$$ init { @@ -82,6 +91,14 @@ internal class URenderPass : AutoCloseable { //#endif //$$ ) //#endif + //#if MC >= 26.2 + //$$ fun VertexFormat.uploadImmediateVertexBuffer(buffer: ByteBuffer) = + //$$ RenderSystem.getDevice().createBuffer({ "Immediate vertex buffer for $pipeline" }, GpuBuffer.USAGE_COPY_DST or GpuBuffer.USAGE_VERTEX, buffer) + //$$ .also { tmpBuffers.add(it) } + //$$ fun VertexFormat.uploadImmediateIndexBuffer(buffer: ByteBuffer) = + //$$ RenderSystem.getDevice().createBuffer({ "Immediate index buffer for $pipeline" }, GpuBuffer.USAGE_COPY_DST or GpuBuffer.USAGE_INDEX, buffer) + //$$ .also { tmpBuffers.add(it) } + //#endif //$$ val builtBuffer = builtBuffer.mc //$$ val vertexBuffer = pipeline.format.uploadImmediateVertexBuffer(builtBuffer.buffer) //$$ val sortedBuffer = builtBuffer.sortedBuffer @@ -91,7 +108,11 @@ internal class URenderPass : AutoCloseable { //$$ val shapeIndexBuffer = RenderSystem.getSequentialBuffer(builtBuffer.drawParameters.mode()) //$$ shapeIndexBuffer.getIndexBuffer(builtBuffer.drawParameters.indexCount()) to shapeIndexBuffer.indexType //$$ } - //$$ mc = MinecraftClient.getInstance().framebuffer.let { fb -> + //#if MC >= 26.2 + //$$ mc = Minecraft.getInstance().gameRenderer.mainRenderTarget().let { fb -> + //#else + //$$ mc = MinecraftClient.getInstance().framebuffer.let { fb -> + //#endif //$$ RenderSystem.getDevice().createCommandEncoder().createRenderPass( //#if MC>=12106 //$$ { "Immediate draw for $pipeline" }, @@ -127,10 +148,6 @@ internal class URenderPass : AutoCloseable { scissor = ScissorState(true, x, y, width, height) } - //#if MC>=12106 && !STANDALONE - //$$ private val tmpBuffers = mutableListOf() - //#endif - override fun uniform(name: String, vararg values: Float): DrawCallBuilder = apply { //#if MC>=12105 && !STANDALONE //#if MC>=12106 @@ -165,6 +182,15 @@ internal class URenderPass : AutoCloseable { //#endif } + //#if MC >= 1.21.5 && !STANDALONE + //$$ private fun samplerNameByIndex(index: Int) = + //#if MC >= 26.2 + //$$ pipeline.mcRenderPipeline.bindGroupLayouts.asSequence().flatMap { it.samplers }.elementAt(index) + //#else + //$$ pipeline.mcRenderPipeline.samplers[index] + //#endif + //#endif + override fun texture(name: String, textureView: UGpuTextureView, sampler: UGpuSampler): DrawCallBuilder = apply { //#if MC >= 1.21.5 && !STANDALONE //#if MC >= 1.21.11 @@ -184,7 +210,7 @@ internal class URenderPass : AutoCloseable { override fun texture(index: Int, textureView: UGpuTextureView, sampler: UGpuSampler): DrawCallBuilder = apply { //#if MC >= 1.21.5 && !STANDALONE - //$$ texture(pipeline.mcRenderPipeline.samplers[index], textureView, sampler) + //$$ texture(samplerNameByIndex(index), textureView, sampler) //#else sampler.impl.configureTexture(textureView.texture.impl.glId) pipeline.texture(index, textureView.texture.impl.glId) @@ -222,7 +248,7 @@ internal class URenderPass : AutoCloseable { override fun texture(index: Int, textureGlId: Int): DrawCallBuilder = apply { //#if MC>=12105 && !STANDALONE //$$ @Suppress("DEPRECATION") - //$$ texture(pipeline.mcRenderPipeline.samplers[index], textureGlId) + //$$ texture(samplerNameByIndex(index), textureGlId) //#else pipeline.texture(index, textureGlId) //#endif diff --git a/src/main/kotlin/gg/essential/universal/render/URenderPipeline.kt b/src/main/kotlin/gg/essential/universal/render/URenderPipeline.kt index b44bfb42..c91a4237 100644 --- a/src/main/kotlin/gg/essential/universal/render/URenderPipeline.kt +++ b/src/main/kotlin/gg/essential/universal/render/URenderPipeline.kt @@ -17,6 +17,11 @@ import org.lwjgl.opengl.GL11 import net.minecraft.client.renderer.vertex.VertexFormat import net.minecraft.util.ResourceLocation +//#if MC >= 26.2 +//$$ import com.mojang.blaze3d.pipeline.BindGroupLayout +//$$ import net.minecraft.client.renderer.BindGroupLayouts +//#endif + //#if MC>=12105 //$$ import com.mojang.blaze3d.vertex.VertexFormatElement //$$ import com.mojang.blaze3d.pipeline.BlendFunction @@ -325,7 +330,16 @@ class URenderPipeline private constructor( //#if MC>=11700 && !STANDALONE //#if MC>=12105 - //$$ class Mc(val vert: Identifier, val frag: Identifier, val samplers: List, val uniforms: Map) : ShaderSupplier + //$$ class Mc( + //$$ val vert: Identifier, + //$$ val frag: Identifier, + //#if MC >= 26.2 + //$$ val bindGroupLayouts: List, + //#else + //$$ val samplers: List, + //$$ val uniforms: Map, + //#endif + //$$ ) : ShaderSupplier //#else //$$ class Mc(val shader: Supplier) : ShaderSupplier { //$$ override fun bind(blendState: BlendState) { @@ -426,8 +440,15 @@ class URenderPipeline private constructor( //$$ withVertexShader(vertId) //$$ withFragmentShader(fragId) //$$ - //$$ transformer.samplers.forEach { withSampler(it) } - //$$ transformer.uniforms.forEach { withUniform(it.key, it.value.mc) } + //#if MC >= 26.2 + //$$ withBindGroupLayout(BindGroupLayout.builder().apply { + //$$ transformer.samplers.forEach { withSampler(it) } + //$$ transformer.uniforms.forEach { withUniform(it.key, it.value.mc) } + //$$ }.build()) + //#else + //$$ transformer.samplers.forEach { withSampler(it) } + //$$ transformer.uniforms.forEach { withUniform(it.key, it.value.mc) } + //#endif //$$ //$$ // ShaderProgram calls glBindAttribLocation using the names in the VertexFormat so we need to //$$ // construct a custom one based on the original but with our prefixed names @@ -450,8 +471,12 @@ class URenderPipeline private constructor( //$$ withVertexShader(shader.vert) //$$ withFragmentShader(shader.frag) //$$ - //$$ shader.samplers.forEach { withSampler(it) } - //$$ shader.uniforms.forEach { withUniform(it.key, it.value) } + //#if MC >= 26.2 + //$$ shader.bindGroupLayouts.forEach { withBindGroupLayout(it) } + //#else + //$$ shader.samplers.forEach { withSampler(it) } + //$$ shader.uniforms.forEach { withUniform(it.key, it.value) } + //#endif //$$ } //$$ } //#if MC >= 26.1 @@ -629,6 +654,12 @@ class URenderPipeline private constructor( //$$ @JvmStatic //$$ fun wrap(mc: RenderPipeline): URenderPipeline = //$$ URenderPipeline(mc.location, mc.vertexFormat, null, mc) + //#endif + //#if MC >= 26.2 + //$$ fun builder(id: Identifier, drawMode: DrawMode, format: VertexFormat, vert: Identifier, frag: Identifier, bindGroupLayouts: List): Builder { + //$$ return BuilderImpl(id, drawMode, format, ShaderSupplier.Mc(vert, frag, bindGroupLayouts)) + //$$ } + //#elseif MC >= 1.21.5 //$$ fun builder(id: Identifier, drawMode: DrawMode, format: VertexFormat, vert: Identifier, frag: Identifier, samplers: List, uniforms: Map): Builder { //$$ return BuilderImpl(id, drawMode, format, ShaderSupplier.Mc(vert, frag, samplers, uniforms)) //$$ } @@ -664,6 +695,15 @@ class URenderPipeline private constructor( //$$ ?: throw IllegalArgumentException("No default shader for $format.") //#if MC>=12105 //$$ val shaderId = Identifier.ofVanilla(shader) + //#if MC >= 26.2 + //$$ val bindGroupLayouts = buildList(4) { + //$$ add(BindGroupLayouts.MATRICES_PROJECTION) + //$$ if (format.mc.contains(VertexFormatElement.UV0)) add(BindGroupLayouts.SAMPLER0) + //$$ if (format.mc.contains(VertexFormatElement.UV1)) add(BindGroupLayouts.SAMPLER1) + //$$ if (format.mc.contains(VertexFormatElement.UV2)) add(BindGroupLayouts.SAMPLER2) + //$$ } + //$$ return builder(mcId, drawMode, format.mc, shaderId, shaderId, bindGroupLayouts) + //#else //$$ val samplers = List(format.mc.elements.count { //#if MC >= 26.1 //$$ it == VertexFormatElement.UV0 || it == VertexFormatElement.UV1 || it == VertexFormatElement.UV2 @@ -682,6 +722,7 @@ class URenderPipeline private constructor( //#endif //$$ ) //$$ return builder(mcId, drawMode, format.mc, shaderId, shaderId, samplers, uniforms) + //#endif //#else //$$ return builder(mcId, drawMode, format.mc, shader) //#endif diff --git a/src/main/kotlin/gg/essential/universal/vertex/UBuiltBuffer.kt b/src/main/kotlin/gg/essential/universal/vertex/UBuiltBuffer.kt index 3ab24c76..9cde4d5c 100644 --- a/src/main/kotlin/gg/essential/universal/vertex/UBuiltBuffer.kt +++ b/src/main/kotlin/gg/essential/universal/vertex/UBuiltBuffer.kt @@ -39,7 +39,7 @@ interface UBuiltBuffer : AutoCloseable { } } - //#if MC>=11600 && !STANDALONE + //#if MC >= 1.16 && MC < 26.2 //$$ fun drawAndClose(renderLayer: RenderType): Unit = //$$ use { draw(renderLayer) } //$$ diff --git a/versions/26.2-fabric/gradle.properties b/versions/26.2-fabric/gradle.properties index df8c54e8..8ba649d7 100644 --- a/versions/26.2-fabric/gradle.properties +++ b/versions/26.2-fabric/gradle.properties @@ -1 +1 @@ -essential.defaults.loom.minecraft=com.mojang:minecraft:26.2-snapshot-1 +essential.defaults.loom.minecraft=com.mojang:minecraft:26.2-snapshot-5 From 47b30d512aec65d16db3317f4283b330516b427c Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Tue, 19 May 2026 14:26:45 +0200 Subject: [PATCH 2/2] coerce scissor bounds --- .../universal/render/ScissorState.kt | 18 +++++++ .../essential/universal/render/URenderPass.kt | 47 ++++++++++++++----- 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/render/ScissorState.kt b/src/main/kotlin/gg/essential/universal/render/ScissorState.kt index f79f8c2f..09e7c13a 100644 --- a/src/main/kotlin/gg/essential/universal/render/ScissorState.kt +++ b/src/main/kotlin/gg/essential/universal/render/ScissorState.kt @@ -27,6 +27,24 @@ internal data class ScissorState(val enabled: Boolean, val x: Int, val y: Int, v //#endif } + fun coerceIn(x: Int, y: Int, width: Int, height: Int): ScissorState { + var x1 = this.x + var x2 = this.x + this.width + var y1 = this.y + var y2 = this.y + this.height + x1 = x1.coerceAtLeast(x) + x2 = x2.coerceAtMost(x + width) + y1 = y1.coerceAtLeast(y) + y2 = y2.coerceAtMost(y + height) + return ScissorState( + enabled, + x1, + y1, + (x2 - x1).coerceAtLeast(0), + (y2 - y1).coerceAtLeast(0), + ) + } + companion object { val DISABLED = ScissorState(false, 0, 0, 0, 0) diff --git a/src/main/kotlin/gg/essential/universal/render/URenderPass.kt b/src/main/kotlin/gg/essential/universal/render/URenderPass.kt index 6d7de5ae..7b3136f2 100644 --- a/src/main/kotlin/gg/essential/universal/render/URenderPass.kt +++ b/src/main/kotlin/gg/essential/universal/render/URenderPass.kt @@ -2,6 +2,7 @@ package gg.essential.universal.render import gg.essential.universal.vertex.UBuiltBuffer import gg.essential.universal.vertex.UBuiltBufferInternal +import kotlin.ranges.coerceIn //#if STANDALONE //#else @@ -57,18 +58,20 @@ internal class URenderPass : AutoCloseable { val builder = DrawCallBuilderImpl(pipeline, builtBuffer as UBuiltBufferInternal) configure(builder) builder.submit() + builder.close() } internal inner class DrawCallBuilderImpl( private val pipeline: URenderPipeline, private val builtBuffer: UBuiltBufferInternal, - ) : DrawCallBuilder { + ) : DrawCallBuilder, AutoCloseable { //#if MC>=12106 && !STANDALONE //$$ private val tmpBuffers = mutableListOf() //#endif //#if MC>=12105 && !STANDALONE //$$ val mc: RenderPass + //$$ val outputTextureSize: Pair //$$ init { //#if MC>=12106 //$$ val dynamicUniforms = RenderSystem.getDynamicUniforms().write( @@ -113,16 +116,22 @@ internal class URenderPass : AutoCloseable { //#else //$$ mc = MinecraftClient.getInstance().framebuffer.let { fb -> //#endif + //#if MC >= 1.21.6 + //$$ val outputColorTexture = RenderSystem.outputColorTextureOverride ?: fb.colorAttachmentView!! + //$$ val outputDepthTexture = RenderSystem.outputDepthTextureOverride ?: fb.depthAttachmentView + //#else + //$$ val outputColorTexture = fb.colorAttachment!! + //$$ val outputDepthTexture = fb.depthAttachment + //#endif + //$$ outputTextureSize = Pair(outputColorTexture.getWidth(0), outputColorTexture.getHeight(0)) //$$ RenderSystem.getDevice().createCommandEncoder().createRenderPass( //#if MC>=12106 //$$ { "Immediate draw for $pipeline" }, - //$$ RenderSystem.outputColorTextureOverride ?: fb.colorAttachmentView!!, - //$$ OptionalInt.empty(), - //$$ RenderSystem.outputDepthTextureOverride ?: fb.depthAttachmentView, - //$$ OptionalDouble.empty(), - //#else - //$$ fb.colorAttachment!!, OptionalInt.empty(), fb.depthAttachment, OptionalDouble.empty() //#endif + //$$ outputColorTexture, + //$$ OptionalInt.empty(), + //$$ outputDepthTexture, + //$$ OptionalDouble.empty(), //$$ ) //$$ } //$$ mc.setVertexBuffer(0, vertexBuffer) @@ -256,19 +265,21 @@ internal class URenderPass : AutoCloseable { fun submit() { //#if MC>=12105 && !STANDALONE - //$$ val scissor = scissor ?: ScissorState.active() + //$$ var scissor = scissor ?: ScissorState.active() //$$ if (scissor.enabled) { + //$$ // As of 26.2-snapshot-4, Minecraft will throw when the given scissor is out-of-bounds or empty. + //$$ // Existing users of URenderPass are already used to it accepting such scissors, so we'll silently + //$$ // coerce the given scissor to fit, and skip drawing altogether when it's empty. + //$$ scissor = scissor.coerceIn(0, 0, outputTextureSize.first, outputTextureSize.second) + //$$ if (scissor.width <= 0 || scissor.height <= 0) { + //$$ return + //$$ } //$$ mc.enableScissor(scissor.x, scissor.y, scissor.width, scissor.height) //$$ } else { //$$ mc.disableScissor() //$$ } //$$ //$$ pipeline.draw(mc, builtBuffer.mc) - //$$ - //$$ mc.close() - //#if MC>=12106 - //$$ tmpBuffers.forEach { it.close() } - //#endif //#else if (currPipeline != pipeline) { currPipeline = pipeline @@ -284,9 +295,19 @@ internal class URenderPass : AutoCloseable { pipeline.draw(builtBuffer) prevScissor?.activate() + //#endif + } + override fun close() { + //#if MC >= 1.21.5 && !STANDALONE + //$$ mc.close() + //#else pipeline.unbind() //#endif + + //#if MC >= 1.21.6 && !STANDALONE + //$$ tmpBuffers.forEach { it.close() } + //#endif } } }