From 667dd85aeffaac9f1c8888a36b6098d5a0e6d786 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 15 Mar 2026 15:57:57 -0500 Subject: [PATCH 1/6] Fix LOD rendering on Mac --- .../blaze/BlazeDhGenericObjectRenderer.java | 86 +++++++++---------- .../render/blaze/BlazeDhTerrainRenderer.java | 38 +------- .../BlazeGenericObjectVertexContainer.java | 22 +++-- .../buffer/BlazeVertexBufferWrapper.java | 60 +++++++++++-- .../render/openGl/GlDhMetaRenderer.java | 5 -- .../openGl/GlDhTerrainShaderProgram.java | 7 +- .../glObject/buffer/GLVertexBuffer.java | 35 +++++++- 7 files changed, 155 insertions(+), 98 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhGenericObjectRenderer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhGenericObjectRenderer.java index c57ec2fbf..18fdf02f5 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhGenericObjectRenderer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhGenericObjectRenderer.java @@ -492,15 +492,7 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer profiler.push(boxGroup.getResourceLocationNamespace()); profiler.push(boxGroup.getResourceLocationPath()); - try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass( - this::getRenderPassName, - BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView, - /*optionalClearColorAsInt*/ OptionalInt.empty(), - BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, - /*optionalDepthValueAsDouble*/ OptionalDouble.empty())) - { - this.renderBoxGroupInstanced(renderPass, renderEventParam, boxGroup, profiler); - } + this.renderBoxGroupInstanced(renderEventParam, boxGroup, profiler); profiler.pop(); // resource path profiler.pop(); // resource namespace @@ -537,46 +529,54 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer //region private void renderBoxGroupInstanced( - RenderPass renderPass, RenderParams renderEventParam, + RenderParams renderEventParam, RenderableBoxGroup boxGroup, IProfilerWrapper profiler) { - // update instance data // - - profiler.push("vertex setup"); - - BlazeGenericObjectVertexContainer container = (BlazeGenericObjectVertexContainer) boxGroup.vertexBufferContainer; - - LightMapWrapper lightMapWrapper = (LightMapWrapper) renderEventParam.lightmap; - BlazeTextureViewWrapper lightmapTextureViewWrapper = lightMapWrapper.getTextureViewWrapper(); - renderPass.bindTexture("uLightMap", lightmapTextureViewWrapper.textureView, lightmapTextureViewWrapper.textureSampler); - - - - // Bind instance data // - profiler.popPush("binding"); - - - renderPass.setUniform("vertUniformBlock", this.vertUniformBuffer); - - // set pipeline - renderPass.setPipeline(this.pipeline); - renderPass.setIndexBuffer(container.indexGpuBuffer, VertexFormat.IndexType.INT); - - renderPass.setVertexBuffer(0, container.vboGpuBuffer); - - // Draw instanced - profiler.popPush("render"); - if (container.uploadedBoxCount > 0) + try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass( + this::getRenderPassName, + BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView, + /*optionalClearColorAsInt*/ OptionalInt.empty(), + BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, + /*optionalDepthValueAsDouble*/ OptionalDouble.empty())) { - renderPass.drawIndexed( - /*indexStart*/ 0, - /*firstIndex*/0, - /*indexCount*/container.uploadedBoxCount * 36, // 36 = 6 faces * 6 verticies per face - /*instanceCount*/1); + // update instance data // + + profiler.push("vertex setup"); + + BlazeGenericObjectVertexContainer container = (BlazeGenericObjectVertexContainer) boxGroup.vertexBufferContainer; + + LightMapWrapper lightMapWrapper = (LightMapWrapper) renderEventParam.lightmap; + BlazeTextureViewWrapper lightmapTextureViewWrapper = lightMapWrapper.getTextureViewWrapper(); + renderPass.bindTexture("uLightMap", lightmapTextureViewWrapper.textureView, lightmapTextureViewWrapper.textureSampler); + + + + // Bind instance data // + profiler.popPush("binding"); + + + renderPass.setUniform("vertUniformBlock", this.vertUniformBuffer); + + // set pipeline + renderPass.setPipeline(this.pipeline); + renderPass.setIndexBuffer(container.indexGpuBuffer, VertexFormat.IndexType.INT); + + renderPass.setVertexBuffer(0, container.vboGpuBuffer); + + // Draw instanced + profiler.popPush("render"); + if (container.uploadedBoxCount > 0) + { + renderPass.drawIndexed( + /*indexStart*/ 0, + /*firstIndex*/0, + /*indexCount*/container.uploadedBoxCount * 36, // 36 = 6 faces * 6 verticies per face + /*instanceCount*/1); + + } } - profiler.pop(); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhTerrainRenderer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhTerrainRenderer.java index 24a9f439c..90bb7539a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhTerrainRenderer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhTerrainRenderer.java @@ -68,8 +68,6 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer private RenderPipeline transparentPipeline; private boolean init = false; - private GpuBuffer indexBuffer; - private GpuBuffer fragUniformBuffer; private GpuBuffer vertSharedUniformBuffer; @@ -261,30 +259,6 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer); } - // create index buffer - { - if (this.indexBuffer == null) - { - ByteBuffer buffer = MemoryUtil.memAlloc(LodQuadBuilder.getMaxBufferByteSize() * GLEnums.getTypeSize(GL32.GL_UNSIGNED_INT) * 6); - GlQuadIndexBuffer.buildBuffer(LodQuadBuilder.getMaxBufferByteSize(), buffer, GL32.GL_UNSIGNED_INT); - - - // create buffer if needed - if (this.indexBuffer == null - || this.indexBuffer.size() < buffer.capacity()) - { - int usage = GpuBuffer.USAGE_COPY_DST - | GpuBuffer.USAGE_VERTEX - | GpuBuffer.USAGE_INDEX - | GpuBuffer.USAGE_UNIFORM; - this.indexBuffer = GPU_DEVICE.createBuffer(this::getIndexBufferName, usage, buffer.capacity()); - } - - GpuBufferSlice bufferSlice = new GpuBufferSlice(this.indexBuffer, /*offset*/ 0, buffer.capacity()); - COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer); - } - } - // render pass setup @@ -292,25 +266,20 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer profiler.popPush("setup"); // create a render pass - OptionalInt optionalClearColorAsInt = OptionalInt.empty(); - OptionalDouble optionalDepthValueAsDouble = OptionalDouble.empty(); - try(RenderPass renderPass = COMMAND_ENCODER.createRenderPass( this::getRenderPassName, BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView, - optionalClearColorAsInt, - BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, optionalDepthValueAsDouble) + /*optionalClearColorAsInt*/ OptionalInt.empty(), + BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, + /*optionalDepthValueAsDouble*/ OptionalDouble.empty()) ) { - // bind MC Lightmap - //renderPass.bindTexture("uLightMap", this.mcLightTextureViewWrapper.textureView, this.mcLightTextureViewWrapper.textureSampler); LightMapWrapper lightMapWrapper = (LightMapWrapper) renderEventParam.lightmap; BlazeTextureViewWrapper lightmapTextureViewWrapper = lightMapWrapper.getTextureViewWrapper(); renderPass.bindTexture("uLightMap", lightmapTextureViewWrapper.textureView, lightmapTextureViewWrapper.textureSampler); // set pipeline renderPass.setPipeline(opaquePass ? this.opaquePipeline : this.transparentPipeline); - renderPass.setIndexBuffer(this.indexBuffer, VertexFormat.IndexType.INT); // shared uniforms renderPass.setUniform("fragUniformBlock", this.fragUniformBuffer); @@ -367,6 +336,7 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeBufferRenderEvent.class, new DhApiBeforeBufferRenderEvent.EventParam(renderEventParam, modelPos)); } + renderPass.setIndexBuffer(bufferWrapper.indexBuffer, VertexFormat.IndexType.INT); renderPass.setVertexBuffer(0, bufferWrapper.vboGpuBuffer); // vertex buffer can only be "0" lol if (!bufferWrapper.vboGpuBuffer.isClosed()) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/objects/BlazeGenericObjectVertexContainer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/objects/BlazeGenericObjectVertexContainer.java index 603480b86..58954ced6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/objects/BlazeGenericObjectVertexContainer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/objects/BlazeGenericObjectVertexContainer.java @@ -215,8 +215,15 @@ public class BlazeGenericObjectVertexContainer implements IDhGenericObjectVertex { int totalVertexByteSize = this.vertexBufferSize(); if (this.vboGpuBuffer == null - || this.vboGpuBuffer.size() < totalVertexByteSize) + // recreating if the size changes is always necessary (even if we only need a smaller amount) + // due to a bug on Mac where it will attempt to render anything allocated in the buffer + || this.vboGpuBuffer.size() != totalVertexByteSize) { + if (this.vboGpuBuffer != null) + { + this.vboGpuBuffer.close(); + } + int usage = GpuBuffer.USAGE_COPY_DST | GpuBuffer.USAGE_VERTEX; this.vboGpuBuffer = GPU_DEVICE.createBuffer(this::getVertexBufferName, usage, totalVertexByteSize); @@ -230,12 +237,17 @@ public class BlazeGenericObjectVertexContainer implements IDhGenericObjectVertex { int totalVertexByteSize = this.indexBufferSize(); if (this.indexGpuBuffer == null - || this.indexGpuBuffer.size() < totalVertexByteSize) + // recreating if the size changes is always necessary (even if we only need a smaller amount) + // due to a bug on Mac where it will attempt to render anything allocated in the buffer + || this.indexGpuBuffer.size() != totalVertexByteSize) { + if (this.indexGpuBuffer != null) + { + this.indexGpuBuffer.close(); + } + int usage = GpuBuffer.USAGE_COPY_DST - | GpuBuffer.USAGE_VERTEX - | GpuBuffer.USAGE_INDEX - | GpuBuffer.USAGE_UNIFORM; + | GpuBuffer.USAGE_INDEX; this.indexGpuBuffer = GPU_DEVICE.createBuffer(this::getIndexBufferName, usage, totalVertexByteSize); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/buffer/BlazeVertexBufferWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/buffer/BlazeVertexBufferWrapper.java index ea707adfc..71761481a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/buffer/BlazeVertexBufferWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/buffer/BlazeVertexBufferWrapper.java @@ -10,9 +10,15 @@ import com.mojang.blaze3d.buffers.GpuBufferSlice; import com.mojang.blaze3d.systems.CommandEncoder; import com.mojang.blaze3d.systems.GpuDevice; import com.mojang.blaze3d.systems.RenderSystem; +import com.seibel.distanthorizons.common.render.openGl.glObject.buffer.GlQuadIndexBuffer; +import com.seibel.distanthorizons.common.render.openGl.glObject.enums.GLEnums; +import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodQuadBuilder; import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IVertexBufferWrapper; +import org.lwjgl.opengl.GL32; +import org.lwjgl.system.MemoryUtil; import java.nio.ByteBuffer; +import java.nio.ByteOrder; public class BlazeVertexBufferWrapper implements IVertexBufferWrapper { @@ -24,6 +30,8 @@ public class BlazeVertexBufferWrapper implements IVertexBufferWrapper public String getName() { return this.name; } public GpuBuffer vboGpuBuffer = null; + public GpuBuffer indexBuffer = null; + public int vertexCount = -1; public int indexCount = -1; public boolean uploaded = false; @@ -47,22 +55,60 @@ public class BlazeVertexBufferWrapper implements IVertexBufferWrapper //region @Override - public void upload(ByteBuffer buffer, int vertexCount) + public void upload(ByteBuffer vertexBuffer, int vertexCount) { + int oldVertexCount = this.vertexCount; + this.vertexCount = vertexCount; // 4 vertices per face, but 6 indices (IE 2 triangles) per face, aka need to multiply by 1.5 this.indexCount = (int)(vertexCount * 1.5); this.uploaded = true; - int usage = GpuBuffer.USAGE_COPY_DST - | GpuBuffer.USAGE_VERTEX; - int byteSize = (buffer.limit() - buffer.position()); - this.vboGpuBuffer = GPU_DEVICE.createBuffer(this::getName, usage, byteSize); + if (this.vboGpuBuffer == null + // recreating if the size changes is always necessary (even if we only need a smaller amount) + // due to a bug on Mac where it will attempt to render anything allocated in the buffer + || oldVertexCount != vertexCount) + { + if (this.vboGpuBuffer != null) + { + this.vboGpuBuffer.close(); + } + + int usage = GpuBuffer.USAGE_COPY_DST + | GpuBuffer.USAGE_VERTEX; + int byteSize = (vertexBuffer.limit() - vertexBuffer.position()); + this.vboGpuBuffer = GPU_DEVICE.createBuffer(this::getName, usage, byteSize); + + GpuBufferSlice bufferSlice = new GpuBufferSlice(this.vboGpuBuffer, /*offset*/0, byteSize); + COMMAND_ENCODER.writeToBuffer(bufferSlice, vertexBuffer); + } - GpuBufferSlice bufferSlice = new GpuBufferSlice(this.vboGpuBuffer, /*offset*/0, byteSize); - COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer); + + if (this.indexBuffer == null + // recreating if the size changes is always necessary (even if we only need a smaller amount) + // due to a bug on Mac where it will attempt to render anything allocated in the buffer + || oldVertexCount != vertexCount) + { + if (this.indexBuffer != null) + { + this.indexBuffer.close(); + } + + int quadCount = (this.vertexCount / 4); + ByteBuffer indexBuffer = MemoryUtil.memAlloc(quadCount * 6 * GLEnums.getTypeSize(GL32.GL_UNSIGNED_INT)); + indexBuffer.order(ByteOrder.nativeOrder()); + GlQuadIndexBuffer.buildBuffer(quadCount, indexBuffer, GL32.GL_UNSIGNED_INT); + + int usage = GpuBuffer.USAGE_COPY_DST + | GpuBuffer.USAGE_INDEX; + this.indexBuffer = GPU_DEVICE.createBuffer(this::getIndexBufferName, usage, indexBuffer.capacity()); + + GpuBufferSlice bufferSlice = new GpuBufferSlice(this.indexBuffer, /*offset*/ 0, indexBuffer.capacity()); + COMMAND_ENCODER.writeToBuffer(bufferSlice, indexBuffer); + } } + private String getIndexBufferName() { return "distantHorizons:LodIndexBuffer"; } //endregion diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/GlDhMetaRenderer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/GlDhMetaRenderer.java index fe2c84bbf..8450849de 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/GlDhMetaRenderer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/GlDhMetaRenderer.java @@ -106,7 +106,6 @@ public class GlDhMetaRenderer implements IDhMetaRenderer this.setGLState(renderParams, firstPass); - GlDhTerrainShaderProgram.INSTANCE.quadIBO.bind(); this.bindLightmap(renderParams.lightmap); } private void setGLState( @@ -242,9 +241,6 @@ public class GlDhMetaRenderer implements IDhMetaRenderer LOGGER.info("Setting up renderer"); - GlDhTerrainShaderProgram.INSTANCE.quadIBO = new GlQuadIndexBuffer(); - GlDhTerrainShaderProgram.INSTANCE.quadIBO.reserve(LodQuadBuilder.getMaxBufferByteSize()); - // create or get the frame buffer if (AbstractOptifineAccessor.optifinePresent()) @@ -362,7 +358,6 @@ public class GlDhMetaRenderer implements IDhMetaRenderer this.unbindLightmap(); - GlDhTerrainShaderProgram.INSTANCE.quadIBO.unbind(); this.shaderProgramForThisFrame.unbind(); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/GlDhTerrainShaderProgram.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/GlDhTerrainShaderProgram.java index e6f30b78f..a046781a6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/GlDhTerrainShaderProgram.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/GlDhTerrainShaderProgram.java @@ -52,7 +52,6 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS private boolean init = false; - public GlQuadIndexBuffer quadIBO = null; public GlAbstractVertexAttribute vao; // uniforms // @@ -351,12 +350,16 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS int indexCount = (int)(vbo.getVertexCount() * 1.5); vbo.bind(); + vbo.quadIBO.bind(); + GlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.bindVertexBuffer(vbo.getId()); GL32.glDrawElements( GL32.GL_TRIANGLES, indexCount, - this.quadIBO.getType(), 0); + vbo.quadIBO.getType(), 0); + vbo.unbind(); + vbo.quadIBO.unbind(); } } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLVertexBuffer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLVertexBuffer.java index 5567c7cf2..4889c9a6d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLVertexBuffer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLVertexBuffer.java @@ -20,13 +20,17 @@ package com.seibel.distanthorizons.common.render.openGl.glObject.buffer; import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import com.seibel.distanthorizons.common.render.openGl.GlDhTerrainShaderProgram; import com.seibel.distanthorizons.common.render.openGl.glObject.GLProxy; +import com.seibel.distanthorizons.common.render.openGl.glObject.enums.GLEnums; import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodQuadBuilder; import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IVertexBufferWrapper; import org.lwjgl.opengl.GL32; import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod; +import org.lwjgl.system.MemoryUtil; /** * This is a container for a OpenGL @@ -44,6 +48,8 @@ public class GLVertexBuffer extends GLBuffer implements IVertexBufferWrapper protected int vertexCount = 0; public int getVertexCount() { return this.vertexCount; } + public GlQuadIndexBuffer quadIBO = null; + //=============// @@ -89,12 +95,36 @@ public class GLVertexBuffer extends GLBuffer implements IVertexBufferWrapper // If size is zero, just ignore it. if (byteBuffer.limit() - byteBuffer.position() != 0) { - boolean useBuffStorage = uploadMethod.useBufferStorage; - super.uploadBuffer(byteBuffer, uploadMethod, maxExpansionSize, useBuffStorage ? 0 : GL32.GL_STATIC_DRAW); + // vertex data + { + super.uploadBuffer(byteBuffer, uploadMethod, maxExpansionSize, uploadMethod.useBufferStorage ? 0 : GL32.GL_STATIC_DRAW); + } + + // index data + { + if (this.quadIBO != null) + { + this.quadIBO.close(); + } + + int quadCount = (vertexCount / 4); + this.quadIBO = new GlQuadIndexBuffer(); + this.quadIBO.reserve(quadCount); + } + } + this.vertexCount = vertexCount; } + //endregion + + + + //================// + // base overrides // + //================// + //region @Override public void close() { this.destroyAsync(); } @@ -102,6 +132,7 @@ public class GLVertexBuffer extends GLBuffer implements IVertexBufferWrapper public void destroyAsync() { super.destroyAsync(); + this.quadIBO.destroyAsync(); this.vertexCount = 0; } From 55155103ec1b622045e3fa576d7abf7ced2ec86c Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 15 Mar 2026 16:24:03 -0500 Subject: [PATCH 2/6] revert to AUTO rendering A if an invalid API is selected --- .../common/wrappers/DependencySetup.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/DependencySetup.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/DependencySetup.java index 95c3deca9..b0d03841a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/DependencySetup.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/DependencySetup.java @@ -91,23 +91,43 @@ public class DependencySetup LOGGER.info("Setting DH Rendering API to: ["+renderingApiEnum+"]."); + + + boolean validApi; AbstractDhRenderApiDefinition renderDefinition; if (renderingApiEnum == EDhApiRenderApi.OPEN_GL) { + validApi = true; renderDefinition = new GlDhRenderApiDefinition(); } else if (renderingApiEnum == EDhApiRenderApi.BLAZE_3D) { #if MC_VER <= MC_1_21_10 - throw new IllegalStateException("["+renderingApiEnum+"] is not supported on this version of Minecraft."); + validApi = false; + renderDefinition = null; #else + validApi = true; renderDefinition = new BlazeDhRenderApiDefinition(); #endif } else { - throw new IllegalStateException("No ["+ AbstractDhRenderApiDefinition.class.getSimpleName()+"] concrete implementation found for the value: ["+renderingApiEnum+"]."); + String message = "No ["+ AbstractDhRenderApiDefinition.class.getSimpleName()+"] concrete implementation found for the value: ["+renderingApiEnum+"]."; + LOGGER.fatal(message); + throw new IllegalStateException(message); } + + + // crash if an invalid API is set + if (!validApi) + { + String message = "["+renderingApiEnum+"] is not supported on this version of Minecraft, reverting to ["+EDhApiRenderApi.AUTO+"]."; + LOGGER.fatal(message); + Config.Client.Advanced.Graphics.Experimental.renderingApi.set(EDhApiRenderApi.AUTO); + throw new IllegalStateException(message); + } + + renderDefinition.bindRenderers(); } From eb6aa1381514ee816224c949bb3327a8edc9e77f Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 15 Mar 2026 16:29:48 -0500 Subject: [PATCH 3/6] Disable generic rendering on Mac --- .../openGl/generic/GlGenericObjectRenderer.java | 16 ++++++++++++++++ coreSubProjects | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/generic/GlGenericObjectRenderer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/generic/GlGenericObjectRenderer.java index 0fae35b2c..cc2c34530 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/generic/GlGenericObjectRenderer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/generic/GlGenericObjectRenderer.java @@ -195,6 +195,13 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer this.vertexAttribDivisorSupported = GLProxy.getInstance().vertexAttribDivisorSupported; this.instancedArraysSupported = GLProxy.getInstance().instancedArraysSupported; boolean isMac = (EPlatform.get() == EPlatform.MACOS); + if (isMac) + { + LOGGER.warn("Generic rendering not supported by Mac. Clouds, beacons, and some other effects will be disabled."); + Config.Client.Advanced.Graphics.GenericRendering.enableGenericRendering.setApiValue(false); + return; + } + this.instancedRenderingAvailable = (this.vertexAttribDivisorSupported || this.instancedArraysSupported) && !isMac; if (!this.instancedRenderingAvailable) { @@ -399,6 +406,14 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer @Override public void render(RenderParams renderEventParam, IProfilerWrapper profiler, boolean renderingWithSsao) { + // generic rendering (both instanced and direct) is extremely unstable on Mac, so don't render anything + if (EPlatform.get() == EPlatform.MACOS) + { + return; + } + + + // render setup // profiler.push("setup"); @@ -511,6 +526,7 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer } + //==========// // clean up // //==========// diff --git a/coreSubProjects b/coreSubProjects index 17df533fa..2de50475f 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 17df533fa6fd64a09969486b6775fe9cae0e583c +Subproject commit 2de50475f175003ab4315328dc5f7d38b5fc2bef From 2432028aa068db5e249d348c641c2a7d65ca7c0a Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 15 Mar 2026 16:30:48 -0500 Subject: [PATCH 4/6] javadoc cleanup --- .../blaze/wrappers/uniform/BlazeLodUniformBufferWrapper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/uniform/BlazeLodUniformBufferWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/uniform/BlazeLodUniformBufferWrapper.java index ba39f5018..795730556 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/uniform/BlazeLodUniformBufferWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/uniform/BlazeLodUniformBufferWrapper.java @@ -32,7 +32,7 @@ public class BlazeLodUniformBufferWrapper extends BlazeUniformBufferWrapper impl //========// - // ??? // + // upload // //========// //region @@ -72,5 +72,7 @@ public class BlazeLodUniformBufferWrapper extends BlazeUniformBufferWrapper impl //endregion + + } #endif \ No newline at end of file From 633544e0b0001d0ec552a48a1cb31e6d65d50ff5 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 15 Mar 2026 16:46:51 -0500 Subject: [PATCH 5/6] remove unneeded chunk update warnings --- .../BatchGenerationEnvironment.java | 14 ++++++++------ .../worldGeneration/InternalServerGenerator.java | 14 ++++++++------ coreSubProjects | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index a2bbc7eaa..87bb106cf 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -83,6 +83,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.world.level.chunk.ChunkStatus; #else import net.minecraft.world.level.chunk.status.ChunkStatus; +import org.jetbrains.annotations.Nullable; #endif public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironmentWrapper @@ -116,6 +117,8 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm private final IDhServerLevel dhServerLevel; + @Nullable + private final ChunkUpdateQueueManager updateManager; public final InternalServerGenerator internalServerGenerator; public final ChunkFileReader chunkFileReader; @@ -184,6 +187,7 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm public BatchGenerationEnvironment(IDhServerLevel dhServerLevel) { this.dhServerLevel = dhServerLevel; + this.updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(this.dhServerLevel.getServerLevelWrapper()); this.globalParams = new GlobalWorldGenParams(dhServerLevel); this.internalServerGenerator = new InternalServerGenerator(this.globalParams, this.dhServerLevel); this.chunkFileReader = new ChunkFileReader(this.globalParams); @@ -592,10 +596,9 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm // usually ignoring the chunk's position is unnecessary, // but this improves performance if a chunk update event does sneak through - ChunkUpdateQueueManager updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(this.dhServerLevel.getServerLevelWrapper()); - if (updateManager != null) + if (this.updateManager != null) { - updateManager.addPosToIgnore(chunkWrapper.getChunkPos()); + this.updateManager.addPosToIgnore(chunkWrapper.getChunkPos()); } }); @@ -724,10 +727,9 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm @Override public void run() { - ChunkUpdateQueueManager updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(BatchGenerationEnvironment.this.dhServerLevel.getServerLevelWrapper()); - if (updateManager != null) + if (BatchGenerationEnvironment.this.updateManager != null) { - updateManager.addPosToIgnore(chunkWrapper.getChunkPos()); + BatchGenerationEnvironment.this.updateManager.removePosToIgnore(chunkWrapper.getChunkPos()); } } }, MS_TO_IGNORE_CHUNK_AFTER_COMPLETION); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java index a356ca0c7..7c4ac1fe8 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java @@ -32,6 +32,7 @@ import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkStatus; #else import net.minecraft.world.level.chunk.status.ChunkStatus; +import org.jetbrains.annotations.Nullable; #endif import java.util.*; @@ -75,6 +76,8 @@ public class InternalServerGenerator private final GlobalWorldGenParams params; private final IDhServerLevel dhServerLevel; + @Nullable + private final ChunkUpdateQueueManager updateManager; private final Timer chunkSaveIgnoreTimer = TimerUtil.CreateTimer("ChunkSaveIgnoreTimer"); @@ -87,6 +90,7 @@ public class InternalServerGenerator { this.params = params; this.dhServerLevel = dhServerLevel; + this.updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(this.dhServerLevel.getServerLevelWrapper()); } @@ -237,10 +241,9 @@ public class InternalServerGenerator ServerLevel level = this.params.mcServerLevel; // ignore chunk update events for this position - ChunkUpdateQueueManager updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(this.params.dhServerLevel.getServerLevelWrapper()); - if (updateManager != null) + if (this.updateManager != null) { - updateManager.addPosToIgnore(new DhChunkPos(chunkPos.x, chunkPos.z)); + this.updateManager.removePosToIgnore(new DhChunkPos(chunkPos.x, chunkPos.z)); } #if MC_VER < MC_1_21_5 @@ -304,10 +307,9 @@ public class InternalServerGenerator @Override public void run() { - ChunkUpdateQueueManager updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(dhLevel.getServerLevelWrapper()); - if (updateManager != null) + if (InternalServerGenerator.this.updateManager != null) { - updateManager.addPosToIgnore(new DhChunkPos(chunkPos.x, chunkPos.z)); + InternalServerGenerator.this.updateManager.addPosToIgnore(new DhChunkPos(chunkPos.x, chunkPos.z)); } } }, MS_TO_IGNORE_CHUNK_AFTER_COMPLETION); diff --git a/coreSubProjects b/coreSubProjects index 2de50475f..b9984c772 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 2de50475f175003ab4315328dc5f7d38b5fc2bef +Subproject commit b9984c7723695b74e67298b117e71e84590c9679 From ae08ad56c43622979339d751b72a4a5eaabaaf56 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 15 Mar 2026 16:52:17 -0500 Subject: [PATCH 6/6] Fix MC complaining about GL shader file names --- .../render/openGl/postProcessing/apply/GlDhApplyShader.java | 2 +- .../openGl/postProcessing/fade/GlDhFarFadeApplyShader.java | 2 +- .../render/openGl/postProcessing/fade/GlDhFarFadeShader.java | 4 ++-- .../openGl/postProcessing/fade/GlDhVanillaFadeShader.java | 4 ++-- .../render/openGl/postProcessing/fog/GlDhFogApplyShader.java | 2 +- .../render/openGl/postProcessing/fog/GlDhFogShader.java | 2 +- .../openGl/postProcessing/ssao/GlDhSSAOApplyShader.java | 2 +- .../render/openGl/postProcessing/ssao/GlDhSSAOShader.java | 2 +- coreSubProjects | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/apply/GlDhApplyShader.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/apply/GlDhApplyShader.java index 4a4f4b04b..1d65a5e9a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/apply/GlDhApplyShader.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/apply/GlDhApplyShader.java @@ -57,7 +57,7 @@ public class GlDhApplyShader extends GlAbstractShaderRenderer public void onInit() { this.shader = new GlShaderProgram( - "assets/distanthorizons/shaders/shared/gl/quadApply.vert", + "assets/distanthorizons/shaders/shared/gl/quad_apply.vert", "assets/distanthorizons/shaders/shared/gl/apply.frag", "vPosition" ); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fade/GlDhFarFadeApplyShader.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fade/GlDhFarFadeApplyShader.java index 83e30f08e..306959f43 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fade/GlDhFarFadeApplyShader.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fade/GlDhFarFadeApplyShader.java @@ -59,7 +59,7 @@ public class GlDhFarFadeApplyShader extends GlAbstractShaderRenderer public void onInit() { this.shader = new GlShaderProgram( - "assets/distanthorizons/shaders/shared/gl/quadApply.vert", + "assets/distanthorizons/shaders/shared/gl/quad_apply.vert", "assets/distanthorizons/shaders/fade/gl/apply.frag", "vPosition" ); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fade/GlDhFarFadeShader.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fade/GlDhFarFadeShader.java index ae9a511ff..d2cbda827 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fade/GlDhFarFadeShader.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fade/GlDhFarFadeShader.java @@ -69,8 +69,8 @@ public class GlDhFarFadeShader extends GlAbstractShaderRenderer public void onInit() { this.shader = new GlShaderProgram( - "assets/distanthorizons/shaders/shared/gl/quadApply.vert", - "assets/distanthorizons/shaders/fade/gl/dhFade.frag", + "assets/distanthorizons/shaders/shared/gl/quad_apply.vert", + "assets/distanthorizons/shaders/fade/gl/dh_fade.frag", "vPosition" ); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fade/GlDhVanillaFadeShader.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fade/GlDhVanillaFadeShader.java index 15a1ba43c..9ad70522b 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fade/GlDhVanillaFadeShader.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fade/GlDhVanillaFadeShader.java @@ -77,8 +77,8 @@ public class GlDhVanillaFadeShader extends GlAbstractShaderRenderer public void onInit() { this.shader = new GlShaderProgram( - "assets/distanthorizons/shaders/shared/gl/quadApply.vert", - "assets/distanthorizons/shaders/fade/gl/vanillaFade.frag", + "assets/distanthorizons/shaders/shared/gl/quad_apply.vert", + "assets/distanthorizons/shaders/fade/gl/vanilla_fade.frag", "vPosition" ); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fog/GlDhFogApplyShader.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fog/GlDhFogApplyShader.java index affbce795..b62fc058f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fog/GlDhFogApplyShader.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fog/GlDhFogApplyShader.java @@ -57,7 +57,7 @@ public class GlDhFogApplyShader extends GlAbstractShaderRenderer public void onInit() { this.shader = new GlShaderProgram( - "assets/distanthorizons/shaders/shared/gl/quadApply.vert", + "assets/distanthorizons/shaders/shared/gl/quad_apply.vert", "assets/distanthorizons/shaders/fog/gl/apply.frag", "vPosition" ); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fog/GlDhFogShader.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fog/GlDhFogShader.java index 05efafdfb..ec9af37e4 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fog/GlDhFogShader.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/fog/GlDhFogShader.java @@ -109,7 +109,7 @@ public class GlDhFogShader extends GlAbstractShaderRenderer public void onInit() { this.shader = new GlShaderProgram( - "assets/distanthorizons/shaders/shared/gl/quadApply.vert", + "assets/distanthorizons/shaders/shared/gl/quad_apply.vert", "assets/distanthorizons/shaders/fog/gl/fog.frag", "vPosition" ); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/ssao/GlDhSSAOApplyShader.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/ssao/GlDhSSAOApplyShader.java index d12663de2..f85924273 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/ssao/GlDhSSAOApplyShader.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/ssao/GlDhSSAOApplyShader.java @@ -62,7 +62,7 @@ public class GlDhSSAOApplyShader extends GlAbstractShaderRenderer public void onInit() { this.shader = new GlShaderProgram( - "assets/distanthorizons/shaders/shared/gl/quadApply.vert", + "assets/distanthorizons/shaders/shared/gl/quad_apply.vert", "assets/distanthorizons/shaders/ssao/gl/apply.frag", "vPosition" ); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/ssao/GlDhSSAOShader.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/ssao/GlDhSSAOShader.java index 77cd454af..5d006cbf6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/ssao/GlDhSSAOShader.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/postProcessing/ssao/GlDhSSAOShader.java @@ -70,7 +70,7 @@ public class GlDhSSAOShader extends GlAbstractShaderRenderer public void onInit() { this.shader = new GlShaderProgram( - "assets/distanthorizons/shaders/shared/gl/quadApply.vert", + "assets/distanthorizons/shaders/shared/gl/quad_apply.vert", "assets/distanthorizons/shaders/ssao/gl/ao.frag", "vPosition" ); diff --git a/coreSubProjects b/coreSubProjects index b9984c772..5933ef824 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit b9984c7723695b74e67298b117e71e84590c9679 +Subproject commit 5933ef82458c45e9dd896aa60e7a9064b895ee36