Fix: Crash On Exit When Using Vulkan

Vulkan device was deallocated, but when destroying the GHOST context
the GPU context is reactivated and want to allocate buffers lazilly.

This is solved by de-initializing the device on platform exit, resetting
buffer pointers so double free can be detected.

Pull Request: https://projects.blender.org/blender/blender/pulls/111462
This commit is contained in:
Jeroen Bakker
2023-08-24 10:23:21 +02:00
parent 24a8d6425a
commit bce23aa0f5
2 changed files with 10 additions and 7 deletions
+5 -6
View File
@@ -90,15 +90,14 @@ void VKBackend::detect_workarounds(VKDevice &device)
void VKBackend::platform_exit()
{
GPG.clear();
}
void VKBackend::delete_resources()
{
if (device_.is_initialized()) {
device_.deinit();
VKDevice &device = VKBackend::get().device_;
if (device.is_initialized()) {
device.deinit();
}
}
void VKBackend::delete_resources() {}
void VKBackend::samplers_update() {}
void VKBackend::compute_dispatch(int groups_x_len, int groups_y_len, int groups_z_len)
+5 -1
View File
@@ -14,7 +14,9 @@ namespace blender::gpu {
VKBuffer::~VKBuffer()
{
free();
if (is_allocated()) {
free();
}
}
bool VKBuffer::is_allocated() const
@@ -144,6 +146,8 @@ bool VKBuffer::free()
const VKDevice &device = VKBackend::get().device_get();
VmaAllocator allocator = device.mem_allocator_get();
vmaDestroyBuffer(allocator, vk_buffer_, allocation_);
allocation_ = VK_NULL_HANDLE;
vk_buffer_ = VK_NULL_HANDLE;
return true;
}