mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-14 06:24:12 +01:00
Save yourself the trouble
- Don't initialize instancers if they have 0 instances - Never shrink the index pool - Actually process recently allocated meshes to avoid growing the list forever
This commit is contained in:
parent
68453d8349
commit
5b97a56c8c
@ -58,8 +58,13 @@ public abstract class DrawManager<N extends AbstractInstancer<?>> {
|
||||
public void flush(LightStorage lightStorage, EnvironmentStorage environmentStorage) {
|
||||
// Thread safety: flush is called from the render thread after all visual updates have been made,
|
||||
// so there are no:tm: threads we could be racing with.
|
||||
for (var instancer : initializationQueue) {
|
||||
initialize(instancer.key(), instancer.instancer());
|
||||
for (var init : initializationQueue) {
|
||||
var instancer = init.instancer();
|
||||
if (instancer.instanceCount() > 0) {
|
||||
initialize(init.key(), instancer);
|
||||
} else {
|
||||
instancers.remove(init.key());
|
||||
}
|
||||
}
|
||||
initializationQueue.clear();
|
||||
}
|
||||
|
@ -70,23 +70,17 @@ public class MeshPool {
|
||||
if (anyToRemove) {
|
||||
anyToRemove = false;
|
||||
processDeletions();
|
||||
}
|
||||
|
||||
// Might want to shrink the index pool if something was removed.
|
||||
indexPool.reset();
|
||||
for (PooledMesh mesh : meshList) {
|
||||
indexPool.updateCount(mesh.mesh.indexSequence(), mesh.indexCount());
|
||||
}
|
||||
} else {
|
||||
if (!recentlyAllocated.isEmpty()) {
|
||||
// Otherwise, just update the index with the new counts.
|
||||
for (PooledMesh mesh : recentlyAllocated) {
|
||||
indexPool.updateCount(mesh.mesh.indexSequence(), mesh.indexCount());
|
||||
}
|
||||
indexPool.flush();
|
||||
recentlyAllocated.clear();
|
||||
}
|
||||
|
||||
// Always need to flush the index pool.
|
||||
indexPool.flush();
|
||||
|
||||
uploadAll();
|
||||
dirty = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user