File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
filament/backend/src/vulkan Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 1919#include " VulkanCommands.h"
2020#include " VulkanTexture.h"
2121
22+ #include < utils/debug.h>
2223#include < utils/FixedCapacityVector.h>
2324#include < utils/Panic.h>
2425
@@ -105,6 +106,11 @@ void VulkanSwapChain::update() {
105106}
106107
107108void VulkanSwapChain::present (DriverBase& driver) {
109+ // The last acquire failed, so just skip presenting.
110+ if (!mAcquired ) {
111+ return ;
112+ }
113+
108114 if (!mHeadless && mTransitionSwapChainImageLayoutForPresent ) {
109115 VulkanCommandBuffer& commands = mCommands ->get ();
110116 VkImageSubresourceRange const subresources{
@@ -161,7 +167,15 @@ void VulkanSwapChain::acquire(bool& resized) {
161167
162168 VulkanPlatform::ImageSyncData imageSyncData;
163169 VkResult const result = mPlatform ->acquire (swapChain, &imageSyncData);
170+
171+ if (result != VK_SUCCESS) {
172+ // We just don't set mAcquired here so the next present will just skip.
173+ FVK_LOGD << " Failed to acquire next image in the swapchain result=" << (int ) result;
174+ return ;
175+ }
176+
164177 mCurrentSwapIndex = imageSyncData.imageIndex ;
178+ assert_invariant (mCurrentSwapIndex < mFinishedDrawing .size ());
165179 mFinishedDrawing [mCurrentSwapIndex ] = {};
166180 FILAMENT_CHECK_POSTCONDITION (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR)
167181 << " Cannot acquire in swapchain. error=" << static_cast <int32_t >(result);
You can’t perform that action at this time.
0 commit comments