refactoring and cleanup

This commit is contained in:
James Seibel
2026-03-09 12:03:27 -05:00
parent 4d7674348b
commit afdccfe087
15 changed files with 187 additions and 210 deletions
@@ -54,6 +54,7 @@ import com.seibel.distanthorizons.core.logging.f3.F3Screen;
import com.seibel.distanthorizons.core.render.renderer.RenderParams;
import com.seibel.distanthorizons.core.render.renderer.generic.GenericRenderObjectFactory;
import com.seibel.distanthorizons.core.render.renderer.generic.IGenericObjectVertexBufferContainer;
import com.seibel.distanthorizons.core.render.renderer.generic.NativeGlGenericObjectVertexContainer;
import com.seibel.distanthorizons.core.render.renderer.generic.RenderableBoxGroup;
import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.util.math.Mat4f;
@@ -528,7 +529,7 @@ public class McGenericObjectRenderer implements IMcGenericRenderer
//endregion
}
private String getName() { return "distantHorizons:McTestRenderer"; }
private String getName() { return "distantHorizons:McGenericObjectRenderer"; }
//endregion
@@ -21,7 +21,7 @@ import com.seibel.distanthorizons.common.render.blaze.helpers.*;
import com.seibel.distanthorizons.common.render.blaze.util.DhBlazeVertexFormat;
import com.seibel.distanthorizons.common.render.blaze.wrappers.BlazeTextureViewWrapper;
import com.seibel.distanthorizons.common.render.blaze.wrappers.BlazeTextureWrapper;
import com.seibel.distanthorizons.common.render.blaze.wrappers.LodContainerUniformBufferWrapper;
import com.seibel.distanthorizons.common.render.blaze.wrappers.LodUniformBufferWrapper;
import com.seibel.distanthorizons.common.render.blaze.wrappers.VertexBufferWrapper;
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
import com.seibel.distanthorizons.core.config.Config;
@@ -286,10 +286,11 @@ public class McLodRenderer implements IMcLodRenderer
if (this.indexBuffer == null
|| this.indexBuffer.size() < buffer.capacity())
{
// GpuBuffer.USAGE_UNIFORM = 128
// GpuBuffer.USAGE_INDEX = 64
int usage = 8 | 32 | 64 | 128; // is this just using OpenGL VBO flags?, if so I can't find it, supposedly GlDevice on Mojang's side
this.indexBuffer = GPU_DEVICE.createBuffer(() -> "DH Index Buffer", usage, 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());
}
int offset = 0;
@@ -302,15 +303,6 @@ public class McLodRenderer implements IMcLodRenderer
this.dhDepthTextureWrapper.trySetup();
this.dhColorTextureWrapper.trySetup();
//LightMapWrapper lightMapWrapper = (LightMapWrapper) renderEventParam.lightmap;
//this.mcLightTextureViewWrapper.trySetup(lightMapWrapper.gpuTexture);
//LightMapWrapper lightMapWrapper = (LightMapWrapper) renderEventParam.lightmap;
//McTextureViewWrapper lightmapTextureViewWrapper = lightMapWrapper.getTextureViewWrapper();
//renderPass.bindTexture("uLightMap", lightmapTextureViewWrapper.textureView, lightmapTextureViewWrapper.textureSampler);
{
profiler.popPush("setup");
@@ -346,7 +338,7 @@ public class McLodRenderer implements IMcLodRenderer
profiler.popPush("binding");
LodBufferContainer bufferContainer = bufferContainers.get(lodIndex);
LodContainerUniformBufferWrapper uniformWrapper = (LodContainerUniformBufferWrapper)bufferContainer.uniforms;
LodUniformBufferWrapper uniformWrapper = (LodUniformBufferWrapper)bufferContainer.uniforms;
boolean columnBuilderDebugEnabled = Config.Client.Advanced.Debugging.ColumnBuilderDebugging.columnBuilderDebugEnable.get();
if (columnBuilderDebugEnabled)
@@ -400,6 +392,7 @@ public class McLodRenderer implements IMcLodRenderer
profiler.pop();
}
private String getIndexBufferName() { return "distantHorizons:LodIndexBuffer"; }
private String getName() { return "distantHorizons:McLodRenderer"; }
@Override
@@ -16,6 +16,9 @@ public abstract class AbstractUniformBufferWrapper implements IUniformBufferWrap
{
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
private final String name;
@@ -23,30 +26,35 @@ public abstract class AbstractUniformBufferWrapper implements IUniformBufferWrap
public GpuBuffer gpuBuffer = null;
//=============//
// constructor //
//=============//
//region
public AbstractUniformBufferWrapper() { this.name = this.getClass().getSimpleName(); }
//endregion
//========//
// render //
//========//
//region
public AbstractUniformBufferWrapper() { this.name = this.getClass().getSimpleName(); }
public AbstractUniformBufferWrapper(String name) { this.name = name; }
protected ByteBuffer getOrCreateBuffer(int size)
{
GpuDevice gpuDevice = RenderSystem.getDevice();
if (this.buffer == null
|| this.buffer.capacity() != size)
{
this.buffer = ByteBuffer.allocateDirect(size);
this.buffer.order(ByteOrder.nativeOrder());
// GpuBuffer.USAGE_UNIFORM = 128
// GpuBuffer.USAGE_INDEX = 64
int usage = 8 | 32 | 128; // is this just using OpenGL VBO flags?, if so I can't find it, supposedly GlDevice on Mojang's side
int usage = GpuBuffer.USAGE_COPY_DST
| GpuBuffer.USAGE_VERTEX
| GpuBuffer.USAGE_UNIFORM;
int byteSize = (this.buffer.limit() - this.buffer.position());
this.gpuBuffer = gpuDevice.createBuffer(this::getName, usage, byteSize);
this.gpuBuffer = GPU_DEVICE.createBuffer(this::getName, usage, byteSize);
}
return this.buffer;
@@ -62,14 +70,11 @@ public abstract class AbstractUniformBufferWrapper implements IUniformBufferWrap
GpuDevice gpuDevice = RenderSystem.getDevice();
CommandEncoder commandEncoder = gpuDevice.createCommandEncoder();
int byteSize = (this.buffer.limit() - this.buffer.position());
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.gpuBuffer, /*offset*/0, byteSize);
if (!bufferSlice.buffer().isClosed())
{
commandEncoder.writeToBuffer(bufferSlice, this.buffer);
COMMAND_ENCODER.writeToBuffer(bufferSlice, this.buffer);
}
else
{
@@ -78,6 +83,15 @@ public abstract class AbstractUniformBufferWrapper implements IUniformBufferWrap
}
private String getName() { return this.name; }
//endregion
//================//
// base overrides //
//================//
//region
@Override
public void close()
{
@@ -87,8 +101,8 @@ public abstract class AbstractUniformBufferWrapper implements IUniformBufferWrap
}
}
//endregion
}
@@ -6,7 +6,6 @@ import com.mojang.blaze3d.systems.CommandEncoder;
import com.mojang.blaze3d.systems.GpuDevice;
import com.mojang.blaze3d.systems.RenderSystem;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.render.glObject.GLEnums;
@@ -14,14 +13,11 @@ import com.seibel.distanthorizons.core.render.glObject.GLProxy;
import com.seibel.distanthorizons.core.render.renderer.generic.IGenericObjectVertexBufferContainer;
import com.seibel.distanthorizons.core.render.renderer.generic.RenderableBoxGroup;
import com.seibel.distanthorizons.core.util.ColorUtil;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftGLWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import org.lwjgl.opengl.GL32;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.List;
import java.util.function.Supplier;
/**
* For use by {@link RenderableBoxGroup}
@@ -32,48 +28,8 @@ public class BlazeGenericObjectVertexContainer implements IGenericObjectVertexBu
{
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
private static final IMinecraftGLWrapper GLMC = SingletonInjector.INSTANCE.get(IMinecraftGLWrapper.class);
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
/** A box from 0,0,0 to 1,1,1 */
private static final float[] BOX_VERTICES = {
//region
// Pos x y z
// min X, vertical face
0, 0, 0,
1, 0, 0,
1, 1, 0,
0, 1, 0,
// max X, vertical face
0, 1, 1,
1, 1, 1,
1, 0, 1,
0, 0, 1,
// min Z, vertical face
0, 0, 1,
0, 0, 0,
0, 1, 0,
0, 1, 1,
// max Z, vertical face
1, 0, 1,
1, 1, 1,
1, 1, 0,
1, 0, 0,
// min Y, horizontal face
0, 0, 1,
1, 0, 1,
1, 0, 0,
0, 0, 0,
// max Y, horizontal face
0, 1, 1,
1, 1, 1,
1, 1, 0,
0, 1, 0,
//endregion
};
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
private static final int[] BOX_INDICES = {
//region
@@ -100,69 +56,11 @@ public class BlazeGenericObjectVertexContainer implements IGenericObjectVertexBu
//endregion
};
public static final int[][][] DIRECTION_VERTEX_IBO_QUAD = new int[][][]
///region
{
// X,Z //
{ // UP
{1, 0}, // 0
{1, 1}, // 1
{0, 1}, // 2
{0, 0}, // 3
},
{ // DOWN
{0, 0}, // 0
{0, 1}, // 1
{1, 1}, // 2
{1, 0}, // 3
},
// X,Y //
{ // NORTH
{0, 0}, // 0
{0, 1}, // 1
{1, 1}, // 2
{1, 0}, // 3
},
{ // SOUTH
{1, 0}, // 0
{1, 1}, // 1
{0, 1}, // 2
{0, 0}, // 3
},
// Z,Y //
{ // WEST
{0, 0}, // 0
{1, 0}, // 1
{1, 1}, // 2
{0, 1}, // 3
},
{ // EAST
{0, 1}, // 0
{1, 1}, // 1
{1, 0}, // 2
{0, 0}, // 3
},
};
///endregion
public GpuBuffer vboGpuBuffer;
public GpuBuffer indexGpuBuffer;
//public int[] chunkPosData = new int[0];
//public float[] subChunkPosData = new float[0];
////public float[] scalingData = new float[0];
//public float[] colorData = new float[0];
//public int[] materialData = new int[0];
private ByteBuffer vertexBuffer = ByteBuffer.allocateDirect(0);
private ByteBuffer indexBuffer = ByteBuffer.allocateDirect(0);
@@ -208,10 +106,6 @@ public class BlazeGenericObjectVertexContainer implements IGenericObjectVertexBu
//QuadElementBuffer.buildBuffer(quadCount, this.indexBuffer, GL32.GL_UNSIGNED_INT);
for (int boxIndex = 0; boxIndex < boxCount; boxIndex++)
{
// index
@@ -227,7 +121,8 @@ public class BlazeGenericObjectVertexContainer implements IGenericObjectVertexBu
// vertex
DhApiRenderableBox box = uploadBoxList.get(boxIndex);
final double[] boxVertices = {
final double[] boxVertices =
{
//region
// Pos x y z
@@ -308,31 +203,23 @@ public class BlazeGenericObjectVertexContainer implements IGenericObjectVertexBu
int quadCount = this.uploadedBoxCount * 36;
int byteSize = quadCount * GLEnums.getTypeSize(GL32.GL_UNSIGNED_INT) * 6;
return byteSize;
//int faceCount = this.uploadedBoxCount * 6;
//int vertexCount = faceCount * 6;
//int byteSize = vertexCount * Integer.BYTES;
//return byteSize;
}
public void uploadDataToGpu()
{
GpuDevice gpuDevice = RenderSystem.getDevice();
CommandEncoder commandEncoder = gpuDevice.createCommandEncoder();
// vertex
{
int totalVertexByteSize = this.vertexBufferSize();
if (this.vboGpuBuffer == null
|| this.vboGpuBuffer.size() < totalVertexByteSize)
{
Supplier<String> labelSupplier = () -> "distantHorizons:GenericContainerVertex";
int usage = 8 | 32; // is this just using OpenGL VBO flags?, if so I can't find it, supposedly GlDevice on Mojang's side
this.vboGpuBuffer = gpuDevice.createBuffer(labelSupplier, usage, totalVertexByteSize);
int usage = GpuBuffer.USAGE_COPY_DST
| GpuBuffer.USAGE_VERTEX;
this.vboGpuBuffer = GPU_DEVICE.createBuffer(this::getName, usage, totalVertexByteSize);
}
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.vboGpuBuffer, /*offset*/0, totalVertexByteSize);
commandEncoder.writeToBuffer(bufferSlice, this.vertexBuffer);
COMMAND_ENCODER.writeToBuffer(bufferSlice, this.vertexBuffer);
}
// index
@@ -341,21 +228,22 @@ public class BlazeGenericObjectVertexContainer implements IGenericObjectVertexBu
if (this.indexGpuBuffer == null
|| this.indexGpuBuffer.size() < totalVertexByteSize)
{
Supplier<String> labelSupplier = () -> "distantHorizons:GenericContainerIndex";
// GpuBuffer.USAGE_UNIFORM = 128
// GpuBuffer.USAGE_INDEX = 64
int usage = 8 | 32 | 64 | 128; // is this just using OpenGL VBO flags?, if so I can't find it, supposedly GlDevice on Mojang's side
this.indexGpuBuffer = gpuDevice.createBuffer(labelSupplier, usage, totalVertexByteSize);
int usage = GpuBuffer.USAGE_COPY_DST
| GpuBuffer.USAGE_VERTEX
| GpuBuffer.USAGE_INDEX
| GpuBuffer.USAGE_UNIFORM;
this.indexGpuBuffer = GPU_DEVICE.createBuffer(this::getName, usage, totalVertexByteSize);
}
int offset = 0;
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.indexGpuBuffer, offset, totalVertexByteSize);
commandEncoder.writeToBuffer(bufferSlice, this.indexBuffer);
COMMAND_ENCODER.writeToBuffer(bufferSlice, this.indexBuffer);
}
this.state = EState.RENDER;
}
private String getName() { return "distantHorizons:GenericContainerIndex"; }
//endregion
@@ -375,6 +263,7 @@ public class BlazeGenericObjectVertexContainer implements IGenericObjectVertexBu
{
this.vboGpuBuffer.close();
}
if (this.indexGpuBuffer != null)
{
this.indexGpuBuffer.close();
@@ -1,28 +1,33 @@
package com.seibel.distanthorizons.common.render.blaze.helpers;
import com.mojang.blaze3d.buffers.GpuBuffer;
import com.mojang.blaze3d.systems.CommandEncoder;
import com.mojang.blaze3d.systems.GpuDevice;
import com.mojang.blaze3d.systems.RenderSystem;
@Deprecated // TODO use Uniform Wrapper instead
public class UniformHandler
{
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
public static GpuBuffer createBuffer(String uniformName, int size, GpuBuffer vboGpuBuffer)
{
GpuDevice gpuDevice = RenderSystem.getDevice();
// create VBO if needed
if (vboGpuBuffer == null
|| vboGpuBuffer.size() < size)
{
// TODO
// GpuBuffer.USAGE_UNIFORM = 128
int usage = 8 | 32 | 128; // is this just using OpenGL VBO flags?, if so I can't find it, supposedly GlDevice on Mojang's side
vboGpuBuffer = gpuDevice.createBuffer(() -> uniformName, usage, size);
int usage = GpuBuffer.USAGE_COPY_DST
| GpuBuffer.USAGE_VERTEX
| GpuBuffer.USAGE_UNIFORM;
vboGpuBuffer = GPU_DEVICE.createBuffer(() -> uniformName, usage, size);
}
return vboGpuBuffer;
}
}
@@ -0,0 +1,60 @@
package com.seibel.distanthorizons.common.render.blaze.postProcessing;
import com.mojang.blaze3d.buffers.GpuBuffer;
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 java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.function.Supplier;
/**
* Contains code that's used by all post-processing effects.
*/
public class BlazePostProcessUtil
{
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
// vertices for a full-screen quad
private static final float[] VERTICES = new float[]
{
// PosX,Y,
-1f, -1f,
1f, -1f,
1f, 1f,
-1f, 1f,
};
public static GpuBuffer createAndUploadScreenVertexData(String name)
{
Supplier<String> labelSupplier = () -> "distantHorizons:"+name;
int usage = GpuBuffer.USAGE_COPY_DST
| GpuBuffer.USAGE_VERTEX;
int size = VERTICES.length * Float.BYTES;
GpuBuffer vboGpuBuffer = GPU_DEVICE.createBuffer(labelSupplier, usage, size);
{
int length = VERTICES.length * Float.BYTES;
GpuBufferSlice bufferSlice = new GpuBufferSlice(vboGpuBuffer, /*offset*/ 0, length);
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(VERTICES.length * Float.BYTES);
// Fill buffer with vertices.
byteBuffer.order(ByteOrder.nativeOrder());
byteBuffer.asFloatBuffer().put(VERTICES);
byteBuffer.rewind();
COMMAND_ENCODER.writeToBuffer(bufferSlice, byteBuffer);
}
return vboGpuBuffer;
}
}
@@ -105,11 +105,6 @@ public class McFarFadeRenderer implements IMcFarFadeRenderer
GpuDevice gpuDevice = RenderSystem.getDevice();
CommandEncoder commandEncoder = gpuDevice.createCommandEncoder();
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
{
pipelineBuilder.withCull(false);
@@ -215,10 +210,7 @@ public class McFarFadeRenderer implements IMcFarFadeRenderer
private void renderFadeToTexture()
{
GpuDevice gpuDevice = RenderSystem.getDevice();
CommandEncoder commandEncoder = gpuDevice.createCommandEncoder();
try (RenderPass renderPass = commandEncoder.createRenderPass(
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
this::getName,
this.dhFadeColorTextureWrapper.textureView,
/*optionalClearColorAsInt*/ OptionalInt.empty(),
@@ -122,11 +122,6 @@ public class McFogRenderer implements IMcFogRenderer
);
GpuDevice gpuDevice = RenderSystem.getDevice();
CommandEncoder commandEncoder = gpuDevice.createCommandEncoder();
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
{
pipelineBuilder.withCull(false);
@@ -114,11 +114,6 @@ public class McSsaoRenderer implements IMcSsaoRenderer
/*uniforms*/ new String[] { "applyFragUniformBlock" }
);
GpuDevice gpuDevice = RenderSystem.getDevice();
CommandEncoder commandEncoder = gpuDevice.createCommandEncoder();
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
{
pipelineBuilder.withCull(false);
@@ -107,11 +107,6 @@ public class McVanillaFadeRenderer implements IMcVanillaFadeRenderer
GpuDevice gpuDevice = RenderSystem.getDevice();
CommandEncoder commandEncoder = gpuDevice.createCommandEncoder();
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
{
pipelineBuilder.withCull(false);
@@ -41,7 +41,6 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.OptionalDouble;
import java.util.OptionalInt;
import java.util.function.Supplier;
/**
* Renders the OpenGL/Vulkan triangle
@@ -121,10 +120,6 @@ public class DhTestRenderer implements IMcTestRenderer
}
private void uploadVertexData()
{
GpuDevice gpuDevice = RenderSystem.getDevice();
CommandEncoder commandEncoder = gpuDevice.createCommandEncoder();
// vertices for the OpenGL/Vulkan Triangle
float[] vertices = new float[]
{
@@ -135,11 +130,10 @@ public class DhTestRenderer implements IMcTestRenderer
};
Supplier<String> labelSupplier = () -> "distantHorizons:DhTestRenderer";
// TODO
int usage = 8 | 32; // is this just using OpenGL VBO flags?, if so I can't find it, supposedly GlDevice on Mojang's side
int usage = GpuBuffer.USAGE_COPY_DST
| GpuBuffer.USAGE_VERTEX;
int size = vertices.length * Float.BYTES;
this.vboGpuBuffer = gpuDevice.createBuffer(labelSupplier, usage, size);
this.vboGpuBuffer = GPU_DEVICE.createBuffer(this::getName, usage, size);
{
int offset = 0;
@@ -152,7 +146,7 @@ public class DhTestRenderer implements IMcTestRenderer
byteBuffer.asFloatBuffer().put(vertices);
byteBuffer.rewind();
commandEncoder.writeToBuffer(bufferSlice, byteBuffer);
COMMAND_ENCODER.writeToBuffer(bufferSlice, byteBuffer);
}
}
@@ -10,6 +10,9 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.function.Supplier;
/**
* Contains code that's used by all post-processing effects.
*/
public class BlazePostProcessUtil
{
@@ -29,10 +32,10 @@ public class BlazePostProcessUtil
public static GpuBuffer createAndUploadScreenVertexData(String name)
{
Supplier<String> labelSupplier = () -> "distantHorizons:"+name;
// TODO
int usage = 8 | 32; // is this just using OpenGL VBO flags?, if so I can't find it, supposedly GlDevice on Mojang's side
int usage = GpuBuffer.USAGE_COPY_DST
| GpuBuffer.USAGE_VERTEX;
int size = VERTICES.length * Float.BYTES;
GpuBuffer vboGpuBuffer = GPU_DEVICE.createBuffer(labelSupplier, usage, size);
@@ -52,4 +55,6 @@ public class BlazePostProcessUtil
return vboGpuBuffer;
}
}
@@ -1,5 +1,6 @@
package com.seibel.distanthorizons.common.render.blaze.wrappers;
import com.mojang.blaze3d.buffers.GpuBuffer;
import com.mojang.blaze3d.systems.CommandEncoder;
import com.mojang.blaze3d.systems.GpuDevice;
import com.mojang.blaze3d.systems.RenderSystem;
@@ -29,8 +30,15 @@ public class BlazeTextureWrapper
public GpuTextureView textureView = null;
public GpuSampler textureSampler = null;
private int width = -1;
private int height = -1;
//=============//
// constructor //
//=============//
//region
public static BlazeTextureWrapper createDepth(String name) { return new BlazeTextureWrapper(name, TextureFormat.DEPTH32); }
public static BlazeTextureWrapper createColor(String name) { return new BlazeTextureWrapper(name, TextureFormat.RGBA8); }
@@ -40,10 +48,31 @@ public class BlazeTextureWrapper
this.textureFormat = textureFormat;
}
//endregion
//=========//
// getters //
//=========//
//region
public boolean isEmpty() { return this.texture == null; }
/** @return -1 if the texture is null */
public int getWidth() { return this.width; }
/** @return -1 if the texture is null */
public int getHeight() { return this.height; }
//endregion
//=======//
// setup //
//=======//
//region
public void trySetup()
{
this.tryCreateTexture();
@@ -52,14 +81,11 @@ public class BlazeTextureWrapper
private void tryCreateTexture()
{
int viewWidth = MC_RENDER.getTargetFramebufferViewportWidth();
int textureWidth = (this.texture != null) ? this.texture.getWidth(0) : -1;
int viewHeight = MC_RENDER.getTargetFramebufferViewportHeight();
int textureHeight = (this.texture != null) ? this.texture.getHeight(0) : -1;
if (this.texture == null
|| textureWidth != viewWidth
|| textureHeight != viewHeight)
|| this.width != viewWidth
|| this.height != viewHeight)
{
if (this.texture != null)
{
@@ -67,8 +93,13 @@ public class BlazeTextureWrapper
this.textureView.close();
}
// TODO USAGE_TEXTURE_BINDING = 4
int usage = 4 | 8 | 32 | 128;
this.width = viewWidth;
this.height = viewHeight;
int usage = GpuBuffer.USAGE_HINT_CLIENT_STORAGE
| GpuBuffer.USAGE_COPY_DST
| GpuBuffer.USAGE_VERTEX
| GpuBuffer.USAGE_UNIFORM;
this.texture = GPU_DEVICE.createTexture(this.name,
usage,
this.textureFormat,
@@ -91,6 +122,10 @@ public class BlazeTextureWrapper
}
}
//endregion
/** @see ColorUtil#argbToInt */
public void clearColor(int clearArgbColor)
@@ -100,6 +135,7 @@ public class BlazeTextureWrapper
COMMAND_ENCODER.clearColorTexture(this.texture, clearArgbColor);
}
}
public void clearDepth(float depth)
{
if (this.texture != null)
@@ -12,7 +12,10 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.render.ILodContainerUni
import java.nio.ByteBuffer;
public class LodContainerUniformBufferWrapper extends AbstractUniformBufferWrapper implements ILodContainerUniformBufferWrapper
/**
* TODO ??
*/
public class LodUniformBufferWrapper extends AbstractUniformBufferWrapper implements ILodContainerUniformBufferWrapper
{
@@ -25,8 +25,8 @@ import com.seibel.distanthorizons.api.interfaces.override.worldGenerator.IDhApiW
import com.seibel.distanthorizons.api.interfaces.world.IDhApiLevelWrapper;
import com.seibel.distanthorizons.api.interfaces.factories.IDhApiWrapperFactory;
import com.seibel.distanthorizons.common.render.blaze.McGenericObjectRenderer;
import com.seibel.distanthorizons.common.render.blaze.wrappers.LodContainerUniformBufferWrapper;
import com.seibel.distanthorizons.common.render.blaze.helpers.BlazeGenericObjectVertexContainer;
import com.seibel.distanthorizons.common.render.blaze.wrappers.LodUniformBufferWrapper;
import com.seibel.distanthorizons.common.render.blaze.wrappers.VertexBufferWrapper;
import com.seibel.distanthorizons.common.wrappers.block.BiomeWrapper;
import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper;
@@ -365,7 +365,7 @@ public class WrapperFactory implements IWrapperFactory
@Override
public IVertexBufferWrapper createVboWrapper(String name) { return new VertexBufferWrapper(name); }
@Override
public ILodContainerUniformBufferWrapper createLodContainerUniformWrapper() { return new LodContainerUniformBufferWrapper(); }
public ILodContainerUniformBufferWrapper createLodContainerUniformWrapper() { return new LodUniformBufferWrapper(); }
@Override
public IGenericObjectVertexBufferContainer createInstancedVboContainer() { return new BlazeGenericObjectVertexContainer(); }