Skip to content

Commit 1240398

Browse files
Merge pull request #19 from rextimmy/apple
Apple support
2 parents c793ba3 + 01d1d71 commit 1240398

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/vk_mem_alloc.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,8 +1739,18 @@ remove them if not needed.
17391739
#include <mutex> // for std::mutex
17401740
#include <atomic> // for std::atomic
17411741

1742-
#if !defined(_WIN32)
1742+
#if !defined(_WIN32) && !defined(__APPLE__)
17431743
#include <malloc.h> // for aligned_alloc()
1744+
#endif
1745+
1746+
#if defined(__APPLE__)
1747+
#include <cstdlib>
1748+
void *aligned_alloc(size_t alignment, size_t size)
1749+
{
1750+
void *pointer;
1751+
posix_memalign(&pointer, alignment, size);
1752+
return pointer;
1753+
}
17441754
#endif
17451755

17461756
// Normal assert to check for programmer's errors, especially in Debug configuration.
@@ -4964,7 +4974,7 @@ void VmaBlockMetadata::PrintDetailedMap(class VmaJsonWriter& json) const
49644974
json.WriteNumber(m_SumFreeSize);
49654975

49664976
json.WriteString("Allocations");
4967-
json.WriteNumber(m_Suballocations.size() - m_FreeCount);
4977+
json.WriteNumber((uint64_t)m_Suballocations.size() - m_FreeCount);
49684978

49694979
json.WriteString("UnusedRanges");
49704980
json.WriteNumber(m_FreeCount);
@@ -6322,7 +6332,7 @@ size_t VmaBlockVector::CalcMaxBlockSize() const
63226332
size_t result = 0;
63236333
for(size_t i = m_Blocks.size(); i--; )
63246334
{
6325-
result = VMA_MAX(result, m_Blocks[i]->m_Metadata.GetSize());
6335+
result = VMA_MAX((uint64_t)result, (uint64_t)m_Blocks[i]->m_Metadata.GetSize());
63266336
if(result >= m_PreferredBlockSize)
63276337
{
63286338
break;
@@ -6408,15 +6418,15 @@ void VmaBlockVector::PrintDetailedMap(class VmaJsonWriter& json)
64086418
if(m_MinBlockCount > 0)
64096419
{
64106420
json.WriteString("Min");
6411-
json.WriteNumber(m_MinBlockCount);
6421+
json.WriteNumber((uint64_t)m_MinBlockCount);
64126422
}
64136423
if(m_MaxBlockCount < SIZE_MAX)
64146424
{
64156425
json.WriteString("Max");
6416-
json.WriteNumber(m_MaxBlockCount);
6426+
json.WriteNumber((uint64_t)m_MaxBlockCount);
64176427
}
64186428
json.WriteString("Cur");
6419-
json.WriteNumber(m_Blocks.size());
6429+
json.WriteNumber((uint64_t)m_Blocks.size());
64206430
json.EndObject();
64216431

64226432
if(m_FrameInUseCount > 0)

0 commit comments

Comments
 (0)