Skip to content

Commit 01d7366

Browse files
committed
views
1 parent 682116f commit 01d7366

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

framework/sdl_service/test/vulkan_test.cpp

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ class VulkanRenderer : public Service {
155155

156156
VkQueue _graphics_queue{};
157157
//VkQueue _present_queue{};
158+
158159
VkSwapchainKHR _swapchain{};
160+
std::vector<VkImage> _swapchain_images{};
161+
std::vector<VkImageView> _swapchain_image_views{};
159162

160163
public:
161164
VulkanRenderer(void) {
@@ -214,6 +217,10 @@ class VulkanRenderer : public Service {
214217
// cleanup
215218
if (_device) {
216219
vk::Device device{_device};
220+
221+
for (const auto& img_view : _swapchain_image_views) {
222+
device.destroy(img_view);
223+
}
217224
device.destroy(_swapchain);
218225
device.destroy();
219226
}
@@ -371,8 +378,32 @@ class VulkanRenderer : public Service {
371378
// TODO: fill in rest
372379
});
373380

374-
auto images = device.getSwapchainImagesKHR(_swapchain);
375-
SPDLOG_INFO("have {} swapchain images", images.size());
381+
{
382+
_swapchain_images.clear();
383+
auto images = device.getSwapchainImagesKHR(_swapchain);
384+
for (const auto& img : images) {
385+
_swapchain_images.push_back(img);
386+
}
387+
}
388+
SPDLOG_INFO("have {} swapchain images", _swapchain_images.size());
389+
390+
_swapchain_image_views.clear();
391+
for (const auto& img : _swapchain_images) {
392+
_swapchain_image_views.push_back(device.createImageView({
393+
{},
394+
img,
395+
vk::ImageViewType::e2D,
396+
swap_surf_format.format,
397+
{}, // comp mapping
398+
{ // subres
399+
vk::ImageAspectFlagBits::eColor,
400+
0,
401+
1,
402+
0,
403+
1,
404+
},
405+
}));
406+
}
376407

377408
return true;
378409
}

0 commit comments

Comments
 (0)