VulkanEngine 0.1
Graphics engine using Vulkan
Loading...
Searching...
No Matches
Device.h
1// Copyright (c) 2024 Michael Carlie. All Rights Reserved.
2//
3// This software is released under the MIT License.
4// https://opensource.org/licenses/MIT
5
6#ifndef INCLUDE_VULKANENGINE_DEVICE_H_
7#define INCLUDE_VULKANENGINE_DEVICE_H_
8
9#include <vector>
10#include <vulkan/vulkan.hpp>
11
12// Support latest vk_mem_alloc with older Vulkan SDK headers.
13#ifndef VK_API_VERSION_MAJOR
14#define VK_API_VERSION_MAJOR(version) VK_VERSION_MAJOR(version)
15#endif
16
17#ifndef VK_API_VERSION_MINOR
18#define VK_API_VERSION_MINOR(version) VK_VERSION_MINOR(version)
19#endif
20
21#ifndef VK_API_VERSION_PATCH
22#define VK_API_VERSION_PATCH(version) VK_VERSION_PATCH(version)
23#endif
24#include <vk_mem_alloc.h>
25
26namespace VulkanEngine {
27
30class Device {
31 public:
33 Device();
34
36 ~Device();
37
38 const vk::Device& getVkDevice() const;
39
40 void destroyCommandBuffers();
41
42 void waitIdle();
43
44 vk::CommandBuffer getCommandBuffer(size_t index);
45
46 const VmaAllocator& getVmaAllocator();
47
48 vk::CommandPool getVkCommandPool();
49
50 vk::Queue getVkGraphicsQueue();
51
52 void beginSingleUsageCommandBuffer();
53
54 void endSingleUsageCommandBuffer();
55
56 private:
57 int graphics_queue_family_index;
58 vk::Device vk_device;
59 VmaAllocator vma_allocator;
60 vk::Queue vk_graphics_queue;
61 vk::CommandPool vk_command_pool;
62 std::vector<vk::CommandBuffer> vk_command_buffers;
63 vk::CommandBuffer single_use_command_buffer;
64 VULKAN_HPP_DEFAULT_DISPATCHER_TYPE vk_dispatch_loader_dynamic;
65
66#ifdef ENABLE_VULKAN_VALIDATION
67 vk::DebugUtilsMessengerEXT vk_debug_utils_messenger;
68
69 static VKAPI_ATTR VkBool32 VKAPI_CALL
70 debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT message_severity,
71 VkDebugUtilsMessageTypeFlagsEXT message_type,
72 const VkDebugUtilsMessengerCallbackDataEXT* callback_data,
73 void* user_data);
74#endif
75};
76
77} // namespace VulkanEngine
78
79#endif // INCLUDE_VULKANENGINE_DEVICE_H_
Definition: Device.h:30
Device()
Constructor.
Definition: Device.cpp:28
~Device()
Destructor.
Definition: Device.cpp:156
TODO development of this class is in progress.
Definition: Attribute.h:13