summaryrefslogtreecommitdiff
path: root/include/resources/buffer.h
blob: 7c6fe0e4d31d879212dc895f2b737eb39a330730 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once 

#include <cstdint>
#include <memory>
#include <optional>
#include <vk_mem_alloc.h>
#include <vulkan/vulkan_core.h>
namespace iris {

struct BufferDesc {
    uint64_t size;
    std::optional<uint64_t> alignment;
    VkBufferUsageFlags buffer_usage;
    VmaMemoryUsage memory_usage;
};

struct Buffer_tt {
    VkBuffer handle;
    BufferDesc desc;

    // Used during release
    VkDevice device;
    VmaAllocator allocator;
    VmaAllocation allocation;
    void release();

    // Used during map/unmap
    std::optional<void *> mapped_data;
    void *map();
    void unmap();
    
    ~Buffer_tt() { release(); }
};

typedef std::shared_ptr<Buffer_tt> Buffer_s;

} // namespace iris