The ring buffer is defined as:
class DVKRingBuffer
{
uint64 AllocateMemory(uint64 size)
{
uint64 allocationOffset = Align<uint64>(bufferOffset, minAlignment);
if (allocationOffset + size <= bufferSize)
{
bufferOffset = allocationOffset + size;
return allocationOffset;
}
bufferOffset = 0;
return bufferOffset;
}
When allocation is going to exceed the bufferSize allocationOffset + size > bufferSize, why bufferOffset = 0; but not bufferOffset = size? I think the latter is the right one, meaning that you reset your allocation to the start of inner buffer, and you have allocate size memory.
I think this is right:
class DVKRingBuffer
{
uint64 AllocateMemory(uint64 size)
{
uint64 allocationOffset = Align<uint64>(bufferOffset, minAlignment);
if (allocationOffset + size <= bufferSize)
{
bufferOffset = allocationOffset + size;
return allocationOffset;
}
bufferOffset = size;
return 0;
}