Merge branch 'main' of https://gitlab.com/distant-horizons-team/distant-horizons
# Conflicts: # common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/InternalServerGenerator.java
This commit is contained in:
+43
-43
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
+4
-34
@@ -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())
|
||||
|
||||
+17
-5
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+53
-7
@@ -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
|
||||
|
||||
|
||||
+3
-1
@@ -32,7 +32,7 @@ public class BlazeLodUniformBufferWrapper extends BlazeUniformBufferWrapper impl
|
||||
|
||||
|
||||
//========//
|
||||
// ??? //
|
||||
// upload //
|
||||
//========//
|
||||
//region
|
||||
|
||||
@@ -72,5 +72,7 @@ public class BlazeLodUniformBufferWrapper extends BlazeUniformBufferWrapper impl
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
-5
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -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 //
|
||||
//==========//
|
||||
|
||||
+33
-2
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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"
|
||||
);
|
||||
|
||||
+1
-1
@@ -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"
|
||||
);
|
||||
|
||||
+2
-2
@@ -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"
|
||||
);
|
||||
|
||||
|
||||
+2
-2
@@ -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"
|
||||
);
|
||||
|
||||
|
||||
+1
-1
@@ -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"
|
||||
);
|
||||
|
||||
+1
-1
@@ -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"
|
||||
);
|
||||
|
||||
+1
-1
@@ -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"
|
||||
);
|
||||
|
||||
+1
-1
@@ -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"
|
||||
);
|
||||
|
||||
+22
-2
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
+8
-6
@@ -93,6 +93,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
|
||||
@@ -126,6 +127,8 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
||||
|
||||
|
||||
private final IDhServerLevel dhServerLevel;
|
||||
@Nullable
|
||||
private final ChunkUpdateQueueManager updateManager;
|
||||
|
||||
public final InternalServerGenerator internalServerGenerator;
|
||||
|
||||
@@ -199,6 +202,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);
|
||||
#if MC_VER > MC_1_12_2
|
||||
@@ -613,10 +617,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());
|
||||
}
|
||||
|
||||
});
|
||||
@@ -745,10 +748,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);
|
||||
|
||||
+12
-16
@@ -45,6 +45,7 @@ import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
@@ -89,6 +90,8 @@ public class InternalServerGenerator
|
||||
|
||||
private final GlobalWorldGenParams params;
|
||||
private final IDhServerLevel dhServerLevel;
|
||||
@Nullable
|
||||
private final ChunkUpdateQueueManager updateManager;
|
||||
private final Timer chunkSaveIgnoreTimer = TimerUtil.CreateTimer("ChunkSaveIgnoreTimer");
|
||||
|
||||
|
||||
@@ -108,6 +111,7 @@ public class InternalServerGenerator
|
||||
LOGGER.error("DH_SERVER_GEN_TICKET is null for level: " + dhServerLevel.getServerLevelWrapper().getDimensionName());
|
||||
}
|
||||
#endif
|
||||
this.updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(this.dhServerLevel.getServerLevelWrapper());
|
||||
}
|
||||
|
||||
|
||||
@@ -256,10 +260,9 @@ public class InternalServerGenerator
|
||||
#if MC_VER <= MC_1_12_2
|
||||
WorldServer level = this.params.mcServerLevel;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
CompletableFuture<Chunk> future = new CompletableFuture<>();
|
||||
@@ -300,10 +303,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
|
||||
@@ -357,14 +359,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));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.warn("Unable to find chunk update manager for server level ["+dhLevel+"], chunk updates may fail.");
|
||||
InternalServerGenerator.this.updateManager.addPosToIgnore(new DhChunkPos(chunkPos.x, chunkPos.z));
|
||||
}
|
||||
}
|
||||
}, MS_TO_IGNORE_CHUNK_AFTER_COMPLETION);
|
||||
@@ -400,10 +397,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);
|
||||
|
||||
+1
-1
Submodule coreSubProjects updated: 17df533fa6...5933ef8245
Reference in New Issue
Block a user