Open
Description
... and avk::read
does not perform such a barrier. Not sure yet, if this issue is a bug or an enhancement, though -- i.e., if it is the responsibility of avk::read
to perform the barrier or if it is the user's. But this should be investigated.
Anyways, Vulkan synchronization examples have the following example:
CPU read back of data written by a compute shader
This example shows the steps required to get data written to a buffer by a compute shader, back to the CPU.
vkCmdDispatch(...);
VkMemoryBarrier2KHR memoryBarrier = {
...
.srcStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT_KHR,
.srcAccessMask = VK_ACCESS_2_SHADER_WRITE_BIT_KHR,
.dstStageMask = VK_PIPELINE_STAGE_2_HOST_BIT_KHR,
.dstAccessMask = VK_ACCESS_2_HOST_READ_BIT_KHR};
VkDependencyInfoKHR dependencyInfo = {
...
1, // memoryBarrierCount
&memoryBarrier, // pMemoryBarriers
...
}
vkCmdPipelineBarrier2KHR(commandBuffer, &dependencyInfo);
vkEndCommandBuffer(...);
vkQueueSubmit2KHR(..., fence); // Submit the command buffer with a fence