#ifndef SWAP_CHAIN_STATE_VK_H #define SWAP_CHAIN_STATE_VK_H #include #include #include #include #include #include #include "goldfish_vk_dispatch.h" namespace gfxstream { namespace vk { struct SwapchainCreateInfoWrapper { VkSwapchainCreateInfoKHR mCreateInfo; std::vector mQueueFamilyIndices; SwapchainCreateInfoWrapper(const SwapchainCreateInfoWrapper&); SwapchainCreateInfoWrapper(SwapchainCreateInfoWrapper&&) = delete; SwapchainCreateInfoWrapper& operator=(const SwapchainCreateInfoWrapper&); SwapchainCreateInfoWrapper& operator=(SwapchainCreateInfoWrapper&&) = delete; SwapchainCreateInfoWrapper(const VkSwapchainCreateInfoKHR&); void setQueueFamilyIndices(const std::vector& queueFamilyIndices); }; // Assert SwapchainCreateInfoWrapper is a copy only class. static_assert(std::is_copy_assignable_v && std::is_copy_constructible_v && !std::is_move_constructible_v && !std::is_move_assignable_v); class SwapChainStateVk { public: static std::vector getRequiredInstanceExtensions(); static std::vector getRequiredDeviceExtensions(); static bool validateQueueFamilyProperties(const VulkanDispatch&, VkPhysicalDevice, VkSurfaceKHR, uint32_t queueFamilyIndex); static std::optional createSwapChainCi( const VulkanDispatch&, VkSurfaceKHR, VkPhysicalDevice, uint32_t width, uint32_t height, const std::unordered_set& queueFamilyIndices); SwapChainStateVk() = delete; SwapChainStateVk(const SwapChainStateVk&) = delete; SwapChainStateVk& operator = (const SwapChainStateVk&) = delete; static std::unique_ptr createSwapChainVk(const VulkanDispatch&, VkDevice, const VkSwapchainCreateInfoKHR&); ~SwapChainStateVk(); VkFormat getFormat(); VkExtent2D getImageExtent() const; const std::vector& getVkImages() const; const std::vector& getVkImageViews() const; VkSwapchainKHR getSwapChain() const; private: explicit SwapChainStateVk(const VulkanDispatch&, VkDevice); VkResult initSwapChainStateVk(const VkSwapchainCreateInfoKHR& swapChainCi); const static VkFormat k_vkFormat = VK_FORMAT_B8G8R8A8_UNORM; const static VkColorSpaceKHR k_vkColorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR; const VulkanDispatch& m_vk; VkDevice m_vkDevice; VkSwapchainKHR m_vkSwapChain; VkExtent2D m_vkImageExtent; std::vector m_vkImages; std::vector m_vkImageViews; }; } // namespace vk } // namespace gfxstream #endif