You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.6 KiB
66 lines
1.6 KiB
#pragma once
|
|
|
|
#include <vulkan/vulkan.h>
|
|
#include <GLFW/glfw3.h>
|
|
#include <optional>
|
|
#include <set>
|
|
#include "vk_mem_alloc.h"
|
|
|
|
class CommandPool;
|
|
|
|
class Instance {
|
|
public:
|
|
explicit Instance();
|
|
~Instance();
|
|
|
|
GLFWwindow *window = nullptr;
|
|
VkSurfaceKHR surface = VK_NULL_HANDLE;
|
|
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
|
|
VkDevice device = VK_NULL_HANDLE;
|
|
VmaAllocator allocator = VK_NULL_HANDLE;
|
|
VkQueue graphicsQueue = VK_NULL_HANDLE;
|
|
VkQueue presentQueue = VK_NULL_HANDLE;
|
|
VkQueue computeQueue = VK_NULL_HANDLE;
|
|
|
|
bool windowResized = false;
|
|
|
|
CommandPool* commandPool = nullptr;
|
|
|
|
struct QueueFamilyIndices {
|
|
std::optional<uint32_t> graphicsFamily;
|
|
std::optional<uint32_t> computeFamily;
|
|
std::optional<uint32_t> presentFamily;
|
|
std::optional<uint32_t> graphicsAndComputeFamily;
|
|
bool isComplete() const {
|
|
return graphicsFamily.has_value() &&
|
|
computeFamily.has_value() &&
|
|
presentFamily.has_value() &&
|
|
graphicsAndComputeFamily.has_value();
|
|
}
|
|
std::set<uint32_t> uniqueQueueFamilies(){
|
|
return {
|
|
graphicsFamily.value(),
|
|
presentFamily.value(),
|
|
computeFamily.value(),
|
|
graphicsAndComputeFamily.value()
|
|
};
|
|
}
|
|
};
|
|
static QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device, VkSurfaceKHR surface);
|
|
|
|
static Instance* instance;
|
|
private:
|
|
VkInstance handle = VK_NULL_HANDLE;
|
|
|
|
void initWindow();
|
|
void createInstance();
|
|
void createSurface();
|
|
void pickPhysicalDevice();
|
|
void createLogicalDevice();
|
|
void createAllocator();
|
|
|
|
bool isDeviceSuitable(VkPhysicalDevice potentialPhysicalDevice);
|
|
|
|
static bool checkDeviceExtensionSupport(VkPhysicalDevice device);
|
|
|
|
}; |