diff options
-rw-r--r-- | video.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -242,6 +242,7 @@ struct Context_Vk : public Context { void begin_record(Device_Vk* dev); Context_Vk& acquire(Device_Vk* dev); void release(); + void destroy(Device_Vk* dev); }; struct Texture_Vk : public Texture { @@ -631,9 +632,18 @@ void Device_Vk::init_internal() { } void Device_Vk::deinit_internal() { + int i; + vkDeviceWaitIdle(dev); swapchain.destroy(this); deinit_swap_cap(this, &swap_cap); app_destroy_vk_surface(app, inst, surf); + for (auto& i : rpo_cache) + i.second.destroy(this); + for (i = 0; i < max_contexts; i++) { + auto& context = contexts[i]; + if (context.state & context_state_init) + context.destroy(this); + } vkDestroyDevice(dev, &ac); #ifdef DEBUG destroy_dmesg( @@ -1140,6 +1150,13 @@ void Context_Vk::release() { state |= context_state_avail; } +void Context_Vk::destroy(Device_Vk* dev) { + state &= ~context_state_init; + vkDestroyCommandPool(dev->dev, pool, &dev->ac); + vkDestroySemaphore(dev->dev, semaphore, &dev->ac); + vkDestroyFence(dev->dev, fence, &dev->ac); +} + Context& Device::acquire() { Device_Vk* vk = (Device_Vk*)this; int i; |