Renderers: Fix UploadPool

This commit is contained in:
Jérôme Leclercq 2021-01-28 15:59:18 +01:00
parent 41c921bcf6
commit 5eedd3c0bc
3 changed files with 6 additions and 2 deletions

View File

@ -44,7 +44,7 @@ namespace Nz
{ {
Vk::DeviceMemory blockMemory; Vk::DeviceMemory blockMemory;
Vk::Buffer buffer; Vk::Buffer buffer;
UInt64 freeOffset; UInt64 freeOffset = 0;
}; };
UInt64 m_blockSize; UInt64 m_blockSize;

View File

@ -52,6 +52,8 @@ namespace Nz
allocationData.mappedPtr = static_cast<UInt8*>(bestBlock.block->memory.data()) + bestBlock.offset; allocationData.mappedPtr = static_cast<UInt8*>(bestBlock.block->memory.data()) + bestBlock.offset;
allocationData.size = size; allocationData.size = size;
bestBlock.block->freeOffset += size;
return allocationData; return allocationData;
} }

View File

@ -50,7 +50,7 @@ namespace Nz
{ {
Block newBlock; Block newBlock;
if (!newBlock.buffer.Create(m_device, 0U, m_blockSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT)) if (!newBlock.buffer.Create(m_device, 0U, m_blockSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT))
throw std::runtime_error("Failed to create block buffer: " + TranslateVulkanError(newBlock.buffer.GetLastErrorCode())); throw std::runtime_error("failed to create block buffer: " + TranslateVulkanError(newBlock.buffer.GetLastErrorCode()));
VkMemoryRequirements requirement = newBlock.buffer.GetMemoryRequirements(); VkMemoryRequirements requirement = newBlock.buffer.GetMemoryRequirements();
@ -74,6 +74,8 @@ namespace Nz
allocationData.offset = bestBlock.alignedOffset; allocationData.offset = bestBlock.alignedOffset;
allocationData.size = size; allocationData.size = size;
bestBlock.block->freeOffset += size;
return allocationData; return allocationData;
} }