Skip to content

Commit aa612e0

Browse files
committed
(SSBO) Implemented support for SSBO.
1 parent 3582ce7 commit aa612e0

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

Core/inc/EvoVulkan/Memory/Allocator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ namespace EvoVulkan::Memory {
5757

5858
public:
5959
Buffer AllocBuffer(const VkBufferCreateInfo& info, VmaMemoryUsage usage);
60+
Buffer AllocBuffer(const VkBufferCreateInfo& info, VmaMemoryUsage usage, VmaAllocationCreateFlags flags);
6061
Types::Image AllocImage(const VkImageCreateInfo& info, bool CPUUsage);
6162
RawMemory AllocateMemory(VkMemoryAllocateInfo memoryAllocateInfo);
6263

Core/inc/EvoVulkan/Types/VmaBuffer.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define EVOVULKAN_VMABUFFER_H
77

88
#include <EvoVulkan/Tools/NonCopyable.h>
9+
#include <EvoVulkan/Memory/Allocator.h>
910

1011
namespace EvoVulkan::Memory {
1112
class Allocator;
@@ -31,6 +32,16 @@ namespace EvoVulkan::Types {
3132
VkDeviceSize size,
3233
void* data = nullptr);
3334

35+
static VmaBuffer* Create(
36+
Memory::Allocator* allocator,
37+
VkBufferUsageFlags bufferUsage,
38+
VmaMemoryUsage memoryUsage,
39+
VkDeviceSize size,
40+
VkSharingMode sharingMode,
41+
VkBufferCreateFlags createFlags,
42+
VmaAllocationCreateFlags allocateFlags,
43+
void* data = nullptr);
44+
3445
static VmaBuffer* Create(
3546
Memory::Allocator* allocator,
3647
VkDeviceSize size,

Core/src/EvoVulkan/Memory/Allocator.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,14 @@ uint64_t EvoVulkan::Memory::Allocator::GetCPUMemoryUsage() const {
146146
}
147147

148148
EvoVulkan::Memory::Buffer EvoVulkan::Memory::Allocator::AllocBuffer(const VkBufferCreateInfo &info, VmaMemoryUsage usage) {
149+
return AllocBuffer(info, usage, static_cast<VmaAllocationCreateFlags>(0));
150+
}
151+
152+
EvoVulkan::Memory::Buffer EvoVulkan::Memory::Allocator::AllocBuffer(const VkBufferCreateInfo &info, VmaMemoryUsage usage, VmaAllocationCreateFlags flags) {
149153
EvoVulkan::Memory::Buffer buffer = {};
150154

151155
VmaAllocationCreateInfo allocInfo;
152-
allocInfo.flags = 0;
156+
allocInfo.flags = flags;
153157
allocInfo.usage = usage;
154158
allocInfo.requiredFlags = 0;
155159
allocInfo.preferredFlags = 0;

Core/src/EvoVulkan/Types/VmaBuffer.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,33 @@ namespace EvoVulkan::Types {
3131
return buffer;
3232
}
3333

34+
VmaBuffer* VmaBuffer::Create(
35+
Memory::Allocator* allocator,
36+
VkBufferUsageFlags bufferUsage,
37+
VmaMemoryUsage memoryUsage,
38+
VkDeviceSize size,
39+
VkSharingMode sharingMode,
40+
VkBufferCreateFlags createFlags,
41+
VmaAllocationCreateFlags allocateFlags,
42+
void* data)
43+
{
44+
auto&& buffer = new VmaBuffer(allocator, size);
45+
46+
auto&& bufferCreateInfo = Tools::Initializers::BufferCreateInfo(bufferUsage, size);
47+
bufferCreateInfo.sharingMode = sharingMode;
48+
bufferCreateInfo.flags = createFlags;
49+
50+
buffer->m_buffer = allocator->AllocBuffer(bufferCreateInfo, memoryUsage, allocateFlags);
51+
52+
if (data) {
53+
buffer->CopyToDevice(data, memoryUsage == VMA_MEMORY_USAGE_CPU_ONLY);
54+
}
55+
56+
buffer->SetupDescriptor();
57+
58+
return buffer;
59+
}
60+
3461
VmaBuffer* VmaBuffer::Create(EvoVulkan::Memory::Allocator* allocator, VkDeviceSize size, void* data) {
3562
return Create(allocator, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VMA_MEMORY_USAGE_CPU_ONLY, size, data);
3663
}

0 commit comments

Comments
 (0)