blob: b6f270a7d8cf5e2bbb8c3c3c6c438c5a8a58c34b (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#include <memory>
#include <vulkan/vulkan_core.h>
#include <vk_mem_alloc.h>
#include <cstdint>
#include <vector>
#include <string>
#define CHECK_VULKAN(result) \
do { \
VkResult res = result; \
if (res != VK_SUCCESS) { \
/* TODO: throw error instead of returning */ \
std::cerr << "Vulkan error: " << res << std::endl; \
abort(); \
} \
} while (0)
namespace iris {
struct Buffer_t {
VkBuffer buffer;
VmaAllocator allocator;
VmaAllocation allocation;
VkBufferUsageFlags flags;
VkDeviceSize size;
~Buffer_t();
};
typedef std::shared_ptr<Buffer_t> Buffer;
struct Texture2D_t {
VkImage image;
VmaAllocator allocator;
VmaAllocation allocation;
VkImageView image_view;
VkImageUsageFlags flags;
VkExtent2D extent;
~Texture2D_t();
};
typedef std::shared_ptr<Texture2D_t> Texture2D;
struct Device {
VkInstance instance;
VkPhysicalDevice physical_device;
VkDevice device;
uint32_t main_queue_family_index;
VkQueue graphics_queue;
VmaAllocator allocator;
Device(
std::vector<std::string> layers,
std::vector<std::string> instance_extensions);
~Device();
Buffer create_buffer(
VkDeviceSize size,
VkBufferUsageFlags usage,
VmaMemoryUsage memory_usage = VMA_MEMORY_USAGE_AUTO);
Texture2D create_texture(
VkExtent2D extent,
VkFormat format,
VkImageUsageFlags usage,
VmaMemoryUsage memory_usage = VMA_MEMORY_USAGE_AUTO);
};
} // namespace iris
|