No one can hear you free

- Silence empty model warning behind a system property
- Fix gpu memory leak from light/matrix buffers on indirect
This commit is contained in:
Jozufozu 2024-11-11 22:33:41 -08:00
parent 6709682785
commit 868a263c28
4 changed files with 23 additions and 7 deletions

View file

@ -28,6 +28,8 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.client.resources.model.ModelBakery;
public abstract class DrawManager<N extends AbstractInstancer<?>> {
private static final boolean WARN_EMPTY_MODELS = Boolean.getBoolean("flywheel.warnEmptyModels");
/**
* A map of instancer keys to instancers.
* <br>
@ -100,15 +102,16 @@ public abstract class DrawManager<N extends AbstractInstancer<?>> {
return true;
}
StringBuilder builder = new StringBuilder();
builder.append("Creating an instancer for a model with no meshes! Stack trace:");
if (WARN_EMPTY_MODELS) {
StringBuilder builder = new StringBuilder();
builder.append("Creating an instancer for a model with no meshes! Stack trace:");
StackWalker.getInstance()
// .walk(s -> s.skip(3)) // this causes forEach to crash for some reason
.forEach(f -> builder.append("\n\t")
.append(f.toString()));
StackWalker.getInstance()
.forEach(f -> builder.append("\n\t")
.append(f.toString()));
FlwBackend.LOGGER.warn(builder.toString());
FlwBackend.LOGGER.warn(builder.toString());
}
return false;
}

View file

@ -186,6 +186,10 @@ public class IndirectDrawManager extends DrawManager<IndirectInstancer<?>> {
programs.release();
depthPyramid.delete();
lightBuffers.delete();
matrixBuffer.delete();
}
public void renderCrumbling(List<Engine.CrumblingBlock> crumblingBlocks) {

View file

@ -40,4 +40,9 @@ public class LightBuffers {
GL46.glBindBufferRange(GL46.GL_SHADER_STORAGE_BUFFER, BufferBindings.LIGHT_LUT, lut.handle(), 0, lut.byteCapacity());
GL46.glBindBufferRange(GL46.GL_SHADER_STORAGE_BUFFER, BufferBindings.LIGHT_SECTION, sections.handle(), 0, sections.byteCapacity());
}
public void delete() {
lut.delete();
sections.delete();
}
}

View file

@ -30,4 +30,8 @@ public class MatrixBuffer {
GL46.glBindBufferRange(GL46.GL_SHADER_STORAGE_BUFFER, BufferBindings.MATRICES, matrices.handle(), 0, matrices.byteCapacity());
}
public void delete() {
matrices.delete();
}
}