Optimize vertex buffer writing in Debug Draw

This commit is contained in:
Wojtek Figat
2021-10-27 11:03:08 +02:00
parent 883a829590
commit 7ca83858ab
2 changed files with 78 additions and 101 deletions

View File

@@ -75,6 +75,27 @@ public:
Data.Add((byte*)bytes, size);
}
/// <summary>
/// Allocates bytes in the buffer by resizing the buffer for new memory and returns the pointer to the start of the allocated space.
/// </summary>
/// <param name="size">Amount of data to allocate (in bytes)</param>
FORCE_INLINE byte* WriteReserve(int32 size)
{
const int32 start = Data.Count();
Data.AddUninitialized(size);
return Data.Get() + start;
}
/// <summary>
/// Allocates bytes in the buffer by resizing the buffer for new memory and returns the pointer to the start of the allocated space.
/// </summary>
/// <param name="count">Amount of items to allocate</param>
template<typename T>
FORCE_INLINE T* WriteReserve(int32 count)
{
return (T*)WriteReserve(count * sizeof(T));
}
/// <summary>
/// Unlock buffer and flush data with a buffer (it will be ready for an immediate draw).
/// </summary>