summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-11-30 16:57:13 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-11-30 16:57:13 +0000
commitef396c82756864a0834a391e28a822b20cc7b019 (patch)
tree9b64d68f653c489a947c6060717a638cc7e1d8c8 /Graphics/GraphicsEngineVulkan
parentVulkan backend: fixed 32-bit build (diff)
downloadDiligentCore-ef396c82756864a0834a391e28a822b20cc7b019.tar.gz
DiligentCore-ef396c82756864a0834a391e28a822b20cc7b019.zip
Fixed some 32-bit compilation warnings
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUploadHeap.h22
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanMemoryManager.h2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUploadHeap.cpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanMemoryManager.cpp15
4 files changed, 26 insertions, 15 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUploadHeap.h b/Graphics/GraphicsEngineVulkan/include/VulkanUploadHeap.h
index f544dd1f..dce3a711 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUploadHeap.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUploadHeap.h
@@ -96,7 +96,7 @@ public:
~VulkanUploadHeap();
- VulkanUploadAllocation Allocate(size_t SizeInBytes, size_t Alignment);
+ VulkanUploadAllocation Allocate(VkDeviceSize SizeInBytes, VkDeviceSize Alignment);
// Releases all allocated pages that are later returned to the global memory manager by the release queues.
// As global memory manager is hosted by the render device, the upload heap can be destroyed before the
@@ -134,12 +134,12 @@ private:
struct CurrPageInfo
{
- VkBuffer vkBuffer = VK_NULL_HANDLE;
- Uint8* CurrCPUAddress = nullptr;
- size_t CurrOffset = 0;
- size_t AvailableSize = 0;
+ VkBuffer vkBuffer = VK_NULL_HANDLE;
+ Uint8* CurrCPUAddress = nullptr;
+ VkDeviceSize CurrOffset = 0;
+ VkDeviceSize AvailableSize = 0;
- void Reset(UploadPageInfo& NewPage, size_t PageSize)
+ void Reset(UploadPageInfo& NewPage, VkDeviceSize PageSize)
{
vkBuffer = NewPage.Buffer;
CurrCPUAddress = NewPage.CPUAddress;
@@ -147,7 +147,7 @@ private:
AvailableSize = PageSize;
}
- void Advance(size_t SizeInBytes)
+ void Advance(VkDeviceSize SizeInBytes)
{
CurrCPUAddress += SizeInBytes;
CurrOffset += SizeInBytes;
@@ -155,10 +155,10 @@ private:
}
} m_CurrPage;
- size_t m_CurrFrameSize = 0;
- size_t m_PeakFrameSize = 0;
- size_t m_CurrAllocatedSize = 0;
- size_t m_PeakAllocatedSize = 0;
+ VkDeviceSize m_CurrFrameSize = 0;
+ VkDeviceSize m_PeakFrameSize = 0;
+ VkDeviceSize m_CurrAllocatedSize = 0;
+ VkDeviceSize m_PeakAllocatedSize = 0;
UploadPageInfo CreateNewPage(VkDeviceSize SizeInBytes) const;
};
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanMemoryManager.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanMemoryManager.h
index b736c5ad..f1aaf139 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanMemoryManager.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanMemoryManager.h
@@ -124,6 +124,8 @@ public:
void* GetCPUMemory() const { return m_CPUMemory; }
private:
+ using AllocationsMgrOffsetType = Diligent::VariableSizeAllocationsManager::OffsetType;
+
friend struct VulkanMemoryAllocation;
// Memory is reclaimed immediately. The application is responsible to ensure it is not in use by the GPU
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUploadHeap.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUploadHeap.cpp
index 0316ec05..c693905d 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUploadHeap.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUploadHeap.cpp
@@ -86,7 +86,7 @@ VulkanUploadHeap::UploadPageInfo VulkanUploadHeap::CreateNewPage(VkDeviceSize Si
return UploadPageInfo{std::move(MemAllocation), std::move(NewBuffer), CPUAddress};
}
-VulkanUploadAllocation VulkanUploadHeap::Allocate(size_t SizeInBytes, size_t Alignment)
+VulkanUploadAllocation VulkanUploadHeap::Allocate(VkDeviceSize SizeInBytes, VkDeviceSize Alignment)
{
VERIFY(IsPowerOfTwo(Alignment), "Alignment (", Alignment, ") must be power of two");
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanMemoryManager.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanMemoryManager.cpp
index cc36ed99..94e8e10c 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanMemoryManager.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanMemoryManager.cpp
@@ -42,9 +42,13 @@ VulkanMemoryPage::VulkanMemoryPage(VulkanMemoryManager& ParentMemoryMgr,
bool IsHostVisible) noexcept :
// clang-format off
m_ParentMemoryMgr{ParentMemoryMgr},
- m_AllocationMgr {PageSize, ParentMemoryMgr.m_Allocator}
+ m_AllocationMgr {static_cast<AllocationsMgrOffsetType>(PageSize), ParentMemoryMgr.m_Allocator}
// clang-format on
{
+ VERIFY(PageSize <= std::numeric_limits<AllocationsMgrOffsetType>::max(),
+ "PageSize (", PageSize, ") exceeds maximum allowed value ",
+ std::numeric_limits<AllocationsMgrOffsetType>::max());
+
VkMemoryAllocateInfo MemAlloc = {};
MemAlloc.pNext = nullptr;
@@ -81,7 +85,10 @@ VulkanMemoryPage::~VulkanMemoryPage()
VulkanMemoryAllocation VulkanMemoryPage::Allocate(VkDeviceSize size, VkDeviceSize alignment)
{
std::lock_guard<std::mutex> Lock{m_Mutex};
- auto Allocation = m_AllocationMgr.Allocate(size, alignment);
+ VERIFY(size <= std::numeric_limits<AllocationsMgrOffsetType>::max(),
+ "Allocation size (", size, ") exceeds maximum allowed value ",
+ std::numeric_limits<AllocationsMgrOffsetType>::max());
+ auto Allocation = m_AllocationMgr.Allocate(static_cast<AllocationsMgrOffsetType>(size), static_cast<AllocationsMgrOffsetType>(alignment));
if (Allocation.IsValid())
{
// Offset may not necessarily be aligned, but the allocation is guaranteed to be large enough
@@ -99,7 +106,9 @@ void VulkanMemoryPage::Free(VulkanMemoryAllocation&& Allocation)
{
m_ParentMemoryMgr.OnFreeAllocation(Allocation.Size, m_CPUMemory != nullptr);
std::lock_guard<std::mutex> Lock{m_Mutex};
- m_AllocationMgr.Free(Allocation.UnalignedOffset, Allocation.Size);
+ VERIFY_EXPR(Allocation.UnalignedOffset <= std::numeric_limits<AllocationsMgrOffsetType>::max());
+ VERIFY_EXPR(Allocation.Size <= std::numeric_limits<AllocationsMgrOffsetType>::max());
+ m_AllocationMgr.Free(static_cast<AllocationsMgrOffsetType>(Allocation.UnalignedOffset), static_cast<AllocationsMgrOffsetType>(Allocation.Size));
Allocation = VulkanMemoryAllocation{};
}