Reached shader lessons. Stopping to refactor code.
This commit is contained in:
@@ -1,22 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
#define GLFW_INCLUDE_VULKAN
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
// struct FCreateDebugUtilsMessengerExtParams
|
||||
//{
|
||||
// VkInstance Instance;
|
||||
// const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo;
|
||||
// const VkAllocationCallbacks* pAllocator;
|
||||
// VkDebugUtilsMessengerEXT* pDebugMessenger;
|
||||
// };
|
||||
//
|
||||
// struct FDestroyDebugUtilsMessengerExtParams
|
||||
//{
|
||||
// VkInstance Instance;
|
||||
// VkDebugUtilsMessengerEXT DebugMessenger;
|
||||
// const VkAllocationCallbacks* pAllocator;
|
||||
// };
|
||||
const std::vector<const char*> DeviceExtensions = {
|
||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME
|
||||
};
|
||||
|
||||
struct QueueFamilyIndices
|
||||
{
|
||||
std::optional<uint32_t> GraphicsFamily;
|
||||
std::optional<uint32_t> PresentFamily;
|
||||
|
||||
bool IsComplete()
|
||||
{
|
||||
return GraphicsFamily.has_value() && PresentFamily.has_value();
|
||||
}
|
||||
};
|
||||
|
||||
struct SwapChainSupportDetails
|
||||
{
|
||||
VkSurfaceCapabilitiesKHR Capabilities;
|
||||
std::vector<VkSurfaceFormatKHR> Formats;
|
||||
std::vector<VkPresentModeKHR> PresentModes;
|
||||
};
|
||||
|
||||
class VulkanDeviceManager
|
||||
{
|
||||
@@ -30,18 +43,59 @@ public:
|
||||
VulkanDeviceManager(VulkanDeviceManager&& Other) noexcept;
|
||||
VulkanDeviceManager& operator=(VulkanDeviceManager&& Other) noexcept;
|
||||
|
||||
void Initialize(VkInstance Instance);
|
||||
void Initialize(
|
||||
VkInstance Instance,
|
||||
bool EnableValidationLayers,
|
||||
const std::vector<const char*>& ValidationLayers);
|
||||
|
||||
void Cleanup();
|
||||
|
||||
bool IsInitialized() const { return PhysicalDevice != VK_NULL_HANDLE; }
|
||||
bool IsInitialized() const
|
||||
{
|
||||
bool bInitialized = PhysicalDevice && Device && Instance && GraphicsQueue;
|
||||
return bInitialized;
|
||||
}
|
||||
|
||||
static std::vector<VkImage> SwapChainImages;
|
||||
|
||||
private:
|
||||
VkPhysicalDevice PhysicalDevice = VK_NULL_HANDLE;
|
||||
VkInstance Instance = VK_NULL_HANDLE;
|
||||
VkDevice Device = VK_NULL_HANDLE;
|
||||
VkQueue GraphicsQueue = VK_NULL_HANDLE;
|
||||
VkQueue PresentQueue = VK_NULL_HANDLE;
|
||||
|
||||
VkSwapchainKHR SwapChain = VK_NULL_HANDLE;
|
||||
VkFormat SwapChainImageFormat;
|
||||
VkExtent2D SwapChainExtent;
|
||||
|
||||
std::vector<VkImageView> SwapChainImageViews;
|
||||
|
||||
bool bEnableValidationLayers = false;
|
||||
|
||||
const std::vector<const char*>* ValidationLayers = nullptr;
|
||||
|
||||
void PickPhysicalDevice();
|
||||
|
||||
// bool IsDeviceSuitable(VkPhysicalDevice Device);
|
||||
bool IsDeviceSuitable(VkPhysicalDevice Device);
|
||||
|
||||
int RateDeviceSuitability(VkPhysicalDevice Device);
|
||||
|
||||
bool CheckDeviceExtensionSupport(VkPhysicalDevice Device);
|
||||
|
||||
QueueFamilyIndices FindQueueFamilies(VkPhysicalDevice Device);
|
||||
|
||||
void CreateLogicalDevice();
|
||||
|
||||
SwapChainSupportDetails QuerySwapChainSupport(VkPhysicalDevice Device);
|
||||
|
||||
VkSurfaceFormatKHR ChooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& AvailableFormats);
|
||||
|
||||
VkPresentModeKHR ChooseSwapPresentMode(const std::vector<VkPresentModeKHR>& AvailablePresentModes);
|
||||
|
||||
VkExtent2D ChooseSwapExtent(const VkSurfaceCapabilitiesKHR& Capabilities);
|
||||
|
||||
void CreateSwapChain();
|
||||
|
||||
void CreateImageViews();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user