rename vbo containers

This commit is contained in:
James Seibel
2026-03-09 11:16:50 -05:00
parent bd833ba510
commit a8c15d22c3
7 changed files with 19 additions and 23 deletions
@@ -30,7 +30,6 @@ import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.ILodContainerUniformBufferWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.IMcLodRenderer;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.IUniformBufferWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.IVertexBufferWrapper;
import org.lwjgl.system.MemoryUtil;
@@ -218,7 +217,7 @@ public class LodBufferContainer implements AutoCloseable
// get or create the VBO
if (vbos[vboIndex] == null)
{
vbos[vboIndex] = SingletonInjector.INSTANCE.get(IWrapperFactory.class).createVboWrapper();
vbos[vboIndex] = SingletonInjector.INSTANCE.get(IWrapperFactory.class).createVboWrapper("distantHorizons:McLodRenderer");
}
IVertexBufferWrapper vbo = vbos[vboIndex];
@@ -475,7 +475,7 @@ public class GenericObjectRenderer implements IMcGenericRenderer
boxGroup.tryUpdateInstancedDataAsync();
// skip groups that haven't been uploaded yet
if (boxGroup.instancedVbos.getState() != InstancedVboContainer.EState.RENDER)
if (boxGroup.instancedVbos.getState() != NativeGlGenericObjectVertexContainer.EState.RENDER)
{
continue;
}
@@ -557,7 +557,7 @@ public class GenericObjectRenderer implements IMcGenericRenderer
// Bind instance data //
profiler.popPush("binding");
InstancedVboContainer container = (InstancedVboContainer)(boxGroup.instancedVbos);
NativeGlGenericObjectVertexContainer container = (NativeGlGenericObjectVertexContainer)(boxGroup.instancedVbos);
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, container.color);
GL32.glEnableVertexAttribArray(1);
@@ -4,7 +4,7 @@ import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
import java.util.List;
public interface IInstancedVboContainer extends AutoCloseable
public interface IGenericObjectVertexBufferContainer extends AutoCloseable
{
void uploadDataToGpu();
@@ -35,4 +35,6 @@ public interface IInstancedVboContainer extends AutoCloseable
//endregion
}
@@ -17,7 +17,7 @@ import java.util.List;
*
* @see RenderableBoxGroup
*/
public class InstancedVboContainer implements IInstancedVboContainer
public class NativeGlGenericObjectVertexContainer implements IGenericObjectVertexBufferContainer
{
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
@@ -120,7 +120,7 @@ public class InstancedVboContainer implements IInstancedVboContainer
this.materialData[i] = box.material;
}
this.state = InstancedVboContainer.EState.READY_TO_UPLOAD;
this.state = NativeGlGenericObjectVertexContainer.EState.READY_TO_UPLOAD;
}
public void uploadDataToGpu()
@@ -17,7 +17,6 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftGLW
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
import java.io.Closeable;
import java.util.*;
import java.util.List;
@@ -69,9 +68,9 @@ public class RenderableBoxGroup
public Consumer<DhApiRenderParam> afterRenderFunc;
// instance data
public IInstancedVboContainer instancedVbos = WRAPPER_FACTORY.createInstancedVboContainer();
public IGenericObjectVertexBufferContainer instancedVbos = WRAPPER_FACTORY.createInstancedVboContainer();
/** double buffering for thread safety and to prevent locking the render thread during update */
private IInstancedVboContainer altInstancedVbos = WRAPPER_FACTORY.createInstancedVboContainer();
private IGenericObjectVertexBufferContainer altInstancedVbos = WRAPPER_FACTORY.createInstancedVboContainer();
@@ -197,12 +196,12 @@ public class RenderableBoxGroup
public void tryUpdateInstancedDataAsync()
{
// if the alt container is done, swap it in
if (this.altInstancedVbos.getState() == InstancedVboContainer.EState.READY_TO_UPLOAD)
if (this.altInstancedVbos.getState() == NativeGlGenericObjectVertexContainer.EState.READY_TO_UPLOAD)
{
this.altInstancedVbos.uploadDataToGpu();
// swap VBO references for rendering
IInstancedVboContainer temp = this.instancedVbos;
IGenericObjectVertexBufferContainer temp = this.instancedVbos;
this.instancedVbos = this.altInstancedVbos;
this.altInstancedVbos = temp;
@@ -226,11 +225,11 @@ public class RenderableBoxGroup
}
// if the alternate container is already updating, don't double-queue it
if (this.altInstancedVbos.getState() == InstancedVboContainer.EState.UPDATING_DATA)
if (this.altInstancedVbos.getState() == NativeGlGenericObjectVertexContainer.EState.UPDATING_DATA)
{
return;
}
this.altInstancedVbos.setState(InstancedVboContainer.EState.UPDATING_DATA);
this.altInstancedVbos.setState(NativeGlGenericObjectVertexContainer.EState.UPDATING_DATA);
@@ -254,14 +253,14 @@ public class RenderableBoxGroup
catch (Exception e)
{
LOGGER.error("Unexpected error updating instanced VBO data for: ["+this+"], error: ["+e.getMessage()+"].", e);
this.altInstancedVbos.setState(InstancedVboContainer.EState.ERROR);
this.altInstancedVbos.setState(NativeGlGenericObjectVertexContainer.EState.ERROR);
}
});
}
catch (RejectedExecutionException ignore)
{
// the executor was shut down, it should be back up shortly and able to accept new jobs
this.altInstancedVbos.setState(InstancedVboContainer.EState.NEW);
this.altInstancedVbos.setState(NativeGlGenericObjectVertexContainer.EState.NEW);
}
}
@@ -21,12 +21,11 @@ package com.seibel.distanthorizons.core.wrapperInterfaces;
import com.seibel.distanthorizons.api.interfaces.factories.IDhApiWrapperFactory;
import com.seibel.distanthorizons.core.level.IDhLevel;
import com.seibel.distanthorizons.core.render.renderer.generic.IInstancedVboContainer;
import com.seibel.distanthorizons.core.render.renderer.generic.IGenericObjectVertexBufferContainer;
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.ILodContainerUniformBufferWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.IMcGenericRenderer;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.IUniformBufferWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.IVertexBufferWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
@@ -35,7 +34,6 @@ import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindab
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import java.io.IOException;
import java.util.HashSet;
/**
* This handles creating abstract wrapper objects.
@@ -109,10 +107,10 @@ public interface IWrapperFactory extends IDhApiWrapperFactory, IBindable
IVertexBufferWrapper createVboWrapper();
IVertexBufferWrapper createVboWrapper(String name);
ILodContainerUniformBufferWrapper createLodContainerUniformWrapper();
IInstancedVboContainer createInstancedVboContainer();
IGenericObjectVertexBufferContainer createInstancedVboContainer();
IMcGenericRenderer createGenericRenderer();
@@ -30,6 +30,4 @@ public interface IVertexBufferWrapper extends IBindable, AutoCloseable
@Override
void close();
int getVertexCount();
}