mirror of
https://github.com/charles-lunarg/vk-bootstrap.git
synced 2024-11-25 16:24:35 +00:00
Added pNext chain support for swapchain::get_image_views
This commit is contained in:
parent
65071da181
commit
4a2984ad68
@ -1849,16 +1849,19 @@ detail::Result<std::vector<VkImage>> Swapchain::get_images() {
|
|||||||
return swapchain_images;
|
return swapchain_images;
|
||||||
}
|
}
|
||||||
detail::Result<std::vector<VkImageView>> Swapchain::get_image_views() {
|
detail::Result<std::vector<VkImageView>> Swapchain::get_image_views() {
|
||||||
|
return get_image_views(nullptr);
|
||||||
auto swapchain_images_ret = get_images();
|
}
|
||||||
|
detail::Result<std::vector<VkImageView>> Swapchain::get_image_views(const void* pNext) {
|
||||||
|
const auto swapchain_images_ret = get_images();
|
||||||
if (!swapchain_images_ret) return swapchain_images_ret.error();
|
if (!swapchain_images_ret) return swapchain_images_ret.error();
|
||||||
auto swapchain_images = swapchain_images_ret.value();
|
const auto swapchain_images = swapchain_images_ret.value();
|
||||||
|
|
||||||
std::vector<VkImageView> views(swapchain_images.size());
|
std::vector<VkImageView> views(swapchain_images.size());
|
||||||
|
|
||||||
for (size_t i = 0; i < swapchain_images.size(); i++) {
|
for (size_t i = 0; i < swapchain_images.size(); i++) {
|
||||||
VkImageViewCreateInfo createInfo = {};
|
VkImageViewCreateInfo createInfo = {};
|
||||||
createInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
createInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||||
|
createInfo.pNext = pNext;
|
||||||
createInfo.image = swapchain_images[i];
|
createInfo.image = swapchain_images[i];
|
||||||
createInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
createInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
||||||
createInfo.format = image_format;
|
createInfo.format = image_format;
|
||||||
|
@ -759,8 +759,10 @@ struct Swapchain {
|
|||||||
detail::Result<std::vector<VkImage>> get_images();
|
detail::Result<std::vector<VkImage>> get_images();
|
||||||
|
|
||||||
// Returns a vector of VkImageView's to the VkImage's of the swapchain.
|
// Returns a vector of VkImageView's to the VkImage's of the swapchain.
|
||||||
// VkImageViews must be destroyed.
|
// VkImageViews must be destroyed. The pNext chain must be a nullptr or a valid
|
||||||
|
// structure.
|
||||||
detail::Result<std::vector<VkImageView>> get_image_views();
|
detail::Result<std::vector<VkImageView>> get_image_views();
|
||||||
|
detail::Result<std::vector<VkImageView>> get_image_views(const void* pNext);
|
||||||
void destroy_image_views(std::vector<VkImageView> const& image_views);
|
void destroy_image_views(std::vector<VkImageView> const& image_views);
|
||||||
|
|
||||||
// A conversion function which allows this Swapchain to be used
|
// A conversion function which allows this Swapchain to be used
|
||||||
|
@ -290,6 +290,23 @@ TEST_CASE("Swapchain", "[VkBootstrap.bootstrap]") {
|
|||||||
REQUIRE(image_views.value().size() > 0);
|
REQUIRE(image_views.value().size() > 0);
|
||||||
swapchain.destroy_image_views(image_views.value());
|
swapchain.destroy_image_views(image_views.value());
|
||||||
}
|
}
|
||||||
|
AND_THEN("Acquire swapchain images views with nullptr pNext chain") {
|
||||||
|
auto image_views = swapchain.get_image_views(nullptr);
|
||||||
|
REQUIRE(image_views.has_value());
|
||||||
|
REQUIRE(image_views.value().size() > 0);
|
||||||
|
swapchain.destroy_image_views(image_views.value());
|
||||||
|
}
|
||||||
|
AND_THEN("Acquire swapchain image views with valid pNext chain") {
|
||||||
|
VkImageViewUsageCreateInfo usage = {
|
||||||
|
VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO,
|
||||||
|
nullptr,
|
||||||
|
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
|
||||||
|
};
|
||||||
|
auto image_views = swapchain.get_image_views(&usage);
|
||||||
|
REQUIRE(image_views.has_value());
|
||||||
|
REQUIRE(image_views.value().size() > 0);
|
||||||
|
swapchain.destroy_image_views(image_views.value());
|
||||||
|
}
|
||||||
|
|
||||||
vkb::destroy_swapchain(swapchain_ret.value());
|
vkb::destroy_swapchain(swapchain_ret.value());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user