a/vk: Use helper define in vk_csci_get_image_usage_flags

This commit is contained in:
Jakob Bornecrantz 2023-04-07 21:21:52 +01:00
parent 732c4a23ae
commit 585e23054d

View file

@ -178,45 +178,31 @@ vk_csci_get_image_usage_flags(struct vk_bundle *vk, VkFormat format, enum xrt_sw
VkImageUsageFlags image_usage = 0; VkImageUsageFlags image_usage = 0;
if ((bits & XRT_SWAPCHAIN_USAGE_DEPTH_STENCIL) != 0) { #define TEST(XRT_BIT, VK_FORMAT_BIT, VK_USAGE_BIT) \
if (!check_feature(format, XRT_SWAPCHAIN_USAGE_DEPTH_STENCIL, prop.optimalTilingFeatures, if ((bits & XRT_BIT) != 0) { \
VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) { if (!check_feature(format, XRT_BIT, prop.optimalTilingFeatures, VK_FORMAT_BIT)) { \
return 0; return 0; \
} } \
image_usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; image_usage |= VK_USAGE_BIT; \
} }
if ((bits & XRT_SWAPCHAIN_USAGE_COLOR) != 0) { // clang-format off
if (!check_feature(format, XRT_SWAPCHAIN_USAGE_COLOR, prop.optimalTilingFeatures, TEST(XRT_SWAPCHAIN_USAGE_COLOR, VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) { TEST(XRT_SWAPCHAIN_USAGE_INPUT_ATTACHMENT, VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT, VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)
return 0; TEST(XRT_SWAPCHAIN_USAGE_DEPTH_STENCIL, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)
} TEST(XRT_SWAPCHAIN_USAGE_TRANSFER_SRC, VK_FORMAT_FEATURE_TRANSFER_SRC_BIT, VK_IMAGE_USAGE_TRANSFER_SRC_BIT)
image_usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; TEST(XRT_SWAPCHAIN_USAGE_TRANSFER_DST, VK_FORMAT_FEATURE_TRANSFER_DST_BIT, VK_IMAGE_USAGE_TRANSFER_DST_BIT)
} TEST(XRT_SWAPCHAIN_USAGE_SAMPLED, VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT, VK_IMAGE_USAGE_SAMPLED_BIT)
if ((bits & XRT_SWAPCHAIN_USAGE_TRANSFER_SRC) != 0) { // clang-format on
if (!check_feature(format, XRT_SWAPCHAIN_USAGE_TRANSFER_SRC, prop.optimalTilingFeatures,
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT)) { #undef TEST
return 0;
} /*
image_usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT; * Should not be handled here.
} *
if ((bits & XRT_SWAPCHAIN_USAGE_TRANSFER_DST) != 0) { * XRT_SWAPCHAIN_USAGE_UNORDERED_ACCESS
if (!check_feature(format, XRT_SWAPCHAIN_USAGE_TRANSFER_DST, prop.optimalTilingFeatures, * XRT_SWAPCHAIN_USAGE_MUTABLE_FORMAT
VK_FORMAT_FEATURE_TRANSFER_DST_BIT)) { */
return 0;
}
image_usage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
}
if ((bits & XRT_SWAPCHAIN_USAGE_SAMPLED) != 0) {
if (!check_feature(format, XRT_SWAPCHAIN_USAGE_SAMPLED, prop.optimalTilingFeatures,
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)) {
return 0;
}
image_usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
}
if ((bits & XRT_SWAPCHAIN_USAGE_INPUT_ATTACHMENT) != 0) {
image_usage |= VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
}
return image_usage; return image_usage;
} }