1
0
Fork 0

Handle overflow properly

The code would misbehave if frames_drawn overflows.

Realistically this should not happen since UINT64_MAX is a lot of
frames, Godot could probably render until the end of the universe before
it triggers.

However any future intentional tampering with frames_drawn could trigger
this.
This commit is contained in:
Matias N. Goldberg 2025-02-19 14:33:20 -03:00
parent e567f49cbb
commit 70eb2fd995
1 changed files with 1 additions and 1 deletions

View File

@ -357,7 +357,7 @@ Error RenderingDevice::_staging_buffer_allocate(StagingBuffers &p_staging_buffer
}
}
} else if (p_staging_buffers.blocks[p_staging_buffers.current].frame_used <= frames_drawn - frames.size()) {
} else if (frames_drawn - p_staging_buffers.blocks[p_staging_buffers.current].frame_used >= frames.size()) {
// This is an old block, which was already processed, let's reuse.
p_staging_buffers.blocks.write[p_staging_buffers.current].frame_used = frames_drawn;
p_staging_buffers.blocks.write[p_staging_buffers.current].fill_amount = 0;