From 695e2e5486634931d77ecec26467d961ac301a75 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Thu, 2 Jun 2022 00:14:32 +0200 Subject: [PATCH] views --- framework/sdl_service/test/vulkan_test.cpp | 35 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/framework/sdl_service/test/vulkan_test.cpp b/framework/sdl_service/test/vulkan_test.cpp index 44ee063..4af9e78 100644 --- a/framework/sdl_service/test/vulkan_test.cpp +++ b/framework/sdl_service/test/vulkan_test.cpp @@ -155,7 +155,10 @@ class VulkanRenderer : public Service { VkQueue _graphics_queue{}; //VkQueue _present_queue{}; + VkSwapchainKHR _swapchain{}; + std::vector _swapchain_images{}; + std::vector _swapchain_image_views{}; public: VulkanRenderer(void) { @@ -214,6 +217,10 @@ class VulkanRenderer : public Service { // cleanup if (_device) { vk::Device device{_device}; + + for (const auto& img_view : _swapchain_image_views) { + device.destroy(img_view); + } device.destroy(_swapchain); device.destroy(); } @@ -371,8 +378,32 @@ class VulkanRenderer : public Service { // TODO: fill in rest }); - auto images = device.getSwapchainImagesKHR(_swapchain); - SPDLOG_INFO("have {} swapchain images", images.size()); + { + _swapchain_images.clear(); + auto images = device.getSwapchainImagesKHR(_swapchain); + for (const auto& img : images) { + _swapchain_images.push_back(img); + } + } + SPDLOG_INFO("have {} swapchain images", _swapchain_images.size()); + + _swapchain_image_views.clear(); + for (const auto& img : _swapchain_images) { + _swapchain_image_views.push_back(device.createImageView({ + {}, + img, + vk::ImageViewType::e2D, + swap_surf_format.format, + {}, // comp mapping + { // subres + vk::ImageAspectFlagBits::eColor, + 0, + 1, + 0, + 1, + }, + })); + } return true; }