Skip to content

Commit

Permalink
No one can hear you free
Browse files Browse the repository at this point in the history
- Silence empty model warning behind a system property
- Fix gpu memory leak from light/matrix buffers on indirect
  • Loading branch information
Jozufozu committed Nov 12, 2024
1 parent 6709682 commit 868a263
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
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>
Expand Down Expand Up @@ -100,15 +102,16 @@ private static boolean checkAndWarnEmptyModel(Model model) {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ public void delete() {
programs.release();

depthPyramid.delete();

lightBuffers.delete();

matrixBuffer.delete();
}

public void renderCrumbling(List<Engine.CrumblingBlock> crumblingBlocks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ public void bind() {
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ public void bind() {

GL46.glBindBufferRange(GL46.GL_SHADER_STORAGE_BUFFER, BufferBindings.MATRICES, matrices.handle(), 0, matrices.byteCapacity());
}

public void delete() {
matrices.delete();
}
}

0 comments on commit 868a263

Please sign in to comment.