-
Notifications
You must be signed in to change notification settings - Fork 1
/
Instance.h
97 lines (77 loc) · 2.23 KB
/
Instance.h
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef VKOCCLUSIONTEST_INSTANCE_H
#define VKOCCLUSIONTEST_INSTANCE_H
#include <vulkan/vulkan.hpp>
#include <SDL2/SDL.h>
#include <memory>
class Swapchain;
class Buffer;
class Instance {
private:
vk::Instance _instance;
vk::PhysicalDevice _physical_device;
vk::Device _device;
vk::Queue _graphics_queue;
vk::Queue _present_queue;
vk::Queue _compute_queue;
vk::CommandPool _graphics_command_pool;
vk::CommandPool _compute_command_pool;
vk::PhysicalDeviceMemoryProperties _memory_properties;
vk::DescriptorPool _descriptor_pool;
uint32_t _graphics_index;
uint32_t _present_index;
uint32_t _compute_index;
std::unique_ptr<Buffer> _transfer_buffer;
public:
Instance(SDL_Window* window);
~Instance();
void create_device(const Swapchain& swapchain);
void wait_idle() const;
std::vector<vk::DescriptorSet> create_descriptor_sets(const vk::ArrayProxy<vk::DescriptorSetLayout>& info);
static const std::unique_ptr<Buffer>& get_transfer_buffer(const std::shared_ptr<Instance>& instance, size_t size);
inline const vk::Instance& instance() const {
return _instance;
}
inline operator const vk::Instance&() const {
return _instance;
}
inline const vk::Device& device() const {
return _device;
}
inline operator const vk::Device&() const {
return _device;
}
inline const vk::PhysicalDevice& physical_device() const {
return _physical_device;
}
inline operator const vk::PhysicalDevice&() const {
return _physical_device;
}
inline const vk::Queue& graphics_queue() const {
return _graphics_queue;
}
inline const vk::Queue& present_queue() const {
return _present_queue;
}
inline const vk::Queue& compute_queue() const {
return _compute_queue;
}
inline uint32_t graphics_queue_index() const {
return _graphics_index;
}
inline uint32_t present_queue_index() const {
return _present_index;
}
inline uint32_t compute_queue_index() const {
return _compute_index;
}
inline const vk::CommandPool& graphics_command_pool() const {
return _graphics_command_pool;
}
inline const vk::CommandPool& compute_command_pool() const {
return _compute_command_pool;
}
inline const vk::PhysicalDeviceMemoryProperties& memory_properties() const {
return _memory_properties;
}
};
#endif //VKOCCLUSIONTEST_INSTANCE_H