Fix #131212: Metal: Non-aligned circular buffer allocation logic

The new buffer size could have been non aligned when using the
fractional growing heuristic. This non aligned allocation
would then trigger an assert at the SSBO constructor.

Aligning the alocation size fixes the issue.
This commit is contained in:
Clément Foucault
2024-12-02 17:34:28 +01:00
parent 62b2bb48e8
commit 4bfaecc340

View File

@@ -990,9 +990,9 @@ MTLTemporaryBuffer MTLCircularBuffer::allocate_range_aligned(uint64_t alloc_size
/* Resize to the maximum of basic resize heuristic OR the size of the current offset +
* requested allocation -- we want the buffer to grow to a large enough size such that it
* does not need to resize mid-frame. */
new_size = max_ulul(
min_ulul(MTLScratchBufferManager::mtl_scratch_buffer_max_size_, new_size * 1.2),
aligned_current_offset + aligned_alloc_size);
new_size = max_ulul(min_ulul(MTLScratchBufferManager::mtl_scratch_buffer_max_size_,
ceil_to_multiple_ul(new_size * 1.2f, 256)),
aligned_current_offset + aligned_alloc_size);
#ifdef MTL_SCRATCH_BUFFER_ALLOW_TEMPORARY_EXPANSION
/* IF a requested allocation EXCEEDS the maximum supported size, temporarily allocate up to