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.
 
 
 
 

75 lines
1.8 KiB

#pragma once
#include <algorithm>
#include <vulkan/vulkan.h>
#include <GLFW/glfw3.h>
#include <optional>
#include <set>
#include <vector>
#include "vk_mem_alloc.h"
#include "imgui.h"
#include "imgui/backends/imgui_impl_vulkan.h"
#include "imgui/backends/imgui_impl_glfw.h"
using std::optional, std::vector;
class CommandPool;
class Swapchain;
void printVmaStats();
class Instance {
public:
explicit Instance();
~Instance();
GLFWwindow *window = nullptr;
VkQueue graphicsAndPresentQueue = VK_NULL_HANDLE;
VkQueue computeAndTransferQueue = VK_NULL_HANDLE;
bool windowResized = false;
CommandPool *renderingCommandPool = nullptr;
CommandPool *computeCommandPool = nullptr;
struct QueueFamilyIndices {
vector<uint32_t> graphicsAndPresent;
vector<uint32_t> computeAndTransfer;
std::set<uint32_t> uniqueQueueFamilies();
uint32_t tryComputeAndTransferDedicated();
bool isEnough();
};
QueueFamilyIndices indices {};
static Instance *instance;
static VkDevice GetDevice();
static VkPhysicalDevice GetPhysicalDevice();
static VmaAllocator GetAllocator();
static VkSurfaceKHR GetSurface();
void initImGui(const Swapchain &swapchain);
private:
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
VkDevice device = VK_NULL_HANDLE;
VkSurfaceKHR surface = VK_NULL_HANDLE;
VmaAllocator allocator = VK_NULL_HANDLE;
VkDescriptorPool imGuiDescriptorPool = VK_NULL_HANDLE;
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);
static QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device, VkSurfaceKHR surface);
};