StagingBuffer: Large slots should be aligned to alignment

Slots whose stride size is larger than the slot alignment value
should have their size rounded up to the alignment size so that
the slots that follow them will also be aligned.
This commit is contained in:
2025-11-20 00:03:50 -04:00
parent 5789a31e23
commit 0cfb0a9c07
3 changed files with 167 additions and 361 deletions
@@ -68,10 +68,13 @@ static size_t calculateMaxAlignment(
void StagingBuffer::computeSlotStrideAndBufferSize()
{
// Slot stride is the maximum of alignment and padding
slotStrideNBytes = std::max(
// Slot stride is the maximum of alignment and padding, rounded up to a multiple of alignment
size_t minSlotStride = std::max(
inputConstraints.slotStartAlignmentByteVal,
inputConstraints.slotPadToNBytes);
slotStrideNBytes = ((minSlotStride + inputConstraints.slotStartAlignmentByteVal - 1)
/ inputConstraints.slotStartAlignmentByteVal)
* inputConstraints.slotStartAlignmentByteVal;
// Calculate maximum alignment needed for first slot (must satisfy both frame and slot alignment)
size_t maxAlignment = calculateMaxAlignment(