Reputation: 490
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:
Upvotes: 5
Views: 2407
Reputation: 473312
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.
Upvotes: 6