Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions etna/source/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Buffer::Buffer(VmaAllocator alloc, CreateInfo info)
.sharingMode = vk::SharingMode::eExclusive,
};

VmaAllocationCreateInfo allocInfo{
VmaAllocationCreateInfo allocCreateInfo{
.flags = info.allocationCreate,
.usage = info.memoryUsage,
.requiredFlags = 0,
Expand All @@ -27,21 +27,28 @@ Buffer::Buffer(VmaAllocator alloc, CreateInfo info)
.priority = 0.f,
};

VmaAllocationInfo allocInfo;

VkBuffer buf;
auto retcode = vmaCreateBuffer(
allocator,
&static_cast<const VkBufferCreateInfo&>(bufInfo),
&allocInfo,
&allocCreateInfo,
&buf,
&allocation,
nullptr);
&allocInfo);
// Note that usually vulkan.hpp handles doing the assertion
// and a pretty message, but VMA cannot do that.
ETNA_VERIFYF(
retcode == VK_SUCCESS,
"Error {} occurred while trying to allocate an etna::Buffer!",
vk::to_string(static_cast<vk::Result>(retcode)));
buffer = vk::Buffer(buf);

// make map() optional if allocationCreate has VMA_ALLOCATION_CREATE_MAPPED_BIT
mapped = reinterpret_cast<std::byte*>(allocInfo.pMappedData);
ETNA_VERIFY(mapped == nullptr || info.allocationCreate & VMA_ALLOCATION_CREATE_MAPPED_BIT);

etna::set_debug_name(buffer, info.name.data());
}

Expand Down