aux/vk: Add vk_get_access_flags.

This commit is contained in:
Lubosz Sarnecki 2020-05-06 12:41:46 +02:00 committed by Jakob Bornecrantz
parent 06ce79272d
commit c09beb9efb
2 changed files with 29 additions and 0 deletions

View file

@ -1055,3 +1055,29 @@ err_memset:
U_ZERO(vk);
return ret;
}
VkAccessFlags
vk_get_access_flags(VkImageLayout layout)
{
switch (layout) {
case VK_IMAGE_LAYOUT_UNDEFINED: return 0;
case VK_IMAGE_LAYOUT_GENERAL:
return VK_ACCESS_TRANSFER_WRITE_BIT |
VK_ACCESS_TRANSFER_READ_BIT;
case VK_IMAGE_LAYOUT_PREINITIALIZED: return VK_ACCESS_HOST_WRITE_BIT;
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
return VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
return VK_ACCESS_TRANSFER_READ_BIT;
case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
return VK_ACCESS_TRANSFER_WRITE_BIT;
case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
return VK_ACCESS_SHADER_READ_BIT;
default:
fprintf(stderr, "Unhandled access mask case for layout %d.\n",
layout);
}
return 0;
}

View file

@ -399,6 +399,9 @@ VkResult
vk_submit_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer cmd_buffer);
VkAccessFlags
vk_get_access_flags(VkImageLayout layout);
#ifdef __cplusplus
}
#endif