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.
57 lines
1.4 KiB
57 lines
1.4 KiB
2 weeks ago
|
#pragma once
|
||
|
|
||
|
#include <vulkan/vulkan.h>
|
||
|
#include <GLFW/glfw3.h>
|
||
|
#include <optional>
|
||
|
#include <set>
|
||
|
|
||
|
class Instance {
|
||
|
public:
|
||
|
explicit Instance();
|
||
|
~Instance();
|
||
|
|
||
|
GLFWwindow *window = nullptr;
|
||
|
VkSurfaceKHR surface = VK_NULL_HANDLE;
|
||
|
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
|
||
|
VkDevice device = VK_NULL_HANDLE;
|
||
|
VkQueue graphicsQueue = VK_NULL_HANDLE;
|
||
|
VkQueue presentQueue = VK_NULL_HANDLE;
|
||
2 weeks ago
|
VkQueue computeQueue = VK_NULL_HANDLE;
|
||
2 weeks ago
|
|
||
|
struct QueueFamilyIndices {
|
||
|
std::optional<uint32_t> graphicsFamily;
|
||
|
std::optional<uint32_t> computeFamily;
|
||
|
std::optional<uint32_t> presentFamily;
|
||
2 weeks ago
|
std::optional<uint32_t> graphicsAndComputeFamily;
|
||
2 weeks ago
|
bool isComplete() const {
|
||
2 weeks ago
|
return graphicsFamily.has_value() &&
|
||
|
computeFamily.has_value() &&
|
||
|
presentFamily.has_value() &&
|
||
|
graphicsAndComputeFamily.has_value();
|
||
2 weeks ago
|
}
|
||
|
std::set<uint32_t> uniqueQueueFamilies(){
|
||
2 weeks ago
|
return {
|
||
|
graphicsFamily.value(),
|
||
|
presentFamily.value(),
|
||
|
computeFamily.value(),
|
||
|
graphicsAndComputeFamily.value()
|
||
|
};
|
||
2 weeks ago
|
}
|
||
|
};
|
||
|
static QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device, VkSurfaceKHR surface);
|
||
|
|
||
2 weeks ago
|
static Instance* instance;
|
||
2 weeks ago
|
private:
|
||
|
VkInstance handle = VK_NULL_HANDLE;
|
||
|
|
||
|
void initWindow();
|
||
|
void createInstance();
|
||
|
void createSurface();
|
||
|
void pickPhysicalDevice();
|
||
|
void createLogicalDevice();
|
||
|
|
||
|
bool isDeviceSuitable(VkPhysicalDevice physicalDevice);
|
||
|
|
||
|
static bool checkDeviceExtensionSupport(VkPhysicalDevice device);
|
||
|
|
||
|
};
|