Skip to content

Commit

Permalink
vk: do not delay old swapchain destruction when creating new swapchain (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
poweifeng authored Jan 21, 2025
1 parent db6ded4 commit ada5791
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions filament/backend/src/vulkan/VulkanDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,11 @@ void VulkanDriver::createFenceR(Handle<HwFence> fh, int) {
}

void VulkanDriver::createSwapChainR(Handle<HwSwapChain> sch, void* nativeWindow, uint64_t flags) {
// Running gc() to guard against an edge case where the old swapchains need to have been
// destroyed before the new swapchain can be created. Otherwise, we would fail
// vkCreateSwapchainKHR with VK_ERROR_NATIVE_WINDOW_IN_USE_KHR.
mResourceManager.gc();

if ((flags & backend::SWAP_CHAIN_CONFIG_SRGB_COLORSPACE) != 0 && !isSRGBSwapChainSupported()) {
FVK_LOGW << "sRGB swapchain requested, but Platform does not support it"
<< utils::io::endl;
Expand Down
2 changes: 1 addition & 1 deletion filament/backend/src/vulkan/VulkanTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ VulkanTexture::VulkanTexture(VkDevice device, VkPhysicalDevice physicalDevice,
imageInfo.samples = (VkSampleCountFlagBits) samples;

VkResult result = vkCreateImage(mState->mDevice, &imageInfo, VKALLOC, &mState->mTextureImage);
if (result == VK_SUCCESS || FVK_ENABLED(FVK_DEBUG_TEXTURE)) {
if (result != VK_SUCCESS || FVK_ENABLED(FVK_DEBUG_TEXTURE)) {
FVK_LOGD << "vkCreateImage: "
<< "image = " << mState->mTextureImage << ", "
<< "result = " << result << ", "
Expand Down

0 comments on commit ada5791

Please sign in to comment.