Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For reading back data to the host, a barrier is required #59

Open
johannesugb opened this issue Dec 2, 2021 · 0 comments
Open

For reading back data to the host, a barrier is required #59

johannesugb opened this issue Dec 2, 2021 · 0 comments
Labels
bug Something isn't working enhancement New feature or request Vulkan Vulkan-centric task

Comments

@johannesugb
Copy link
Member

johannesugb commented Dec 2, 2021

... 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
@johannesugb johannesugb added bug Something isn't working enhancement New feature or request Vulkan Vulkan-centric task labels Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request Vulkan Vulkan-centric task
Development

No branches or pull requests

1 participant