summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2020-02-26 20:51:53 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2020-02-26 21:07:18 +0100
commit0aaa69e4d73fb5ecc7f2eb2d2a2d84804704b962 (patch)
treed07f5c5ad3c758a0e1dfaceac6c7459adf81fb97 /src/video_core
parentMerge pull request #3431 from CJBok/npad-fix (diff)
downloadyuzu-0aaa69e4d73fb5ecc7f2eb2d2a2d84804704b962.tar
yuzu-0aaa69e4d73fb5ecc7f2eb2d2a2d84804704b962.tar.gz
yuzu-0aaa69e4d73fb5ecc7f2eb2d2a2d84804704b962.tar.bz2
yuzu-0aaa69e4d73fb5ecc7f2eb2d2a2d84804704b962.tar.lz
yuzu-0aaa69e4d73fb5ecc7f2eb2d2a2d84804704b962.tar.xz
yuzu-0aaa69e4d73fb5ecc7f2eb2d2a2d84804704b962.tar.zst
yuzu-0aaa69e4d73fb5ecc7f2eb2d2a2d84804704b962.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_vulkan/vk_swapchain.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp
index f47b691a8..9e73fa9cd 100644
--- a/src/video_core/renderer_vulkan/vk_swapchain.cpp
+++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp
@@ -141,11 +141,6 @@ void VKSwapchain::CreateSwapchain(const vk::SurfaceCapabilitiesKHR& capabilities
const vk::SurfaceFormatKHR surface_format{ChooseSwapSurfaceFormat(formats, srgb)};
const vk::PresentModeKHR present_mode{ChooseSwapPresentMode(present_modes)};
- extent = ChooseSwapExtent(capabilities, width, height);
-
- current_width = extent.width;
- current_height = extent.height;
- current_srgb = srgb;
u32 requested_image_count{capabilities.minImageCount + 1};
if (capabilities.maxImageCount > 0 && requested_image_count > capabilities.maxImageCount) {
@@ -153,10 +148,9 @@ void VKSwapchain::CreateSwapchain(const vk::SurfaceCapabilitiesKHR& capabilities
}
vk::SwapchainCreateInfoKHR swapchain_ci(
- {}, surface, requested_image_count, surface_format.format, surface_format.colorSpace,
- extent, 1, vk::ImageUsageFlagBits::eColorAttachment, {}, {}, {},
- capabilities.currentTransform, vk::CompositeAlphaFlagBitsKHR::eOpaque, present_mode, false,
- {});
+ {}, surface, requested_image_count, surface_format.format, surface_format.colorSpace, {}, 1,
+ vk::ImageUsageFlagBits::eColorAttachment, {}, {}, {}, capabilities.currentTransform,
+ vk::CompositeAlphaFlagBitsKHR::eOpaque, present_mode, false, {});
const u32 graphics_family{device.GetGraphicsFamily()};
const u32 present_family{device.GetPresentFamily()};
@@ -169,9 +163,18 @@ void VKSwapchain::CreateSwapchain(const vk::SurfaceCapabilitiesKHR& capabilities
swapchain_ci.imageSharingMode = vk::SharingMode::eExclusive;
}
+ // Request the size again to reduce the possibility of a TOCTOU race condition.
+ const auto updated_capabilities = physical_device.getSurfaceCapabilitiesKHR(surface, dld);
+ swapchain_ci.imageExtent = ChooseSwapExtent(updated_capabilities, width, height);
+ // Don't add code within this and the swapchain creation.
const auto dev{device.GetLogical()};
swapchain = dev.createSwapchainKHRUnique(swapchain_ci, nullptr, dld);
+ extent = swapchain_ci.imageExtent;
+ current_width = extent.width;
+ current_height = extent.height;
+ current_srgb = srgb;
+
images = dev.getSwapchainImagesKHR(*swapchain, dld);
image_count = static_cast<u32>(images.size());
image_format = surface_format.format;