Fix for not applying debug margin in Generic algorithm.

Ported test for linear algorithm from VMA.

Code by @medranSolus
This commit is contained in:
Adam Sawicki 2022-02-07 16:35:36 +01:00
parent 80cd0026a1
commit ae519f2521
5 changed files with 1122 additions and 144 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
build/
bin/

View File

@ -349,6 +349,8 @@ struct MyUniformRandomNumberGenerator
{
typedef uint32_t result_type;
MyUniformRandomNumberGenerator(RandomNumberGenerator& gen) : m_Gen(gen) { }
static uint32_t min() { return 0; }
static uint32_t max() { return UINT32_MAX; }
uint32_t operator()() { return m_Gen.Generate(); }
private:

View File

@ -4009,8 +4009,8 @@ bool BlockMetadata_Generic::CheckAllocation(
return false;
}
// Start from offset equal to beginning of this suballocation.
UINT64 offset = suballoc.offset;
// Start from offset equal to beginning of this suballocation and debug margin of previous allocation if present.
UINT64 offset = suballoc.offset + (suballocItem == m_Suballocations.cbegin() ? 0 : GetDebugMargin());
// Apply alignment.
offset = AlignUp(offset, allocAlignment);
@ -4018,7 +4018,7 @@ bool BlockMetadata_Generic::CheckAllocation(
// Calculate padding at the beginning based on current offset.
const UINT64 paddingBegin = offset - suballoc.offset;
// Fail if requested size plus margin before and after is bigger than size of this suballocation.
// Fail if requested size plus margin after is bigger than size of this suballocation.
if(paddingBegin + allocSize + GetDebugMargin() > suballoc.size)
{
return false;

View File

@ -20,8 +20,8 @@
// THE SOFTWARE.
//
#include "D3D12MemAlloc.h"
#include "Common.h"
#include "D3D12MemAlloc.h"
#include "Tests.h"
#include <atomic>
#include <Shlwapi.h> // For StrStrI

File diff suppressed because it is too large Load Diff