umbra/projs/shadow/shadow-engine/shadow-renderer/inc/vlkx/vulkan/VulkanDevice.h
Curle a3e89b4e8f
Replace the renderer with a modern, module version. (#7)
* New Vulkan Renderer Module & Associated Fixups
2022-11-26 16:44:16 +00:00

57 lines
1.3 KiB
C++

#pragma once
#include <vulkan/vulkan.h>
#include <stdexcept>
#include <iostream>
#include <vector>
#include <set>
#include <vlkx/vulkan/ValidationAndExtension.h>
struct SwapChainMeta {
VkSurfaceCapabilitiesKHR capabilities;
std::vector<VkSurfaceFormatKHR> formats;
std::vector<VkPresentModeKHR> modes;
};
struct QueueFamilies {
int graphics = -1;
int presentation = -1;
bool present() {
return graphics >= 0 && presentation >= 0;
}
};
class VulkanDevice {
public:
VulkanDevice();
~VulkanDevice();
/** Physical Devices **/
VkPhysicalDevice physical;
VkPhysicalDeviceLimits limits;
SwapChainMeta swapChain;
QueueFamilies queueData;
std::vector<const char*> deviceExtensions = {
VK_KHR_SWAPCHAIN_EXTENSION_NAME
};
void choosePhysicalDevice(VkInstance* vulkan, VkSurfaceKHR surface);
bool isSuitable(VkPhysicalDevice device, VkSurfaceKHR surface);
bool isSupported(VkPhysicalDevice device);
SwapChainMeta checkSwapchain(VkPhysicalDevice device, VkSurfaceKHR surface);
QueueFamilies checkQueues(VkPhysicalDevice device, VkSurfaceKHR surface);
QueueFamilies getQueues() { return queueData; }
/** Logical Devices **/
VkDevice logical;
VkQueue graphicsQueue;
VkQueue presentationQueue;
void createLogicalDevice(VkSurfaceKHR surface, bool validationRequired, ValidationAndExtension* validators);
void destroy();
};