Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There may be a problem with the imageSharingMode specified when creating the swap chain #337

Open
Traveller23 opened this issue May 15, 2023 · 0 comments

Comments

@Traveller23
Copy link

In most of the examples in this tutorial, this is what is written when creating a swap chain:

QueueFamilyIndices indices = findQueueFamilies(physicalDevice);
uint32_t queueFamilyIndices[] = {indices.graphicsFamily.value(), indices.presentFamily.value()};

if (indices.graphicsFamily != indices.presentFamily) {
    createInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
    createInfo.queueFamilyIndexCount = 2;
    createInfo.pQueueFamilyIndices = queueFamilyIndices;
} else {
    createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
}

Also, semaphores are created and used in vkAcquireNextImageKHR and vkQueueSubmit.

According to the standard documentation, semaphores are only needed if imageSharingMode is specified as VK_SHARING_MODE_EXCLUSIVE. When VK_SHARING_MODE_CONCURRENT is specified, though the standard does not explain, but it appears that synchronization can be performed without using any synchronization semantics such as semaphores.

So, no matter how many queue families we use, as long as we use semaphores, we only need to set imageSharingMode to VK_SHARING_MODE_EXCLUSIVE, which will also improve the performance.

Note VK_SHARING_MODE_CONCURRENT may result in lower performance access to the buffer or image than VK_SHARING_MODE_EXCLUSIVE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant