I am trying to learn Vulkan, coming from OpenGL/OpenCL. I am studying this example: https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Base_code and this one: https://cppdig.com/c/minimal-example-of-using-vulkan-for-compute-operations-only-loc .
I am able to have the Vulkan's base code example working on my systems (Mac and Linux) and now I would like to add to it a compute shader whose purpose would be to programmatically compute the positions of the vertices of the triangles to be rendered graphically (e.g. for a physics simulation where I need to compute in runtime the positions of the nodes of a mesh via Verlet's integration).
It is not clear to me how to create a buffer which can be used both as a vertex buffer by the vertex shader and as a storage buffer by a compute shader.
As far as I understand, both mentioned examples use a custom function similar to the following to create a vertex buffer providing some specific parameters:
createBuffer (
bufferSize,
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
stagingBuffer,
stagingBufferMemory
);
and this one to create a storage buffer:
createBuffer (
bufferSize,
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
stagingBuffer,
stagingBufferMemory
);
I wonder if I should specify a usage bit mask as:
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT
as second argument of that function in order to create a single buffer that can be shared between the two shaders.
Moreover, it would be great if you could suggest me a complete example where this done.
P.S. In OpenGL/OpenCL I was used to use SSBO buffers, taking advantage of the GL/CL interop. But now I don't want to use OpenCL anymore, I want to use compute shaders.
Thanks