diff --git a/src/rendering/vulkan/system/vk_device.h b/src/rendering/vulkan/system/vk_device.h index fd90febd0..d820ac0c8 100644 --- a/src/rendering/vulkan/system/vk_device.h +++ b/src/rendering/vulkan/system/vk_device.h @@ -71,83 +71,3 @@ private: friend class VulkanSwapChain; }; - -#if 0 - -struct QueueFamilyIndices -{ - int graphicsFamily = -1; - int presentFamily = -1; - - bool isComplete() - { - return graphicsFamily >= 0 && presentFamily >= 0; - } -}; - -struct SwapChainSupportDetails -{ - VkSurfaceCapabilitiesKHR capabilities; - std::vector formats; - std::vector presentModes; -}; - -class VulkanDevice -{ -public: - VkInstance vkInstance = VK_NULL_HANDLE; - VkSurfaceKHR vkSurface = VK_NULL_HANDLE; - VkPhysicalDevice vkPhysicalDevice = VK_NULL_HANDLE; - VkDevice vkDevice = VK_NULL_HANDLE; - VkDebugReportCallbackEXT vkCallback = VK_NULL_HANDLE; - VkQueue vkGraphicsQueue = VK_NULL_HANDLE; - VkQueue vkTransferQueue = VK_NULL_HANDLE; // for image transfers only. - VkQueue vkPresentQueue = VK_NULL_HANDLE; - VmaAllocator vkAllocator = VK_NULL_HANDLE; - VkCommandPool vkCommandPool = VK_NULL_HANDLE; - int numAllocatorExtensions = 0; - VkPhysicalDeviceProperties physicalProperties = {}; - -private: - void CreateInstance(); - bool CheckValidationLayerSupport(); - void SetupDebugCallback(); - void CreateSurface(); - void PickPhysicalDevice(); - bool IsDeviceSuitable(VkPhysicalDevice device); - bool CheckDeviceExtensionSupport(VkPhysicalDevice device); - void CreateLogicalDevice(); - void CreateAllocator(); - void CreateCommandPool(); - - std::vector GetRequiredExtensions(); - - std::mutex vkSingleTimeQueueMutex; - -public: - // This cannot be set up in the constructor because it may throw exceptions when initialization fails. - void CreateDevice(); - void DestroyDevice(); - QueueFamilyIndices FindQueueFamilies(VkPhysicalDevice device); - SwapChainSupportDetails QuerySwapChainSupport(VkPhysicalDevice device); - ~VulkanDevice() - { - DestroyDevice(); - } - - VkCommandBuffer BeginSingleTimeCommands(); - void EndSingleTimeCommands(VkCommandBuffer commandBuffer); - VkResult TransitionImageLayout(VkImage image, VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout, uint32_t mipLevels); - - int GetTexDimension(int d) - { - return std::min(d, physicalProperties.limits.maxImageDimension2D); - } - - int GetUniformBufferAlignment() - { - return (int)physicalProperties.limits.minUniformBufferOffsetAlignment; - } -}; - -#endif