VulkanTutorial
VulkanTutorial copied to clipboard
There may be a problem with the `imageSharingMode` specified when creating the swap chain
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.