mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-12 23:36:09 +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
2 changed files with 10 additions and 11 deletions
|
@ -58,8 +58,13 @@ public abstract class DrawManager<N extends AbstractInstancer<?>> {
|
||||||
public void flush(LightStorage lightStorage, EnvironmentStorage environmentStorage) {
|
public void flush(LightStorage lightStorage, EnvironmentStorage environmentStorage) {
|
||||||
// Thread safety: flush is called from the render thread after all visual updates have been made,
|
// 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.
|
// so there are no:tm: threads we could be racing with.
|
||||||
for (var instancer : initializationQueue) {
|
for (var init : initializationQueue) {
|
||||||
initialize(instancer.key(), instancer.instancer());
|
var instancer = init.instancer();
|
||||||
|
if (instancer.instanceCount() > 0) {
|
||||||
|
initialize(init.key(), instancer);
|
||||||
|
} else {
|
||||||
|
instancers.remove(init.key());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
initializationQueue.clear();
|
initializationQueue.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,23 +70,17 @@ public class MeshPool {
|
||||||
if (anyToRemove) {
|
if (anyToRemove) {
|
||||||
anyToRemove = false;
|
anyToRemove = false;
|
||||||
processDeletions();
|
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.
|
// Otherwise, just update the index with the new counts.
|
||||||
for (PooledMesh mesh : recentlyAllocated) {
|
for (PooledMesh mesh : recentlyAllocated) {
|
||||||
indexPool.updateCount(mesh.mesh.indexSequence(), mesh.indexCount());
|
indexPool.updateCount(mesh.mesh.indexSequence(), mesh.indexCount());
|
||||||
}
|
}
|
||||||
|
indexPool.flush();
|
||||||
recentlyAllocated.clear();
|
recentlyAllocated.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always need to flush the index pool.
|
|
||||||
indexPool.flush();
|
|
||||||
|
|
||||||
uploadAll();
|
uploadAll();
|
||||||
dirty = false;
|
dirty = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue