Commit ad20b1ef authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

VulkanSwapChain: fix a problem in InitializeSwapChain() and add some DCHECK.

Bug: None
Change-Id: Ib855d479aa435d401de37496990eecc307a89eb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1676678Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672230}
parent 837c696f
......@@ -106,6 +106,8 @@ gfx::SwapResult VulkanSwapChain::SwapBuffers() {
end_write_semaphore_ = VK_NULL_HANDLE;
VkSemaphore vk_semaphore = CreateSemaphore(device);
DCHECK(vk_semaphore != VK_NULL_HANDLE);
uint32_t next_image = 0;
// Acquire then next image.
result = vkAcquireNextImageKHR(device, swap_chain_, UINT64_MAX, vk_semaphore,
......@@ -151,11 +153,6 @@ bool VulkanSwapChain::InitializeSwapChain(
VkSwapchainKHR new_swap_chain = VK_NULL_HANDLE;
result = vkCreateSwapchainKHR(device, &swap_chain_create_info, nullptr,
&new_swap_chain);
if (VK_SUCCESS != result) {
DLOG(ERROR) << "vkCreateSwapchainKHR() failed: " << result;
result = vkCreateSwapchainKHR(device, &swap_chain_create_info, nullptr,
&new_swap_chain);
}
if (old_swap_chain) {
auto* fence_helper = device_queue_->GetFenceHelper();
......@@ -163,6 +160,11 @@ bool VulkanSwapChain::InitializeSwapChain(
std::move(old_swap_chain));
}
if (VK_SUCCESS != result) {
DLOG(ERROR) << "vkCreateSwapchainKHR() failed: " << result;
return false;
}
swap_chain_ = new_swap_chain;
size_ = gfx::Size(swap_chain_create_info.imageExtent.width,
swap_chain_create_info.imageExtent.height);
......@@ -212,6 +214,8 @@ bool VulkanSwapChain::InitializeSwapImages(
}
VkSemaphore vk_semaphore = CreateSemaphore(device);
DCHECK(vk_semaphore != VK_NULL_HANDLE);
// Acquire the initial buffer.
result = vkAcquireNextImageKHR(device, swap_chain_, UINT64_MAX, vk_semaphore,
VK_NULL_HANDLE, &current_image_);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment