Skip to content

Commit

Permalink
VulkanPushPool: Sprinkle a couple of asserts.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed May 4, 2023
1 parent 4e732af commit 7e1f907
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Common/GPU/Vulkan/VulkanMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ VulkanPushPool::Block VulkanPushPool::CreateBlock(size_t size) {
result = vmaMapMemory(vulkan_->Allocator(), block.allocation, (void **)(&block.writePtr));
_assert_(result == VK_SUCCESS);

_assert_msg_(block.writePtr != nullptr, "VulkanPushPool: Failed to map memory on block of size %d", (int)block.size);
return block;
}

Expand Down Expand Up @@ -384,13 +385,15 @@ void VulkanPushPool::NextBlock(VkDeviceSize allocationSize) {
block.used = allocationSize;
block.lastUsed = time_now_d();
block.frameIndex = curFrameIndex;
_assert_(block.writePtr != nullptr);
return;
}
curBlockIndex_++;
}

double start = time_now_d();
VkDeviceSize newBlockSize = std::max(originalBlockSize_ * 2, (VkDeviceSize)RoundUpToPowerOf2((uint32_t)allocationSize));

// We're still here and ran off the end of blocks. Create a new one.
blocks_.push_back(CreateBlock(newBlockSize));
blocks_.back().frameIndex = curFrameIndex;
Expand Down
1 change: 1 addition & 0 deletions Common/GPU/Vulkan/VulkanMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class VulkanPushBuffer : public VulkanMemoryManager {

// Simple memory pushbuffer pool that can share blocks between the "frames", to reduce the impact of push memory spikes -
// a later frame can gobble up redundant buffers from an earlier frame even if they don't share frame index.
// NOT thread safe! Can only be used from one thread (our main thread).
class VulkanPushPool : public VulkanMemoryManager {
public:
VulkanPushPool(VulkanContext *vulkan, const char *name, size_t originalBlockSize, VkBufferUsageFlags usage);
Expand Down

0 comments on commit 7e1f907

Please sign in to comment.