Skip to content

Commit ada5791

Browse files
authored
vk: do not delay old swapchain destruction when creating new swapchain (#8368)
Because of a recent ref-counting refactor, the swapchains are not being immediately destroyed when destorySwapChain is called. This might cause issue with following calls to createSwapChain. We make sure the ref-counted resources are cleaned-up before new swapchains are created. Fixes #8288
1 parent db6ded4 commit ada5791

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

filament/backend/src/vulkan/VulkanDriver.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,11 @@ void VulkanDriver::createFenceR(Handle<HwFence> fh, int) {
700700
}
701701

702702
void VulkanDriver::createSwapChainR(Handle<HwSwapChain> sch, void* nativeWindow, uint64_t flags) {
703+
// Running gc() to guard against an edge case where the old swapchains need to have been
704+
// destroyed before the new swapchain can be created. Otherwise, we would fail
705+
// vkCreateSwapchainKHR with VK_ERROR_NATIVE_WINDOW_IN_USE_KHR.
706+
mResourceManager.gc();
707+
703708
if ((flags & backend::SWAP_CHAIN_CONFIG_SRGB_COLORSPACE) != 0 && !isSRGBSwapChainSupported()) {
704709
FVK_LOGW << "sRGB swapchain requested, but Platform does not support it"
705710
<< utils::io::endl;

filament/backend/src/vulkan/VulkanTexture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ VulkanTexture::VulkanTexture(VkDevice device, VkPhysicalDevice physicalDevice,
296296
imageInfo.samples = (VkSampleCountFlagBits) samples;
297297

298298
VkResult result = vkCreateImage(mState->mDevice, &imageInfo, VKALLOC, &mState->mTextureImage);
299-
if (result == VK_SUCCESS || FVK_ENABLED(FVK_DEBUG_TEXTURE)) {
299+
if (result != VK_SUCCESS || FVK_ENABLED(FVK_DEBUG_TEXTURE)) {
300300
FVK_LOGD << "vkCreateImage: "
301301
<< "image = " << mState->mTextureImage << ", "
302302
<< "result = " << result << ", "

0 commit comments

Comments
 (0)