Update Vulkan memory allocator
Fixes: QTBUG-107715 Change-Id: I8ab0dc22cf4207e1ef6bc2a170dbd7c2cdd52ee4 Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>bb10
parent
d46ad52872
commit
c31b3d052e
|
|
@ -1,52 +0,0 @@
|
|||
From 8dedd23c769e5b8b76bea9d322fc46a46a2bf76e Mon Sep 17 00:00:00 2001
|
||||
From: Laszlo Agocs <laszlo.agocs@qt.io>
|
||||
Date: Thu, 14 Jan 2021 11:25:27 +0100
|
||||
Subject: [PATCH 2/4] Make it compile on macOS 10.15
|
||||
|
||||
Change-Id: I0c26c16ed65668fa90330571d3b741e730b439da
|
||||
---
|
||||
.../VulkanMemoryAllocator/vk_mem_alloc.h | 21 ++++++++++++++++++-
|
||||
1 file changed, 20 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
index 8e579967d9..10369475c7 100644
|
||||
--- a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
+++ b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
@@ -3560,7 +3560,24 @@ void *aligned_alloc(size_t alignment, size_t size)
|
||||
|
||||
return memalign(alignment, size);
|
||||
}
|
||||
-#elif defined(__APPLE__) || defined(__ANDROID__) || (defined(__linux__) && defined(__GLIBCXX__) && !defined(_GLIBCXX_HAVE_ALIGNED_ALLOC))
|
||||
+#elif defined(__APPLE__)
|
||||
+#include <cstdlib>
|
||||
+// aligned_alloc() is marked as macOS 10.15 only in the 10.15 SDK,
|
||||
+// avoid the mess by using a different name
|
||||
+void *vma_aligned_alloc(size_t alignment, size_t size)
|
||||
+{
|
||||
+ // alignment must be >= sizeof(void*)
|
||||
+ if(alignment < sizeof(void*))
|
||||
+ {
|
||||
+ alignment = sizeof(void*);
|
||||
+ }
|
||||
+
|
||||
+ void *pointer;
|
||||
+ if(posix_memalign(&pointer, alignment, size) == 0)
|
||||
+ return pointer;
|
||||
+ return VMA_NULL;
|
||||
+}
|
||||
+#elif defined(__ANDROID__) || (defined(__linux__) && defined(__GLIBCXX__) && !defined(_GLIBCXX_HAVE_ALIGNED_ALLOC))
|
||||
#include <cstdlib>
|
||||
void *aligned_alloc(size_t alignment, size_t size)
|
||||
{
|
||||
@@ -3608,6 +3625,8 @@ void *aligned_alloc(size_t alignment, size_t size)
|
||||
#ifndef VMA_SYSTEM_ALIGNED_MALLOC
|
||||
#if defined(_WIN32)
|
||||
#define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) (_aligned_malloc((size), (alignment)))
|
||||
+ #elif defined(__APPLE__)
|
||||
+ #define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) (vma_aligned_alloc((alignment), (size) ))
|
||||
#else
|
||||
#define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) (aligned_alloc((alignment), (size) ))
|
||||
#endif
|
||||
--
|
||||
2.23.0.windows.1
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
From 81ec04850473efe01ffdc5bc9383272e77f8cc4e Mon Sep 17 00:00:00 2001
|
||||
From: Laszlo Agocs <laszlo.agocs@qt.io>
|
||||
Date: Mon, 17 Oct 2022 14:14:12 +0200
|
||||
Subject: [PATCH] Switch back to the old VK_VERSION_* etc. from
|
||||
VK_API_VERSION_*
|
||||
|
||||
Change-Id: I412ff542ddda895a837c34c4ca40fb4845eae2ba
|
||||
---
|
||||
src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
index 02de45fa1c..ef3ad65060 100644
|
||||
--- a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
+++ b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
@@ -16114,11 +16114,11 @@ VMA_CALL_PRE void VMA_CALL_POST vmaBuildStatsString(
|
||||
|
||||
json.WriteString("apiVersion");
|
||||
json.BeginString();
|
||||
- json.ContinueString(VK_API_VERSION_MAJOR(deviceProperties.apiVersion));
|
||||
+ json.ContinueString(VK_VERSION_MAJOR(deviceProperties.apiVersion));
|
||||
json.ContinueString(".");
|
||||
- json.ContinueString(VK_API_VERSION_MINOR(deviceProperties.apiVersion));
|
||||
+ json.ContinueString(VK_VERSION_MINOR(deviceProperties.apiVersion));
|
||||
json.ContinueString(".");
|
||||
- json.ContinueString(VK_API_VERSION_PATCH(deviceProperties.apiVersion));
|
||||
+ json.ContinueString(VK_VERSION_PATCH(deviceProperties.apiVersion));
|
||||
json.EndString();
|
||||
|
||||
json.WriteString("GPU");
|
||||
--
|
||||
2.36.1.windows.1
|
||||
|
||||
50
src/3rdparty/VulkanMemoryAllocator/patches/0003-Disable-some-warnings-for-gcc-and-clang.patch
vendored
Normal file
50
src/3rdparty/VulkanMemoryAllocator/patches/0003-Disable-some-warnings-for-gcc-and-clang.patch
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
From aca24b15fbb6b47c35cbd7cd31a3db840df52ded Mon Sep 17 00:00:00 2001
|
||||
From: Laszlo Agocs <laszlo.agocs@qt.io>
|
||||
Date: Mon, 17 Oct 2022 16:33:50 +0200
|
||||
Subject: [PATCH] Disable some warnings for gcc and clang
|
||||
|
||||
Change-Id: I81c6c5a2ce736846b6fd95c7f66b7946f7357cf2
|
||||
---
|
||||
.../VulkanMemoryAllocator/vk_mem_alloc.h | 19 +++++++++++++++++++
|
||||
1 file changed, 19 insertions(+)
|
||||
|
||||
diff --git a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
index ef3ad65060..2a5b1e4b1a 100644
|
||||
--- a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
+++ b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
@@ -2565,6 +2565,18 @@ VMA_CALL_PRE void VMA_CALL_POST vmaFreeStatsString(
|
||||
#ifdef VMA_IMPLEMENTATION
|
||||
#undef VMA_IMPLEMENTATION
|
||||
|
||||
+#if defined(__GNUC__) && !defined(__clang__)
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
+#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
+#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
+#elif defined(__clang__)
|
||||
+#pragma clang diagnostic push
|
||||
+#pragma clang diagnostic ignored "-Wunused-variable"
|
||||
+#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
+#pragma clang diagnostic ignored "-Wmissing-field-initializers"
|
||||
+#endif
|
||||
+
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
@@ -17526,6 +17538,13 @@ VMA_CALL_PRE void VMA_CALL_POST vmaFreeVirtualBlockStatsString(VmaVirtualBlock V
|
||||
}
|
||||
#endif // VMA_STATS_STRING_ENABLED
|
||||
#endif // _VMA_PUBLIC_INTERFACE
|
||||
+
|
||||
+#if defined(__GNUC__) && !defined(__clang__)
|
||||
+#pragma GCC diagnostic pop
|
||||
+#elif defined(__clang__)
|
||||
+#pragma clang diagnostic pop
|
||||
+#endif
|
||||
+
|
||||
#endif // VMA_IMPLEMENTATION
|
||||
|
||||
/**
|
||||
--
|
||||
2.36.1.windows.1
|
||||
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
From 2c51f161e9730482b6ebcc4a73b525d5aa4e539a Mon Sep 17 00:00:00 2001
|
||||
From: Laszlo Agocs <laszlo.agocs@qt.io>
|
||||
Date: Thu, 14 Jan 2021 11:26:48 +0100
|
||||
Subject: [PATCH 3/4] Fix gcc 8 warning
|
||||
|
||||
Change-Id: I150223178ecc1e177f669f7415b147f9779f019c
|
||||
---
|
||||
src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
index 10369475c7..79efc1f0da 100644
|
||||
--- a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
+++ b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
@@ -12640,7 +12640,8 @@ void VmaBlockVector::ApplyDefragmentationMovesGpu(
|
||||
const size_t blockCount = m_Blocks.size();
|
||||
|
||||
pDefragCtx->blockContexts.resize(blockCount);
|
||||
- memset(pDefragCtx->blockContexts.data(), 0, blockCount * sizeof(VmaBlockDefragmentationContext));
|
||||
+ for (size_t i = 0; i < blockCount; ++i)
|
||||
+ pDefragCtx->blockContexts[i] = VmaBlockDefragmentationContext();
|
||||
|
||||
// Go over all moves. Mark blocks that are used with BLOCK_FLAG_USED.
|
||||
const size_t moveCount = moves.size();
|
||||
--
|
||||
2.23.0.windows.1
|
||||
|
||||
|
|
@ -1,327 +0,0 @@
|
|||
From 6b27f49d0a2d2391654cd89f9a9ef77fad934f66 Mon Sep 17 00:00:00 2001
|
||||
From: Laszlo Agocs <laszlo.agocs@qt.io>
|
||||
Date: Thu, 14 Jan 2021 11:57:18 +0100
|
||||
Subject: [PATCH 4/4] Avoid compiler warnings
|
||||
|
||||
Change-Id: I3c9bc051229b02efeae60e27a53c3c4d17c7f995
|
||||
---
|
||||
.../VulkanMemoryAllocator/vk_mem_alloc.h | 84 ++++++++++++-------
|
||||
1 file changed, 56 insertions(+), 28 deletions(-)
|
||||
|
||||
diff --git a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
index 79efc1f0da..ebaeb4bcff 100644
|
||||
--- a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
+++ b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
@@ -4080,7 +4080,7 @@ static void VmaWriteMagicValue(void* pData, VkDeviceSize offset)
|
||||
#if VMA_DEBUG_MARGIN > 0 && VMA_DEBUG_DETECT_CORRUPTION
|
||||
uint32_t* pDst = (uint32_t*)((char*)pData + offset);
|
||||
const size_t numberCount = VMA_DEBUG_MARGIN / sizeof(uint32_t);
|
||||
- for(size_t i = 0; i < numberCount; ++i, ++pDst)
|
||||
+ for(size_t i = 0; i != numberCount; ++i, ++pDst)
|
||||
{
|
||||
*pDst = VMA_CORRUPTION_DETECTION_MAGIC_VALUE;
|
||||
}
|
||||
@@ -4094,7 +4094,7 @@ static bool VmaValidateMagicValue(const void* pData, VkDeviceSize offset)
|
||||
#if VMA_DEBUG_MARGIN > 0 && VMA_DEBUG_DETECT_CORRUPTION
|
||||
const uint32_t* pSrc = (const uint32_t*)((const char*)pData + offset);
|
||||
const size_t numberCount = VMA_DEBUG_MARGIN / sizeof(uint32_t);
|
||||
- for(size_t i = 0; i < numberCount; ++i, ++pSrc)
|
||||
+ for(size_t i = 0; i != numberCount; ++i, ++pSrc)
|
||||
{
|
||||
if(*pSrc != VMA_CORRUPTION_DETECTION_MAGIC_VALUE)
|
||||
{
|
||||
@@ -4339,7 +4339,7 @@ public:
|
||||
template<typename U> VmaStlAllocator(const VmaStlAllocator<U>& src) : m_pCallbacks(src.m_pCallbacks) { }
|
||||
|
||||
T* allocate(size_t n) { return VmaAllocateArray<T>(m_pCallbacks, n); }
|
||||
- void deallocate(T* p, size_t n) { VmaFree(m_pCallbacks, p); }
|
||||
+ void deallocate(T* p, size_t /*n*/) { VmaFree(m_pCallbacks, p); }
|
||||
|
||||
template<typename U>
|
||||
bool operator==(const VmaStlAllocator<U>& rhs) const
|
||||
@@ -6067,7 +6067,7 @@ public:
|
||||
|
||||
virtual uint32_t MakeAllocationsLost(uint32_t currentFrameIndex, uint32_t frameInUseCount);
|
||||
|
||||
- virtual VkResult CheckCorruption(const void* pBlockData) { return VK_ERROR_FEATURE_NOT_PRESENT; }
|
||||
+ virtual VkResult CheckCorruption(const void* /*pBlockData*/) { return VK_ERROR_FEATURE_NOT_PRESENT; }
|
||||
|
||||
virtual void Alloc(
|
||||
const VmaAllocationRequest& request,
|
||||
@@ -6637,7 +6637,7 @@ public:
|
||||
bool overlappingMoveSupported);
|
||||
virtual ~VmaDefragmentationAlgorithm_Fast();
|
||||
|
||||
- virtual void AddAllocation(VmaAllocation hAlloc, VkBool32* pChanged) { ++m_AllocationCount; }
|
||||
+ virtual void AddAllocation(VmaAllocation /*hAlloc*/, VkBool32* /*pChanged*/) { ++m_AllocationCount; }
|
||||
virtual void AddAll() { m_AllAllocations = true; }
|
||||
|
||||
virtual VkResult Defragment(
|
||||
@@ -7699,6 +7699,7 @@ void VmaJsonWriter::BeginValue(bool isString)
|
||||
if(currItem.type == COLLECTION_TYPE_OBJECT &&
|
||||
currItem.valueCount % 2 == 0)
|
||||
{
|
||||
+ (void) isString;
|
||||
VMA_ASSERT(isString);
|
||||
}
|
||||
|
||||
@@ -8251,7 +8252,9 @@ bool VmaBlockMetadata_Generic::Validate() const
|
||||
}
|
||||
|
||||
// Margin required between allocations - every free space must be at least that large.
|
||||
+#if VMA_DEBUG_MARGIN
|
||||
VMA_VALIDATE(subAlloc.size >= VMA_DEBUG_MARGIN);
|
||||
+#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -8397,6 +8400,7 @@ bool VmaBlockMetadata_Generic::CreateAllocationRequest(
|
||||
{
|
||||
VMA_ASSERT(allocSize > 0);
|
||||
VMA_ASSERT(!upperAddress);
|
||||
+ (void) upperAddress;
|
||||
VMA_ASSERT(allocType != VMA_SUBALLOCATION_TYPE_FREE);
|
||||
VMA_ASSERT(pAllocationRequest != VMA_NULL);
|
||||
VMA_HEAVY_ASSERT(Validate());
|
||||
@@ -10136,10 +10140,12 @@ bool VmaBlockMetadata_Linear::CreateAllocationRequest_UpperAddress(
|
||||
// Apply VMA_DEBUG_MARGIN at the end.
|
||||
if(VMA_DEBUG_MARGIN > 0)
|
||||
{
|
||||
+#if VMA_DEBUG_MARGIN
|
||||
if(resultOffset < VMA_DEBUG_MARGIN)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
+#endif
|
||||
resultOffset -= VMA_DEBUG_MARGIN;
|
||||
}
|
||||
|
||||
@@ -11079,18 +11085,19 @@ void VmaBlockMetadata_Buddy::PrintDetailedMap(class VmaJsonWriter& json) const
|
||||
#endif // #if VMA_STATS_STRING_ENABLED
|
||||
|
||||
bool VmaBlockMetadata_Buddy::CreateAllocationRequest(
|
||||
- uint32_t currentFrameIndex,
|
||||
- uint32_t frameInUseCount,
|
||||
+ uint32_t /*currentFrameIndex*/,
|
||||
+ uint32_t /*frameInUseCount*/,
|
||||
VkDeviceSize bufferImageGranularity,
|
||||
VkDeviceSize allocSize,
|
||||
VkDeviceSize allocAlignment,
|
||||
bool upperAddress,
|
||||
VmaSuballocationType allocType,
|
||||
- bool canMakeOtherLost,
|
||||
- uint32_t strategy,
|
||||
+ bool /*canMakeOtherLost*/,
|
||||
+ uint32_t /*strategy*/,
|
||||
VmaAllocationRequest* pAllocationRequest)
|
||||
{
|
||||
VMA_ASSERT(!upperAddress && "VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT can be used only with linear algorithm.");
|
||||
+ (void) upperAddress;
|
||||
|
||||
// Simple way to respect bufferImageGranularity. May be optimized some day.
|
||||
// Whenever it might be an OPTIMAL image...
|
||||
@@ -11131,8 +11138,8 @@ bool VmaBlockMetadata_Buddy::CreateAllocationRequest(
|
||||
}
|
||||
|
||||
bool VmaBlockMetadata_Buddy::MakeRequestedAllocationsLost(
|
||||
- uint32_t currentFrameIndex,
|
||||
- uint32_t frameInUseCount,
|
||||
+ uint32_t /*currentFrameIndex*/,
|
||||
+ uint32_t /*frameInUseCount*/,
|
||||
VmaAllocationRequest* pAllocationRequest)
|
||||
{
|
||||
/*
|
||||
@@ -11142,7 +11149,7 @@ bool VmaBlockMetadata_Buddy::MakeRequestedAllocationsLost(
|
||||
return pAllocationRequest->itemsToMakeLostCount == 0;
|
||||
}
|
||||
|
||||
-uint32_t VmaBlockMetadata_Buddy::MakeAllocationsLost(uint32_t currentFrameIndex, uint32_t frameInUseCount)
|
||||
+uint32_t VmaBlockMetadata_Buddy::MakeAllocationsLost(uint32_t /*currentFrameIndex*/, uint32_t /*frameInUseCount*/)
|
||||
{
|
||||
/*
|
||||
Lost allocations are not supported in buddy allocator at the moment.
|
||||
@@ -11153,7 +11160,7 @@ uint32_t VmaBlockMetadata_Buddy::MakeAllocationsLost(uint32_t currentFrameIndex,
|
||||
|
||||
void VmaBlockMetadata_Buddy::Alloc(
|
||||
const VmaAllocationRequest& request,
|
||||
- VmaSuballocationType type,
|
||||
+ VmaSuballocationType /*type*/,
|
||||
VkDeviceSize allocSize,
|
||||
VmaAllocation hAllocation)
|
||||
{
|
||||
@@ -11480,7 +11487,7 @@ void VmaBlockMetadata_Buddy::PrintDetailedMapNode(class VmaJsonWriter& json, con
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class VmaDeviceMemoryBlock
|
||||
|
||||
-VmaDeviceMemoryBlock::VmaDeviceMemoryBlock(VmaAllocator hAllocator) :
|
||||
+VmaDeviceMemoryBlock::VmaDeviceMemoryBlock(VmaAllocator /*hAllocator*/) :
|
||||
m_pMetadata(VMA_NULL),
|
||||
m_MemoryTypeIndex(UINT32_MAX),
|
||||
m_Id(0),
|
||||
@@ -12268,6 +12275,7 @@ VkResult VmaBlockVector::AllocatePage(
|
||||
if(IsCorruptionDetectionEnabled())
|
||||
{
|
||||
VkResult res = pBestRequestBlock->WriteMagicValueAroundAllocation(m_hAllocator, bestRequest.offset, size);
|
||||
+ (void) res;
|
||||
VMA_ASSERT(res == VK_SUCCESS && "Couldn't map block memory to write magic value.");
|
||||
}
|
||||
return VK_SUCCESS;
|
||||
@@ -12314,6 +12322,7 @@ void VmaBlockVector::Free(
|
||||
if(IsCorruptionDetectionEnabled())
|
||||
{
|
||||
VkResult res = pBlock->ValidateMagicValueAroundAllocation(m_hAllocator, hAllocation->GetOffset(), hAllocation->GetSize());
|
||||
+ (void) res;
|
||||
VMA_ASSERT(res == VK_SUCCESS && "Couldn't map block memory to validate magic value.");
|
||||
}
|
||||
|
||||
@@ -12472,6 +12481,7 @@ VkResult VmaBlockVector::AllocateFromBlock(
|
||||
if(IsCorruptionDetectionEnabled())
|
||||
{
|
||||
VkResult res = pBlock->WriteMagicValueAroundAllocation(m_hAllocator, currRequest.offset, size);
|
||||
+ (void) res;
|
||||
VMA_ASSERT(res == VK_SUCCESS && "Couldn't map block memory to write magic value.");
|
||||
}
|
||||
return VK_SUCCESS;
|
||||
@@ -12481,7 +12491,8 @@ VkResult VmaBlockVector::AllocateFromBlock(
|
||||
|
||||
VkResult VmaBlockVector::CreateBlock(VkDeviceSize blockSize, size_t* pNewBlockIndex)
|
||||
{
|
||||
- VkMemoryAllocateInfo allocInfo = { VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO };
|
||||
+ VkMemoryAllocateInfo allocInfo = {};
|
||||
+ allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||
allocInfo.memoryTypeIndex = m_MemoryTypeIndex;
|
||||
allocInfo.allocationSize = blockSize;
|
||||
VkDeviceMemory mem = VK_NULL_HANDLE;
|
||||
@@ -12570,7 +12581,8 @@ void VmaBlockVector::ApplyDefragmentationMovesCpu(
|
||||
if(pDefragCtx->res == VK_SUCCESS)
|
||||
{
|
||||
const VkDeviceSize nonCoherentAtomSize = m_hAllocator->m_PhysicalDeviceProperties.limits.nonCoherentAtomSize;
|
||||
- VkMappedMemoryRange memRange = { VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE };
|
||||
+ VkMappedMemoryRange memRange = {};
|
||||
+ memRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
|
||||
|
||||
for(size_t moveIndex = 0; moveIndex < moveCount; ++moveIndex)
|
||||
{
|
||||
@@ -13032,7 +13044,7 @@ VmaDefragmentationAlgorithm_Generic::VmaDefragmentationAlgorithm_Generic(
|
||||
VmaAllocator hAllocator,
|
||||
VmaBlockVector* pBlockVector,
|
||||
uint32_t currentFrameIndex,
|
||||
- bool overlappingMoveSupported) :
|
||||
+ bool /*overlappingMoveSupported*/) :
|
||||
VmaDefragmentationAlgorithm(hAllocator, pBlockVector, currentFrameIndex),
|
||||
m_AllocationCount(0),
|
||||
m_AllAllocations(false),
|
||||
@@ -15032,8 +15044,13 @@ VkResult VmaAllocator_T::AllocateDedicatedMemory(
|
||||
bool map,
|
||||
bool isUserDataString,
|
||||
void* pUserData,
|
||||
+#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000
|
||||
VkBuffer dedicatedBuffer,
|
||||
VkImage dedicatedImage,
|
||||
+#else
|
||||
+ VkBuffer /*dedicatedBuffer*/,
|
||||
+ VkImage /*dedicatedImage*/,
|
||||
+#endif
|
||||
size_t allocationCount,
|
||||
VmaAllocation* pAllocations)
|
||||
{
|
||||
@@ -15050,12 +15067,14 @@ VkResult VmaAllocator_T::AllocateDedicatedMemory(
|
||||
}
|
||||
}
|
||||
|
||||
- VkMemoryAllocateInfo allocInfo = { VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO };
|
||||
+ VkMemoryAllocateInfo allocInfo = {};
|
||||
+ allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||
allocInfo.memoryTypeIndex = memTypeIndex;
|
||||
allocInfo.allocationSize = size;
|
||||
|
||||
#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000
|
||||
- VkMemoryDedicatedAllocateInfoKHR dedicatedAllocInfo = { VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR };
|
||||
+ VkMemoryDedicatedAllocateInfoKHR dedicatedAllocInfo = {};
|
||||
+ dedicatedAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR;
|
||||
if(m_UseKhrDedicatedAllocation || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0))
|
||||
{
|
||||
if(dedicatedBuffer != VK_NULL_HANDLE)
|
||||
@@ -15195,12 +15214,15 @@ void VmaAllocator_T::GetBufferMemoryRequirements(
|
||||
#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000
|
||||
if(m_UseKhrDedicatedAllocation || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0))
|
||||
{
|
||||
- VkBufferMemoryRequirementsInfo2KHR memReqInfo = { VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR };
|
||||
+ VkBufferMemoryRequirementsInfo2KHR memReqInfo = {};
|
||||
+ memReqInfo.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR;
|
||||
memReqInfo.buffer = hBuffer;
|
||||
|
||||
- VkMemoryDedicatedRequirementsKHR memDedicatedReq = { VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR };
|
||||
+ VkMemoryDedicatedRequirementsKHR memDedicatedReq = {};
|
||||
+ memDedicatedReq.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR;
|
||||
|
||||
- VkMemoryRequirements2KHR memReq2 = { VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR };
|
||||
+ VkMemoryRequirements2KHR memReq2 = {};
|
||||
+ memReq2.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR;
|
||||
memReq2.pNext = &memDedicatedReq;
|
||||
|
||||
(*m_VulkanFunctions.vkGetBufferMemoryRequirements2KHR)(m_hDevice, &memReqInfo, &memReq2);
|
||||
@@ -15227,12 +15249,15 @@ void VmaAllocator_T::GetImageMemoryRequirements(
|
||||
#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000
|
||||
if(m_UseKhrDedicatedAllocation || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0))
|
||||
{
|
||||
- VkImageMemoryRequirementsInfo2KHR memReqInfo = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR };
|
||||
+ VkImageMemoryRequirementsInfo2KHR memReqInfo = {};
|
||||
+ memReqInfo.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR;
|
||||
memReqInfo.image = hImage;
|
||||
|
||||
- VkMemoryDedicatedRequirementsKHR memDedicatedReq = { VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR };
|
||||
+ VkMemoryDedicatedRequirementsKHR memDedicatedReq = {};
|
||||
+ memDedicatedReq.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR;
|
||||
|
||||
- VkMemoryRequirements2KHR memReq2 = { VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR };
|
||||
+ VkMemoryRequirements2KHR memReq2 = {};
|
||||
+ memReq2.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR;
|
||||
memReq2.pNext = &memDedicatedReq;
|
||||
|
||||
(*m_VulkanFunctions.vkGetImageMemoryRequirements2KHR)(m_hDevice, &memReqInfo, &memReq2);
|
||||
@@ -15461,13 +15486,13 @@ VkResult VmaAllocator_T::ResizeAllocation(
|
||||
// This function is deprecated and so it does nothing. It's left for backward compatibility.
|
||||
if(newSize == 0 || alloc->GetLastUseFrameIndex() == VMA_FRAME_INDEX_LOST)
|
||||
{
|
||||
- return VK_ERROR_VALIDATION_FAILED_EXT;
|
||||
+ return VkResult(-1000011001); // VK_ERROR_VALIDATION_FAILED_EXT
|
||||
}
|
||||
if(newSize == alloc->GetSize())
|
||||
{
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
- return VK_ERROR_OUT_OF_POOL_MEMORY;
|
||||
+ return VkResult(-1000069000); // VK_ERROR_OUT_OF_POOL_MEMORY
|
||||
}
|
||||
|
||||
void VmaAllocator_T::CalculateStats(VmaStats* pStats)
|
||||
@@ -15780,6 +15805,7 @@ void VmaAllocator_T::DestroyPool(VmaPool pool)
|
||||
{
|
||||
VmaMutexLockWrite lock(m_PoolsMutex, m_UseMutex);
|
||||
bool success = VmaVectorRemoveSorted<VmaPointerLess>(m_Pools, pool);
|
||||
+ (void) success;
|
||||
VMA_ASSERT(success && "Pool not found in Allocator.");
|
||||
}
|
||||
|
||||
@@ -16111,7 +16137,8 @@ void VmaAllocator_T::FlushOrInvalidateAllocation(
|
||||
|
||||
const VkDeviceSize nonCoherentAtomSize = m_PhysicalDeviceProperties.limits.nonCoherentAtomSize;
|
||||
|
||||
- VkMappedMemoryRange memRange = { VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE };
|
||||
+ VkMappedMemoryRange memRange = {};
|
||||
+ memRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
|
||||
memRange.memory = hAllocation->GetMemory();
|
||||
|
||||
switch(hAllocation->GetType())
|
||||
@@ -16184,6 +16211,7 @@ void VmaAllocator_T::FreeDedicatedMemory(const VmaAllocation allocation)
|
||||
AllocationVectorType* const pDedicatedAllocations = m_pDedicatedAllocations[memTypeIndex];
|
||||
VMA_ASSERT(pDedicatedAllocations);
|
||||
bool success = VmaVectorRemoveSorted<VmaPointerLess>(*pDedicatedAllocations, allocation);
|
||||
+ (void) success;
|
||||
VMA_ASSERT(success);
|
||||
}
|
||||
|
||||
--
|
||||
2.23.0.windows.1
|
||||
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
From e4cf9a73270f586ed15fcd899f3b8f7c0a3253b8 Mon Sep 17 00:00:00 2001
|
||||
From: Laszlo Agocs <laszlo.agocs@qt.io>
|
||||
Date: Thu, 14 Jan 2021 13:31:15 +0100
|
||||
Subject: [PATCH] More MingW 8.1 warning workarounds
|
||||
|
||||
Change-Id: Ib1df65672c312abce4489f5175d9a69af157c206
|
||||
---
|
||||
.../VulkanMemoryAllocator/vk_mem_alloc.h | 37 +++++++++++++------
|
||||
1 file changed, 25 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
index ebaeb4bcff..6b10e1eb94 100644
|
||||
--- a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
+++ b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
@@ -4086,6 +4086,8 @@ static void VmaWriteMagicValue(void* pData, VkDeviceSize offset)
|
||||
}
|
||||
#else
|
||||
// no-op
|
||||
+ (void) pData;
|
||||
+ (void) offset;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -4101,6 +4103,9 @@ static bool VmaValidateMagicValue(const void* pData, VkDeviceSize offset)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+#else
|
||||
+ (void) pData;
|
||||
+ (void) offset;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
@@ -4400,7 +4405,7 @@ public:
|
||||
|
||||
// This version of the constructor is here for compatibility with pre-C++14 std::vector.
|
||||
// value is unused.
|
||||
- VmaVector(size_t count, const T& value, const AllocatorT& allocator)
|
||||
+ VmaVector(size_t count, const T& /*value*/, const AllocatorT& allocator)
|
||||
: VmaVector(count, allocator) {}
|
||||
|
||||
VmaVector(const VmaVector<T, AllocatorT>& src) :
|
||||
@@ -6002,7 +6007,7 @@ private:
|
||||
VkDeviceSize allocAlignment,
|
||||
VmaSuballocationType allocType,
|
||||
bool canMakeOtherLost,
|
||||
- uint32_t strategy,
|
||||
+ uint32_t /*strategy*/,
|
||||
VmaAllocationRequest* pAllocationRequest);
|
||||
bool CreateAllocationRequest_UpperAddress(
|
||||
uint32_t currentFrameIndex,
|
||||
@@ -10098,14 +10103,14 @@ bool VmaBlockMetadata_Linear::CreateAllocationRequest(
|
||||
}
|
||||
|
||||
bool VmaBlockMetadata_Linear::CreateAllocationRequest_UpperAddress(
|
||||
- uint32_t currentFrameIndex,
|
||||
- uint32_t frameInUseCount,
|
||||
+ uint32_t /*currentFrameIndex*/,
|
||||
+ uint32_t /*frameInUseCount*/,
|
||||
VkDeviceSize bufferImageGranularity,
|
||||
VkDeviceSize allocSize,
|
||||
VkDeviceSize allocAlignment,
|
||||
VmaSuballocationType allocType,
|
||||
- bool canMakeOtherLost,
|
||||
- uint32_t strategy,
|
||||
+ bool /*canMakeOtherLost*/,
|
||||
+ uint32_t /*strategy*/,
|
||||
VmaAllocationRequest* pAllocationRequest)
|
||||
{
|
||||
const VkDeviceSize size = GetSize();
|
||||
@@ -10227,7 +10232,7 @@ bool VmaBlockMetadata_Linear::CreateAllocationRequest_LowerAddress(
|
||||
VkDeviceSize allocAlignment,
|
||||
VmaSuballocationType allocType,
|
||||
bool canMakeOtherLost,
|
||||
- uint32_t strategy,
|
||||
+ uint32_t /*strategy*/,
|
||||
VmaAllocationRequest* pAllocationRequest)
|
||||
{
|
||||
const VkDeviceSize size = GetSize();
|
||||
@@ -10678,6 +10683,7 @@ void VmaBlockMetadata_Linear::Alloc(
|
||||
// New allocation at the end of 2-part ring buffer, so before first allocation from 1st vector.
|
||||
VMA_ASSERT(!suballocations1st.empty() &&
|
||||
request.offset + allocSize <= suballocations1st[m_1stNullItemsBeginCount].offset);
|
||||
+ (void) suballocations1st;
|
||||
SuballocationVectorType& suballocations2nd = AccessSuballocations2nd();
|
||||
|
||||
switch(m_2ndVectorMode)
|
||||
@@ -11932,7 +11938,7 @@ VkResult VmaBlockVector::AllocatePage(
|
||||
const bool mapped = (createInfo.flags & VMA_ALLOCATION_CREATE_MAPPED_BIT) != 0;
|
||||
const bool isUserDataString = (createInfo.flags & VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT) != 0;
|
||||
|
||||
- const bool withinBudget = (createInfo.flags & VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT) != 0;
|
||||
+ //const bool withinBudget = (createInfo.flags & VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT) != 0;
|
||||
VkDeviceSize freeMemory;
|
||||
{
|
||||
const uint32_t heapIndex = m_hAllocator->MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex);
|
||||
@@ -15976,7 +15982,8 @@ VkResult VmaAllocator_T::BindVulkanBuffer(
|
||||
if((m_UseKhrBindMemory2 || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0)) &&
|
||||
m_VulkanFunctions.vkBindBufferMemory2KHR != VMA_NULL)
|
||||
{
|
||||
- VkBindBufferMemoryInfoKHR bindBufferMemoryInfo = { VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO_KHR };
|
||||
+ VkBindBufferMemoryInfoKHR bindBufferMemoryInfo = {};
|
||||
+ bindBufferMemoryInfo.sType = VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO_KHR;
|
||||
bindBufferMemoryInfo.pNext = pNext;
|
||||
bindBufferMemoryInfo.buffer = buffer;
|
||||
bindBufferMemoryInfo.memory = memory;
|
||||
@@ -16007,7 +16014,8 @@ VkResult VmaAllocator_T::BindVulkanImage(
|
||||
if((m_UseKhrBindMemory2 || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0)) &&
|
||||
m_VulkanFunctions.vkBindImageMemory2KHR != VMA_NULL)
|
||||
{
|
||||
- VkBindImageMemoryInfoKHR bindBufferMemoryInfo = { VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO_KHR };
|
||||
+ VkBindImageMemoryInfoKHR bindBufferMemoryInfo = {};
|
||||
+ bindBufferMemoryInfo.sType = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO_KHR;
|
||||
bindBufferMemoryInfo.pNext = pNext;
|
||||
bindBufferMemoryInfo.image = image;
|
||||
bindBufferMemoryInfo.memory = memory;
|
||||
@@ -16263,9 +16271,11 @@ void VmaAllocator_T::UpdateVulkanBudget()
|
||||
{
|
||||
VMA_ASSERT(m_UseExtMemoryBudget);
|
||||
|
||||
- VkPhysicalDeviceMemoryProperties2KHR memProps = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR };
|
||||
+ VkPhysicalDeviceMemoryProperties2KHR memProps = {};
|
||||
+ memProps.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR;
|
||||
|
||||
- VkPhysicalDeviceMemoryBudgetPropertiesEXT budgetProps = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT };
|
||||
+ VkPhysicalDeviceMemoryBudgetPropertiesEXT budgetProps = {};
|
||||
+ budgetProps.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT;
|
||||
memProps.pNext = &budgetProps;
|
||||
|
||||
GetVulkanFunctions().vkGetPhysicalDeviceMemoryProperties2KHR(m_PhysicalDevice, &memProps);
|
||||
@@ -16883,6 +16893,7 @@ VMA_CALL_PRE void VMA_CALL_POST vmaGetPoolName(
|
||||
const char** ppName)
|
||||
{
|
||||
VMA_ASSERT(allocator && pool);
|
||||
+ (void) allocator;
|
||||
|
||||
VMA_DEBUG_LOG("vmaGetPoolName");
|
||||
|
||||
@@ -16909,6 +16920,8 @@ VMA_CALL_PRE void VMA_CALL_POST vmaSetPoolName(
|
||||
{
|
||||
allocator->GetRecorder()->RecordSetPoolName(allocator->GetCurrentFrameIndex(), pool, pName);
|
||||
}
|
||||
+#else
|
||||
+ (void) allocator;
|
||||
#endif
|
||||
}
|
||||
|
||||
--
|
||||
2.23.0.windows.1
|
||||
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
From 60d151dfd9ffa2e133af50fde05c5eaae9186bee Mon Sep 17 00:00:00 2001
|
||||
From: Laszlo Agocs <laszlo.agocs@qt.io>
|
||||
Date: Mon, 18 Jan 2021 22:34:37 +0100
|
||||
Subject: [PATCH] Silence clang warning about unused member var
|
||||
|
||||
Change-Id: Id968fd2302e3ff7b4d1a20cd8dd1f4d789588511
|
||||
---
|
||||
src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
index 6b10e1eb94..4f3fe1c451 100644
|
||||
--- a/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
+++ b/src/3rdparty/VulkanMemoryAllocator/vk_mem_alloc.h
|
||||
@@ -6865,7 +6865,7 @@ public:
|
||||
private:
|
||||
const VmaAllocator m_hAllocator;
|
||||
const uint32_t m_CurrFrameIndex;
|
||||
- const uint32_t m_Flags;
|
||||
+ //const uint32_t m_Flags;
|
||||
VmaDefragmentationStats* const m_pStats;
|
||||
// Owner of these objects.
|
||||
VmaBlockVectorDefragmentationContext* m_DefaultPoolContexts[VK_MAX_MEMORY_TYPES];
|
||||
@@ -13782,11 +13782,11 @@ void VmaBlockVectorDefragmentationContext::Begin(bool overlappingMoveSupported)
|
||||
VmaDefragmentationContext_T::VmaDefragmentationContext_T(
|
||||
VmaAllocator hAllocator,
|
||||
uint32_t currFrameIndex,
|
||||
- uint32_t flags,
|
||||
+ uint32_t /*flags*/,
|
||||
VmaDefragmentationStats* pStats) :
|
||||
m_hAllocator(hAllocator),
|
||||
m_CurrFrameIndex(currFrameIndex),
|
||||
- m_Flags(flags),
|
||||
+ //m_Flags(flags),
|
||||
m_pStats(pStats),
|
||||
m_CustomPoolContexts(VmaStlAllocator<VmaBlockVectorDefragmentationContext*>(hAllocator->GetAllocationCallbacks()))
|
||||
{
|
||||
--
|
||||
2.24.2 (Apple Git-127)
|
||||
|
||||
|
|
@ -7,10 +7,10 @@
|
|||
"QtUsage": "Memory management for the Vulkan backend of QRhi.",
|
||||
|
||||
"Homepage": "https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator",
|
||||
"Version": "2.3.0",
|
||||
"Version": "3.0.1",
|
||||
"License": "MIT License",
|
||||
"LicenseId": "MIT",
|
||||
"LicenseFile": "LICENSE.txt",
|
||||
"Copyright": "Copyright (c) 2017-2019 Advanced Micro Devices, Inc. All rights reserved."
|
||||
"Copyright": "Copyright (c) 2017-2022 Advanced Micro Devices, Inc. All rights reserved."
|
||||
}
|
||||
]
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -5,6 +5,7 @@
|
|||
#include "qrhivulkanext_p.h"
|
||||
|
||||
#define VMA_IMPLEMENTATION
|
||||
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
|
||||
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
||||
#define VMA_RECORDING_ENABLED 0
|
||||
#define VMA_DEDICATED_ALLOCATION 0
|
||||
|
|
@ -199,84 +200,14 @@ inline Int aligned(Int v, Int byteAlign)
|
|||
|
||||
static QVulkanInstance *globalVulkanInstance;
|
||||
|
||||
static void VKAPI_PTR wrap_vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties)
|
||||
static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL wrap_vkGetInstanceProcAddr(VkInstance, const char *pName)
|
||||
{
|
||||
globalVulkanInstance->functions()->vkGetPhysicalDeviceProperties(physicalDevice, pProperties);
|
||||
return globalVulkanInstance->getInstanceProcAddr(pName);
|
||||
}
|
||||
|
||||
static void VKAPI_PTR wrap_vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties)
|
||||
static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL wrap_vkGetDeviceProcAddr(VkDevice device, const char *pName)
|
||||
{
|
||||
globalVulkanInstance->functions()->vkGetPhysicalDeviceMemoryProperties(physicalDevice, pMemoryProperties);
|
||||
}
|
||||
|
||||
static VkResult VKAPI_PTR wrap_vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo* pAllocateInfo, const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory)
|
||||
{
|
||||
return globalVulkanInstance->deviceFunctions(device)->vkAllocateMemory(device, pAllocateInfo, pAllocator, pMemory);
|
||||
}
|
||||
|
||||
void VKAPI_PTR wrap_vkFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks* pAllocator)
|
||||
{
|
||||
globalVulkanInstance->deviceFunctions(device)->vkFreeMemory(device, memory, pAllocator);
|
||||
}
|
||||
|
||||
VkResult VKAPI_PTR wrap_vkMapMemory(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData)
|
||||
{
|
||||
return globalVulkanInstance->deviceFunctions(device)->vkMapMemory(device, memory, offset, size, flags, ppData);
|
||||
}
|
||||
|
||||
void VKAPI_PTR wrap_vkUnmapMemory(VkDevice device, VkDeviceMemory memory)
|
||||
{
|
||||
globalVulkanInstance->deviceFunctions(device)->vkUnmapMemory(device, memory);
|
||||
}
|
||||
|
||||
VkResult VKAPI_PTR wrap_vkFlushMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges)
|
||||
{
|
||||
return globalVulkanInstance->deviceFunctions(device)->vkFlushMappedMemoryRanges(device, memoryRangeCount, pMemoryRanges);
|
||||
}
|
||||
|
||||
VkResult VKAPI_PTR wrap_vkInvalidateMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges)
|
||||
{
|
||||
return globalVulkanInstance->deviceFunctions(device)->vkInvalidateMappedMemoryRanges(device, memoryRangeCount, pMemoryRanges);
|
||||
}
|
||||
|
||||
VkResult VKAPI_PTR wrap_vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset)
|
||||
{
|
||||
return globalVulkanInstance->deviceFunctions(device)->vkBindBufferMemory(device, buffer, memory, memoryOffset);
|
||||
}
|
||||
|
||||
VkResult VKAPI_PTR wrap_vkBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset)
|
||||
{
|
||||
return globalVulkanInstance->deviceFunctions(device)->vkBindImageMemory(device, image, memory, memoryOffset);
|
||||
}
|
||||
|
||||
void VKAPI_PTR wrap_vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, VkMemoryRequirements* pMemoryRequirements)
|
||||
{
|
||||
globalVulkanInstance->deviceFunctions(device)->vkGetBufferMemoryRequirements(device, buffer, pMemoryRequirements);
|
||||
}
|
||||
|
||||
void VKAPI_PTR wrap_vkGetImageMemoryRequirements(VkDevice device, VkImage image, VkMemoryRequirements* pMemoryRequirements)
|
||||
{
|
||||
globalVulkanInstance->deviceFunctions(device)->vkGetImageMemoryRequirements(device, image, pMemoryRequirements);
|
||||
}
|
||||
|
||||
VkResult VKAPI_PTR wrap_vkCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBuffer* pBuffer)
|
||||
{
|
||||
return globalVulkanInstance->deviceFunctions(device)->vkCreateBuffer(device, pCreateInfo, pAllocator, pBuffer);
|
||||
}
|
||||
|
||||
void VKAPI_PTR wrap_vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* pAllocator)
|
||||
{
|
||||
globalVulkanInstance->deviceFunctions(device)->vkDestroyBuffer(device, buffer, pAllocator);
|
||||
}
|
||||
|
||||
VkResult VKAPI_PTR wrap_vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImage* pImage)
|
||||
{
|
||||
return globalVulkanInstance->deviceFunctions(device)->vkCreateImage(device, pCreateInfo, pAllocator, pImage);
|
||||
}
|
||||
|
||||
void VKAPI_PTR wrap_vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator)
|
||||
{
|
||||
globalVulkanInstance->deviceFunctions(device)->vkDestroyImage(device, image, pAllocator);
|
||||
return globalVulkanInstance->functions()->vkGetDeviceProcAddr(device, pName);
|
||||
}
|
||||
|
||||
static inline VmaAllocation toVmaAllocation(QVkAlloc a)
|
||||
|
|
@ -726,23 +657,9 @@ bool QRhiVulkan::create(QRhi::Flags flags)
|
|||
caps.nonFillPolygonMode = physDevFeatures.fillModeNonSolid;
|
||||
|
||||
if (!importedAllocator) {
|
||||
VmaVulkanFunctions afuncs;
|
||||
afuncs.vkGetPhysicalDeviceProperties = wrap_vkGetPhysicalDeviceProperties;
|
||||
afuncs.vkGetPhysicalDeviceMemoryProperties = wrap_vkGetPhysicalDeviceMemoryProperties;
|
||||
afuncs.vkAllocateMemory = wrap_vkAllocateMemory;
|
||||
afuncs.vkFreeMemory = wrap_vkFreeMemory;
|
||||
afuncs.vkMapMemory = wrap_vkMapMemory;
|
||||
afuncs.vkUnmapMemory = wrap_vkUnmapMemory;
|
||||
afuncs.vkFlushMappedMemoryRanges = wrap_vkFlushMappedMemoryRanges;
|
||||
afuncs.vkInvalidateMappedMemoryRanges = wrap_vkInvalidateMappedMemoryRanges;
|
||||
afuncs.vkBindBufferMemory = wrap_vkBindBufferMemory;
|
||||
afuncs.vkBindImageMemory = wrap_vkBindImageMemory;
|
||||
afuncs.vkGetBufferMemoryRequirements = wrap_vkGetBufferMemoryRequirements;
|
||||
afuncs.vkGetImageMemoryRequirements = wrap_vkGetImageMemoryRequirements;
|
||||
afuncs.vkCreateBuffer = wrap_vkCreateBuffer;
|
||||
afuncs.vkDestroyBuffer = wrap_vkDestroyBuffer;
|
||||
afuncs.vkCreateImage = wrap_vkCreateImage;
|
||||
afuncs.vkDestroyImage = wrap_vkDestroyImage;
|
||||
VmaVulkanFunctions funcs = {};
|
||||
funcs.vkGetInstanceProcAddr = wrap_vkGetInstanceProcAddr;
|
||||
funcs.vkGetDeviceProcAddr = wrap_vkGetDeviceProcAddr;
|
||||
|
||||
VmaAllocatorCreateInfo allocatorInfo = {};
|
||||
// A QRhi is supposed to be used from one single thread only. Disable
|
||||
|
|
@ -750,7 +667,14 @@ bool QRhiVulkan::create(QRhi::Flags flags)
|
|||
allocatorInfo.flags = VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT;
|
||||
allocatorInfo.physicalDevice = physDev;
|
||||
allocatorInfo.device = dev;
|
||||
allocatorInfo.pVulkanFunctions = &afuncs;
|
||||
allocatorInfo.pVulkanFunctions = &funcs;
|
||||
allocatorInfo.instance = inst->vkInstance();
|
||||
const QVersionNumber apiVer = inst->apiVersion();
|
||||
if (!apiVer.isNull()) {
|
||||
allocatorInfo.vulkanApiVersion = VK_MAKE_VERSION(apiVer.majorVersion(),
|
||||
apiVer.minorVersion(),
|
||||
apiVer.microVersion());
|
||||
}
|
||||
VmaAllocator vmaallocator;
|
||||
VkResult err = vmaCreateAllocator(&allocatorInfo, &vmaallocator);
|
||||
if (err != VK_SUCCESS) {
|
||||
|
|
@ -4388,15 +4312,15 @@ QRhiDriverInfo QRhiVulkan::driverInfo() const
|
|||
|
||||
QRhiStats QRhiVulkan::statistics()
|
||||
{
|
||||
VmaStats stats;
|
||||
vmaCalculateStats(toVmaAllocator(allocator), &stats);
|
||||
VmaTotalStatistics stats;
|
||||
vmaCalculateStatistics(toVmaAllocator(allocator), &stats);
|
||||
|
||||
QRhiStats result;
|
||||
result.totalPipelineCreationTime = totalPipelineCreationTime();
|
||||
result.blockCount = stats.total.blockCount;
|
||||
result.allocCount = stats.total.allocationCount;
|
||||
result.usedBytes = stats.total.usedBytes;
|
||||
result.unusedBytes = stats.total.unusedBytes;
|
||||
result.blockCount = stats.total.statistics.blockCount;
|
||||
result.allocCount = stats.total.statistics.allocationCount;
|
||||
result.usedBytes = stats.total.statistics.allocationBytes;
|
||||
result.unusedBytes = stats.total.statistics.blockBytes - stats.total.statistics.allocationBytes;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue