Add RoundUpToMultiple and DivideAndRoundUp functions to MathUtils.h (#6989)
* Add RoundUpToMultiple and DivideAndRoundUp functions to MathUtils.h Signed-off-by: Tommy Walton <waltont@amazon.com> * Rename DivideByMultiple2 back to DivideByMultiple, now that I've confirmed it's not in use in the codebase. RHI::DivideByMultiple can be fully deprecated in favor of AZ::DivideAndRoundUp at a later date, once the deprecation strategy has been finalized. Signed-off-by: Tommy Walton <waltont@amazon.com> * Update based on PR feedback Signed-off-by: Tommy Walton <waltont@amazon.com> * Switched from std::numeric_limits to AZStd::numeric_limits and updated the header to indicate it works for non-power of two alignments, but that SizeAlignUp is more efficient if the alignment is a power of 2 Signed-off-by: Tommy Walton <waltont@amazon.com> * Added missing arguments to the assert, and a missing namespace and include that failed to compile on non-unity builds Signed-off-by: Tommy Walton <waltont@amazon.com>
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include <GridMate/Containers/unordered_set.h>
|
||||
#include <GridMate/Carrier/DriverEvents.h>
|
||||
|
||||
#include <AzCore/Math/MathUtils.h>
|
||||
#include <AzCore/std/chrono/types.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzCore/std/string/memorytoascii.h>
|
||||
@@ -1951,7 +1952,7 @@ namespace GridMate
|
||||
char *SocketDriverCommon::RIOPlatformSocketDriver::AllocRIOBuffer(AZ::u64 bufferSize, AZ::u64 numBuffers, AZ::u64* amountAllocated /*=nullptr*/)
|
||||
{
|
||||
// calculate how much memory we are really asking for, and this must be page aligned.
|
||||
AZ::u64 totalBufferSize = RoundUp(bufferSize * numBuffers, m_pageSize);
|
||||
AZ::u64 totalBufferSize = AZ::RoundUpToMultiple(bufferSize * numBuffers, m_pageSize);
|
||||
|
||||
if (amountAllocated != nullptr)
|
||||
{
|
||||
|
||||
@@ -221,18 +221,6 @@ namespace GridMate
|
||||
void StopWaitForData() override;
|
||||
|
||||
private:
|
||||
AZ::u64 RoundUpAndDivide(AZ::u64 Value, AZ::u64 RoundTo) const
|
||||
{
|
||||
return ((Value + RoundTo - 1) / RoundTo);
|
||||
}
|
||||
AZ::u64 RoundUp(AZ::u64 Value, AZ::u64 RoundTo) const
|
||||
{
|
||||
// rounds value up to multiple of RoundTo
|
||||
// Example: RoundTo: 4
|
||||
// Value: 0 1 2 3 4 5 6 7 8
|
||||
// Result: 0 4 4 4 4 8 8 8 8
|
||||
return RoundUpAndDivide(Value, RoundTo) * RoundTo;
|
||||
}
|
||||
char *AllocRIOBuffer(AZ::u64 bufferSize, AZ::u64 numBuffers, AZ::u64* amountAllocated=nullptr);
|
||||
bool FreeRIOBuffer(char *buffer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user