13 Swapchain::Swapchain(VkSwapchainKHR swapchain,
const Device* device,
const VkSurfaceFormatKHR& swapchainFormat,
const VkExtent2D& extent) :
14 _swapchain(swapchain), _device(device), _format(swapchainFormat), _extent(extent) {}
19 _images = std::move(swapchain._images);
23 swapchain._swapchain = VK_NULL_HANDLE;
24 swapchain._device =
nullptr;
32 _images = std::move(swapchain._images);
36 swapchain._swapchain = VK_NULL_HANDLE;
37 swapchain._device =
nullptr;
64 VkResult result{VK_SUCCESS};
65 uint32_t imagesCount = 0;
66 std::vector<VkImage> images;
68 result = vkGetSwapchainImagesKHR(static_cast<VkDevice>(*
_device),
_swapchain, &imagesCount,
nullptr);
70 if (result != VK_SUCCESS) {
71 LUG_LOG.error(
"RendererVulkan: Can't enumerate swapchain images: {}", result);
75 images.resize(imagesCount);
76 result = vkGetSwapchainImagesKHR(static_cast<VkDevice>(*
_device),
_swapchain, &imagesCount, images.data());
78 if (result != VK_SUCCESS) {
79 LUG_LOG.error(
"RendererVulkan: Can't enumerate swapchain images: {}", result);
86 for (uint8_t i = 0; i < images.size(); ++i) {
95 for (uint8_t i = 0; i <
_images.size(); ++i) {
96 VkResult result{VK_SUCCESS};
102 LUG_LOG.error(
"Forward::initDepthBuffers: Can't create swapchain image view: {}", result);
114 VkResult result = vkAcquireNextImageKHR(static_cast<VkDevice>(*
_device),
_swapchain, UINT64_MAX, semaphore, VK_NULL_HANDLE, imageIndex);
116 if (result == VK_ERROR_OUT_OF_DATE_KHR) {
119 }
else if (result != VK_SUCCESS) {
120 LUG_LOG.error(
"RendererVulkan: getNextImage(): Can't acquire swapchain next image: {}", result);
129 const VkPresentInfoKHR presentInfo{
130 VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
132 static_cast<uint32_t
>(semaphore != VK_NULL_HANDLE ? 1 : 0),
133 semaphore != VK_NULL_HANDLE ? &semaphore :
nullptr,
140 VkResult result = vkQueuePresentKHR(static_cast<VkQueue>(*presentQueue), &presentInfo);
142 if (result != VK_SUCCESS) {
143 LUG_LOG.error(
"RendererVulkan: present(): Can't acquire swapchain next image: {}", result);
bool build(API::ImageView &instance, VkResult *returnResult=nullptr)
VkSurfaceFormatKHR _format
bool present(const Queue *presentQueue, uint32_t imageIndex, VkSemaphore semaphore=VK_NULL_HANDLE) const
void setFormat(VkFormat format)
std::vector< ImageView > _imagesViews
bool getNextImage(uint32_t *imageIndex, VkSemaphore semaphore=VK_NULL_HANDLE)
std::vector< Image > _images
VkSwapchainKHR _swapchain
Swapchain & operator=(const Swapchain &)=delete