#pragma once #include "dxvk_framebuffer.h" #include "dxvk_sync.h" namespace dxvk { class DxvkDevice; class DxvkFramebuffer; class DxvkSurface; /** * \brief */ struct DxvkSwapchainProperties { VkSurfaceFormatKHR preferredSurfaceFormat; VkPresentModeKHR preferredPresentMode; VkExtent2D preferredBufferSize; }; /** * \brief DXVK swapchain * * Manages a Vulkan swapchain object. */ class DxvkSwapchain : public RcObject { public: DxvkSwapchain( const Rc& device, const Rc& surface, const DxvkSwapchainProperties& properties, VkQueue queue); ~DxvkSwapchain(); /** * \brief Retrieves the framebuffer for the current frame * * If necessary, this will automatically recreate the * underlying swapchain object and framebuffer objects. * \param [in] wakeSync Semaphore to signal * \returns The framebuffer object */ Rc getFramebuffer( const Rc& wakeSync); /** * \brief Presents the current framebuffer * * This may actually fail to present an image. If that is the * case, the surface contents will be undefined for this frame * and the swapchain object will be recreated. * \param [in] waitSync Semaphore to wait on */ void present( const Rc& waitSync); /** * \brief Changes swapchain properties * * This must not be called between \ref getFramebuffer * and \ref present as this method may recreate the swap * chain and framebuffer objects immediately. * \param [in] props New swapchain properties */ void changeProperties( const DxvkSwapchainProperties& props); private: Rc m_device; Rc m_vkd; Rc m_surface; VkQueue m_queue; DxvkSwapchainProperties m_properties; VkSwapchainKHR m_handle = VK_NULL_HANDLE; uint32_t m_imageIndex = 0; uint32_t m_frameIndex = 0; Rc m_renderPass; std::vector> m_framebuffers; VkResult acquireNextImage( const Rc& wakeSync); void recreateSwapchain(); std::vector retrieveSwapImages(); }; }