I have a compute shader which produces vertex buffer and draw indirect structure that are then used to draw some geometry.
Compute shader is invoked not every frame, but once per 5-10 frames. In fact, I have my vertex and draw indirect buffers duplicated, so while I am rendering geometry using VB1 and DI1, compute shader is able to write to VB2 and DI2 and then swap them, so compute and drawing invocations may be independent. I also have 2 queue families: do-everything and compute-only.
So, I can think of 3 ways to do this:
VK_SHARING_MODE_EXCLUSIVE
buffersVK_SHARING_MODE_EXCLUSIVE
buffers and ownership transfer between queuesVK_SHARING_MODE_CONCURRENT
buffersI would like hearing your advices about what option to use and what are they pros/cons. I have some assumptions about it and want to know, am I right or not:
Swap chain. Vulkan does not have the concept of a "default framebuffer", hence it requires an infrastructure that will own the buffers we will render to before we visualize them on the screen. This infrastructure is known as the swap chain and must be created explicitly in Vulkan.
Ah, right, I see what you mean now. Yeah, the problem is that some drivers do report VK_PRESENT_MODE_FIFO_KHR as available, but they actually crash/behave weirdly if you choose to use it. That's why we still prefer immediate mode in that case. Ahhhh. Thanks!
Secondly, since image presentation is heavily tied into the window system and the surfaces associated with windows, it is not actually part of the Vulkan core. You have to enable the VK_KHR_swapchain device extension after querying for its support.
This function takes the specified VkPhysicalDevice and VkSurfaceKHR window surface into account when determining the supported capabilities. All of the support querying functions have these two as first parameters because they are the core components of the swap chain. The next step is about querying the supported surface formats.
Since the standard has this explicit warning:
VK_SHARING_MODE_CONCURRENT
may result in lower performance access to the buffer or image thanVK_SHARING_MODE_EXCLUSIVE
.
I would say that you should pick exclusive mode unless and until your profiling data suggests there is a performance problem. After all, you said there is at least a 5:1 ratio between using the buffers and moving them across queues. So you access the buffers with greater frequency than the frequency with which you perform queue ownership operations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With