Don't delete the buffers that batch building writes into every frame. (#17841)

The `collect_buffers_for_phase` system tries to reuse these buffers, but
its efforts are stymied by the fact that
`clear_batched_gpu_instance_buffers` clears the containing hash table
and therefore frees the buffers. This patch makes
`clear_batched_gpu_instance_buffers` stop doing that so that the
allocations can be reused.
This commit is contained in:
Patrick Walton 2025-02-16 11:58:03 -08:00 committed by GitHub
parent 794bf6a332
commit 7801ed315f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1144,8 +1144,9 @@ where
/// Clears out the buffers in preparation for a new frame.
pub fn clear(&mut self) {
// TODO: Don't do this.
self.phase_instance_buffers.clear();
for phase_instance_buffer in self.phase_instance_buffers.values_mut() {
phase_instance_buffer.clear();
}
}
}
@ -1275,6 +1276,8 @@ pub fn clear_batched_gpu_instance_buffers<GFBD>(
) where
GFBD: GetFullBatchData,
{
// Don't clear the entire table, because that would delete the buffers, and
// we want to reuse those allocations.
if let Some(mut gpu_batched_instance_buffers) = gpu_batched_instance_buffers {
gpu_batched_instance_buffers.clear();
}